1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Allows to pass a field referring to the grid F on the grid V, |
---|
5 | ; thanks to the average: |
---|
6 | ; res = 0.5*(res + shift(res, 1, 0)) |
---|
7 | ; |
---|
8 | ; @categories |
---|
9 | ; Grid |
---|
10 | ; |
---|
11 | ; @param TEMP {in}{required} |
---|
12 | ; A 2, 3 or 4d array |
---|
13 | ; |
---|
14 | ; @returns |
---|
15 | ; a 2d, 3d or 4d array |
---|
16 | ; |
---|
17 | ; @uses |
---|
18 | ; common.pro |
---|
19 | ; |
---|
20 | ; @restrictions |
---|
21 | ; Force parameters of the zoom on the grid V to be the same as |
---|
22 | ; those on the grid T. |
---|
23 | ; |
---|
24 | ; @restrictions |
---|
25 | ; Points which can not be calculated are put at the value NaN |
---|
26 | ; consecrated by IDL: !values.f_nan |
---|
27 | ; |
---|
28 | ; @history |
---|
29 | ; From Marina Levy's programs |
---|
30 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr): |
---|
31 | ; Validation. 5/6/2000 |
---|
32 | ; |
---|
33 | ; @version |
---|
34 | ; $Id$ |
---|
35 | ; |
---|
36 | ;- |
---|
37 | FUNCTION f2v, temp |
---|
38 | ; |
---|
39 | compile_opt idl2, strictarrsubs |
---|
40 | ; |
---|
41 | @cm_4mesh |
---|
42 | @cm_4data |
---|
43 | @cm_4cal |
---|
44 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
45 | @updatenew |
---|
46 | ENDIF |
---|
47 | ;--------------------------------------------------------- |
---|
48 | res = temp |
---|
49 | ;We force nxt=nxf, etc ... |
---|
50 | firstxv = firstxf |
---|
51 | lastxv = lastxf |
---|
52 | firstyv = firstyf |
---|
53 | lastyv = lastyf |
---|
54 | nxv = nxf |
---|
55 | nyv = nyf |
---|
56 | vargrid = 'V' |
---|
57 | if NOT keyword_set(valmask) then valmask = 1e20 |
---|
58 | lon1 = glamv[firstxv, 0] |
---|
59 | lon2 = glamf[lastxf, 0] |
---|
60 | |
---|
61 | ; case on tha array's size and application |
---|
62 | taille = size(temp) |
---|
63 | CASE taille[0] OF |
---|
64 | 1: res = -1 |
---|
65 | 2: BEGIN |
---|
66 | case 1 of |
---|
67 | taille[1] eq nxf and taille[2] eq nyf: |
---|
68 | taille[1] eq jpi and taille[2] eq jpj: $ |
---|
69 | res=res[firstxf:lastxf, firstyf:lastyf] |
---|
70 | else: $ |
---|
71 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
72 | endcase |
---|
73 | mask = (fmask())[firstxf:lastxf, firstyf:lastyf, 0] |
---|
74 | terre = where(mask EQ 0) |
---|
75 | IF terre[0] NE -1 THEN res[terre] = !values.f_nan |
---|
76 | res = 0.5*(res + shift(res, 1, 0)) |
---|
77 | if NOT (keyword_set(key_periodic) AND nxf EQ jpi) then res[0, *] = !values.f_nan |
---|
78 | mask = (vmask())[firstxf:lastxf, firstyf:lastyf, 0] |
---|
79 | terre = where(mask EQ 0) |
---|
80 | IF terre[0] NE -1 THEN res[terre] = valmask |
---|
81 | END |
---|
82 | 3: BEGIN |
---|
83 | case 1 of |
---|
84 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ nzt: |
---|
85 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpk: $ |
---|
86 | res=res[*, *, firstzt:lastzt] |
---|
87 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpt: |
---|
88 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $ |
---|
89 | res=res[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
90 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $ |
---|
91 | res=res[firstxf:lastxf, firstyf:lastyf, *] |
---|
92 | else: $ |
---|
93 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
94 | ENDCASE |
---|
95 | if taille[3] EQ jpt then begin |
---|
96 | mask = (fmask())[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)] |
---|
97 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
98 | mask = reform(mask, nxf, nyf, jpt, /over) |
---|
99 | ENDIF ELSE mask = (fmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
100 | terre = where(temporary(mask) EQ 0) |
---|
101 | IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan |
---|
102 | res = 0.5*(res + shift(res, 1, 0, 0)) |
---|
103 | if NOT (keyword_set(key_periodic) AND nxf EQ jpi) then res[0, *, *] = !values.f_nan |
---|
104 | if taille[3] EQ jpt then BEGIN |
---|
105 | mask = tmask[firstxf:lastxf, firstyf:lastyf, lastzt*(nzt NE jpk)] |
---|
106 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
107 | mask = reform(mask, nxf, nyf, jpt, /over) |
---|
108 | ENDIF ELSE mask = (vmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
109 | terre = where(temporary(mask) EQ 0) |
---|
110 | IF terre[0] NE -1 THEN res[temporary(terre)] = valmask |
---|
111 | END |
---|
112 | 4: BEGIN |
---|
113 | case 1 of |
---|
114 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ nzt AND taille[4] EQ jpt: |
---|
115 | taille[1] eq nxf and taille[2] eq nyf AND taille[3] EQ jpk AND taille[4] EQ jpt: $ |
---|
116 | res=res[*, *, firstzt:lastzt, *] |
---|
117 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk AND taille[4] EQ jpt: $ |
---|
118 | res=res[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt, *] |
---|
119 | else: $ |
---|
120 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
121 | ENDCASE |
---|
122 | mask = (fmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
123 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
124 | mask = reform(mask, nxf, nyf, nzt, jpt, /over) |
---|
125 | terre = where(temporary(mask) EQ 0) |
---|
126 | IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan |
---|
127 | res = 0.5*(res + shift(res, 1, 0, 0, 0)) |
---|
128 | if NOT (keyword_set(key_periodic) AND nxf EQ jpi) then res[0, *, *, *] = !values.f_nan |
---|
129 | mask = (vmask())[firstxf:lastxf, firstyf:lastyf, firstzt:lastzt] |
---|
130 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
131 | mask = reform(mask, nxf, nyf, nzt, jpt, /over) |
---|
132 | terre = where(temporary(mask) EQ 0) |
---|
133 | IF terre[0] NE -1 THEN res[temporary(terre)] = valmask |
---|
134 | END |
---|
135 | endcase |
---|
136 | |
---|
137 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
138 | @updateold |
---|
139 | ENDIF |
---|
140 | |
---|
141 | return, res |
---|
142 | END |
---|