1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Allows to pass a field referring to the grid V on the grid T, |
---|
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 2d, 3d 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 | ; @todo |
---|
37 | ; seb: nom du input? |
---|
38 | ; |
---|
39 | ;- |
---|
40 | ; |
---|
41 | FUNCTION v2t, temp |
---|
42 | ; |
---|
43 | compile_opt idl2, strictarrsubs |
---|
44 | ; |
---|
45 | @cm_4mesh |
---|
46 | @cm_4data |
---|
47 | @cm_4cal |
---|
48 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
49 | @updatenew |
---|
50 | ENDIF |
---|
51 | ;--------------------------------------------------------- |
---|
52 | res = temp |
---|
53 | ;We force nxt=nxv, etc ... |
---|
54 | firstxt = firstxv |
---|
55 | lastxt = lastxv |
---|
56 | firstyt = firstyv |
---|
57 | lastyt = lastyv |
---|
58 | nxt = nxv |
---|
59 | nyt = nyv |
---|
60 | vargrid = 'T' |
---|
61 | if NOT keyword_set(valmask) then valmask = 1e20 |
---|
62 | lat1 = gphit[0, firstyt] |
---|
63 | lat2 = gphiv[0, lastyv] |
---|
64 | |
---|
65 | ; case on tha array's size and application |
---|
66 | taille = size(temp) |
---|
67 | CASE taille[0] OF |
---|
68 | 1: res = -1 |
---|
69 | 2: BEGIN |
---|
70 | case 1 of |
---|
71 | taille[1] eq nxv and taille[2] eq nyv: |
---|
72 | taille[1] eq jpi and taille[2] eq jpj: $ |
---|
73 | res=res[firstxv:lastxv, firstyv:lastyv] |
---|
74 | else: $ |
---|
75 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
76 | endcase |
---|
77 | mask = (vmask())[firstxv:lastxv, firstyv:lastyv, 0] |
---|
78 | terre = where(mask EQ 0) |
---|
79 | IF terre[0] NE -1 THEN res[terre] = !values.f_nan |
---|
80 | res = 0.5*(res + shift(res, 0, +1)) |
---|
81 | res[*, 0] = !values.f_nan |
---|
82 | mask = tmask[firstxv:lastxv, firstyv:lastyv, 0] |
---|
83 | terre = where(mask EQ 0) |
---|
84 | IF terre[0] NE -1 THEN res[terre] = valmask |
---|
85 | END |
---|
86 | 3: BEGIN |
---|
87 | case 1 of |
---|
88 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ nzt: |
---|
89 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpk: $ |
---|
90 | res=res[*, *, firstzt:lastzt] |
---|
91 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpt: |
---|
92 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk: $ |
---|
93 | res=res[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
94 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpt: $ |
---|
95 | res=res[firstxv:lastxv, firstyv:lastyv, *] |
---|
96 | else: $ |
---|
97 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
98 | ENDCASE |
---|
99 | if taille[3] EQ jpt then begin |
---|
100 | mask = (vmask())[firstxv:lastxv, firstyv:lastyv, lastzt*(nzt NE jpk)] |
---|
101 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
102 | mask = reform(mask, nxv, nyv, jpt, /over) |
---|
103 | ENDIF ELSE mask = (vmask())[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
104 | terre = where(temporary(mask) EQ 0) |
---|
105 | IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan |
---|
106 | res = 0.5*(res + shift(res, 0, +1, 0)) |
---|
107 | res[*, 0, *] = !values.f_nan |
---|
108 | if taille[3] EQ jpt then BEGIN |
---|
109 | mask = tmask[firstxv:lastxv, firstyv:lastyv, lastzt*(nzt NE jpk)] |
---|
110 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
111 | mask = reform(mask, nxv, nyv, jpt, /over) |
---|
112 | ENDIF ELSE mask = tmask[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
113 | terre = where(temporary(mask) EQ 0) |
---|
114 | IF terre[0] NE -1 THEN res[temporary(terre)] = valmask |
---|
115 | END |
---|
116 | 4: BEGIN |
---|
117 | case 1 of |
---|
118 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ nzt AND taille[4] EQ jpt: |
---|
119 | taille[1] eq nxv and taille[2] eq nyv AND taille[3] EQ jpk AND taille[4] EQ jpt: $ |
---|
120 | res=res[*, *, firstzt:lastzt, *] |
---|
121 | taille[1] eq jpi and taille[2] eq jpj AND taille[3] EQ jpk AND taille[4] EQ jpt: $ |
---|
122 | res=res[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt, *] |
---|
123 | else: $ |
---|
124 | return, report('Probleme d''adequation entre les tailles du domaine et de la boite.') |
---|
125 | ENDCASE |
---|
126 | mask = (vmask())[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
127 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
128 | mask = reform(mask, nxv, nyv, nzt, jpt, /over) |
---|
129 | terre = where(temporary(mask) EQ 0) |
---|
130 | IF terre[0] NE -1 THEN res[temporary(terre)] = !values.f_nan |
---|
131 | res = 0.5*(res + shift(res, 0, +1, 0, 0)) |
---|
132 | res[*, 0, *, *] = !values.f_nan |
---|
133 | mask = tmask[firstxv:lastxv, firstyv:lastyv, firstzt:lastzt] |
---|
134 | mask = temporary(mask[*])#replicate(1, jpt) |
---|
135 | mask = reform(mask, nxv, nyv, nzt, jpt, /over) |
---|
136 | terre = where(temporary(mask) EQ 0) |
---|
137 | IF terre[0] NE -1 THEN res[temporary(terre)] = valmask |
---|
138 | END |
---|
139 | endcase |
---|
140 | |
---|
141 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
142 | @updateold |
---|
143 | ENDIF |
---|
144 | |
---|
145 | return, res |
---|
146 | END |
---|