1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Overprint vectors in a field traced by plt. |
---|
5 | ; |
---|
6 | ; @categories |
---|
7 | ; Graphics |
---|
8 | ; |
---|
9 | ; @param VECTEUR {in}{required}{type=vector} |
---|
10 | ; It is a structure with 2 elements containing we 2 matrices U and V of |
---|
11 | ; values of the zonal and meridian component of the field of vectors to |
---|
12 | ; be traced. |
---|
13 | ; For ex: |
---|
14 | ; vecteur={matriceu:lec('unsurface'),matricev:lec('vnsurface')} |
---|
15 | ; rq:the name of elements of vector does not have any importance. |
---|
16 | ; vecteur={u:lec('unsurface'),v:lec('vnsurface')} goes well too. |
---|
17 | ; |
---|
18 | ; @keyword UNVECTSUR {type=scalar or array} |
---|
19 | ; It is a scalar n or an array with 2 elements [n1,n2]. |
---|
20 | ; In the first case, we will trace a vector on n following x and y. |
---|
21 | ; In the second case, we will trace a vector on n1 following x and a |
---|
22 | ; vector n2 following n2 |
---|
23 | ; Comments: To trace all vectors following y and one vector on two |
---|
24 | ; following x, put unvectsur=[2,1] |
---|
25 | ; |
---|
26 | ; @keyword VECTMIN {in}{required} |
---|
27 | ; Minimum norme of vectors to be traced |
---|
28 | ; |
---|
29 | ; @keyword VECTMAX {in}{required} |
---|
30 | ; Maximum norme of vectors to be traced |
---|
31 | ; |
---|
32 | ; @keyword _EXTRA |
---|
33 | ; Used to pass keywords |
---|
34 | ; |
---|
35 | ; @uses |
---|
36 | ; common.pro |
---|
37 | ; |
---|
38 | ; @history |
---|
39 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
40 | ; 10/3/1999 |
---|
41 | ; 11/6/1999 compatibilite avec NAN et la lecture |
---|
42 | ; des structures. |
---|
43 | ; |
---|
44 | ; @version |
---|
45 | ; $Id$ |
---|
46 | ; |
---|
47 | ;- |
---|
48 | ; |
---|
49 | PRO ajoutvect,vecteur, vectlegende, UNVECTSUR=unvectsur,VECTMIN=vectmin, VECTMAX=vectmax, _EXTRA = ex |
---|
50 | ; |
---|
51 | compile_opt idl2, strictarrsubs |
---|
52 | ; |
---|
53 | @common |
---|
54 | tempsun = systime(1) ; For key_performance |
---|
55 | ;---------------------------------------------------------------------------- |
---|
56 | ; |
---|
57 | u = litchamp(vecteur.(0)) |
---|
58 | u = checkfield(u, 'plt', TYPE = 'xy', /NOQUESTION) |
---|
59 | v = litchamp(vecteur.(1)) |
---|
60 | v = checkfield(v, 'plt', TYPE = 'xy', /NOQUESTION) |
---|
61 | ;----------------------------------------------------------- |
---|
62 | ;----------------------------------------------------------- |
---|
63 | ; We recuperate possible informations on fields |
---|
64 | ;----------------------------------------------------------- |
---|
65 | grilleu = litchamp(vecteur.(0), /grid) |
---|
66 | if grilleu EQ '' then grilleu = 'U' |
---|
67 | grillev = litchamp(vecteur.(1), /grid) |
---|
68 | if grillev EQ '' then grillev = 'V' |
---|
69 | |
---|
70 | IF grilleu EQ 'V' AND grillev EQ 'U' THEN inverse = 1 |
---|
71 | IF grilleu EQ grillev THEN interpolle = 0 ELSE interpolle = 1 |
---|
72 | if keyword_set(inverse) then begin |
---|
73 | rien = u |
---|
74 | u = v |
---|
75 | v = rien |
---|
76 | endif |
---|
77 | ;------------------------------------------------------------ |
---|
78 | ; We find common points between u and v |
---|
79 | ;------------------------------------------------------------ |
---|
80 | if interpolle then begin |
---|
81 | indicexu = (lindgen(jpi))[firstxu:firstxu+nxu-1] |
---|
82 | indicexv = (lindgen(jpi))[firstxv:firstxv+nxv-1] |
---|
83 | indicex = inter(indicexu, indicexv) |
---|
84 | indiceyu = (lindgen(jpj))[firstyu:firstyu+nyu-1] |
---|
85 | indiceyv = (lindgen(jpj))[firstyv:firstyv+nyv-1] |
---|
86 | indicey = inter(indiceyu, indiceyv) |
---|
87 | nx = n_elements(indicex) |
---|
88 | ny = n_elements(indicey) |
---|
89 | indice2d = lindgen(jpi, jpj) |
---|
90 | indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] |
---|
91 | ;------------------------------------------------------------ |
---|
92 | ; extraction of u and v on the appropriated domain |
---|
93 | ;------------------------------------------------------------ |
---|
94 | case 1 of |
---|
95 | (size(u))[0] NE 2 OR (size(v))[0] NE 2: return |
---|
96 | (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ |
---|
97 | (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN |
---|
98 | if nxu NE nx then $ |
---|
99 | if indicex[0] EQ firstxu then u = u[0:nx-1, *] ELSE u = u[1: nx, *] |
---|
100 | IF nxv NE nx THEN $ |
---|
101 | if indicex[0] EQ firstxv then v = v[0:nx-1, *] ELSE v = v[1: nx, *] |
---|
102 | IF nyu NE ny THEN $ |
---|
103 | if indicey[0] EQ firstyu then u = u[*, 0:ny-1] ELSE u = u[*, 1: ny] |
---|
104 | IF nyv NE ny THEN $ |
---|
105 | if indicey[0] EQ firstyv then v = v[*, 0:ny-1] ELSE v = v[*, 1: ny] |
---|
106 | END |
---|
107 | (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND $ |
---|
108 | (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN |
---|
109 | u = u[indice2d] |
---|
110 | v = v[indice2d] |
---|
111 | END |
---|
112 | ELSE:BEGIN |
---|
113 | ras = report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs') |
---|
114 | return |
---|
115 | end |
---|
116 | endcase |
---|
117 | ;------------------------------------------------------------------ |
---|
118 | ; We reshape u and v to make sure that none dimension has been erased. |
---|
119 | ;------------------------------------------------------------------ |
---|
120 | if ny EQ 1 then begin |
---|
121 | u = reform(u, nx, ny) |
---|
122 | v = reform(v, nx, ny) |
---|
123 | endif |
---|
124 | ;------------------------------------------------------------------ |
---|
125 | ; construction of u and v at points T |
---|
126 | ;----------------------------------------------------------- |
---|
127 | a=u[0,*] |
---|
128 | u=(u+shift(u,1,0))/2. |
---|
129 | if NOT keyword_set(key_periodic) OR nx NE jpi then u[0,*]=a |
---|
130 | a=v[*,0] |
---|
131 | v=(v+shift(v,0,1))/2. |
---|
132 | if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0]=a |
---|
133 | ;---------------------------------------------------------------------------- |
---|
134 | ; attribution of the mask and of longitude and latitude arrays. |
---|
135 | ; We recuperate the complete grid to establish a big mask extensive |
---|
136 | ; in the four directions to cover points for which a land point has |
---|
137 | ; been considerated (do a small drawing) |
---|
138 | ;---------------------------------------------------------------------------- |
---|
139 | vargrid='T' |
---|
140 | msku = (umask())[indice2d+jpi*jpj*firstzt] |
---|
141 | mskv = (vmask())[indice2d+jpi*jpj*firstzt] |
---|
142 | glam = glamt[indice2d] |
---|
143 | gphi = gphit[indice2d] |
---|
144 | if ny EQ 1 then begin |
---|
145 | msku = reform(msku, nx, ny) |
---|
146 | mskv = reform(mskv, nx, ny) |
---|
147 | ; glam = reform(glam, nx, ny) |
---|
148 | ; gphi = reform(gphi, nx, ny) |
---|
149 | endif |
---|
150 | ;----------------------------------------------------------- |
---|
151 | ; We mask u and v et v the long of coasts (the place where we |
---|
152 | ; can not calculate the average) |
---|
153 | ;----------------------------------------------------------- |
---|
154 | ; extention of the mask |
---|
155 | u = u*msku*shift(msku,1,0) |
---|
156 | v = v*mskv*shift(mskv,0,1) |
---|
157 | ENDIF ELSE BEGIN |
---|
158 | u = u*tmask[firstxt:lastxt,firstyt:lastyt,firstzt] |
---|
159 | v = v*tmask[firstxt:lastxt,firstyt:lastyt,firstzt] |
---|
160 | indice2d = lindgen(jpi, jpj) |
---|
161 | indice2d = indice2d[firstxt:lastxt, firstyt:lastyt] |
---|
162 | nx = nxt |
---|
163 | ny = nyt |
---|
164 | endelse |
---|
165 | tabnorme=sqrt(u^2+v^2) |
---|
166 | nan = where(finite(u, /nan) EQ 1) |
---|
167 | if nan[0] NE -1 then u[nan] = 1e5 |
---|
168 | nan = where(finite(v, /nan) EQ 1) |
---|
169 | if nan[0] NE -1 then v[nan] = 1e5 |
---|
170 | if keyword_set(vectmin) then BEGIN |
---|
171 | toosmall=where(tabnorme lt vectmin) |
---|
172 | if toosmall[0] NE -1 then begin |
---|
173 | u[toosmall] = 1e5 |
---|
174 | v[toosmall] = 1e5 |
---|
175 | ENDIF |
---|
176 | endif |
---|
177 | if keyword_set(vectmax) then BEGIN |
---|
178 | toobig=where(tabnorme gt vectmax) |
---|
179 | if toobig[0] NE -1 then begin |
---|
180 | u[toobig] = 1e5 |
---|
181 | v[toobig] = 1e5 |
---|
182 | ENDIF |
---|
183 | ENDIF |
---|
184 | ;----------------------------------------------------------- |
---|
185 | ; Put back of a big value on all points for which we can do the calculation. |
---|
186 | ;----------------------------------------------------------- |
---|
187 | if interpolle then t2 = msku*shift(msku,1,0)*mskv*shift(mskv,0,1) $ |
---|
188 | ELSE t2 = tmask[firstxt:lastxt,firstyt:lastyt,firstzt] |
---|
189 | if NOT keyword_set(key_periodic) OR nx NE jpi then t2[0, *]=0. |
---|
190 | t2[*,0]=0. |
---|
191 | terre=where(t2 eq 0) |
---|
192 | if terre[0] ne -1 then begin |
---|
193 | u[terre]=1e5 |
---|
194 | v[terre]=1e5 |
---|
195 | ENDIF |
---|
196 | ;----------------------------------------------------------- |
---|
197 | ; trace only one vector one two |
---|
198 | ;----------------------------------------------------------- |
---|
199 | if keyword_set(unvectsur) then BEGIN ; |
---|
200 | ; indx is a vector containing number of columns to be selected. |
---|
201 | ; indy is a vector containing number of lines to be selected. |
---|
202 | if n_elements(unvectsur) EQ 1 then begin |
---|
203 | indx = where((lindgen(nx) MOD unvectsur[0]) eq 0) |
---|
204 | indy = where((lindgen(ny) MOD unvectsur[0]) eq 0) |
---|
205 | ENDIF ELSE BEGIN |
---|
206 | indx = where((lindgen(nx) MOD unvectsur[0]) eq 0) |
---|
207 | indy = where((lindgen(ny) MOD unvectsur[1]) eq 0) |
---|
208 | ENDELSE |
---|
209 | ; From indx and indy, we will construct an array which will give indexes |
---|
210 | ; of intersections points of columns specified by indx. |
---|
211 | indicereduit = indx#replicate(1,n_elements(indy))+nx*replicate(1,n_elements(indx))#indy |
---|
212 | ; We reduce arrays which will be passed to vecteur. |
---|
213 | u = u[indicereduit] |
---|
214 | v = v[indicereduit] |
---|
215 | tabnorme = tabnorme[indicereduit] |
---|
216 | t2 = t2[indicereduit] |
---|
217 | ; |
---|
218 | endif |
---|
219 | ;----------------------------------------------------------- |
---|
220 | ; |
---|
221 | ;----------------------------------------------------------- |
---|
222 | if keyword_set(inverse) then begin |
---|
223 | rien = u |
---|
224 | u = v |
---|
225 | v = rien |
---|
226 | endif |
---|
227 | ;----------------------------------------------------------- |
---|
228 | ; Drawing of vectors. |
---|
229 | ;---------------------------------------------------------- |
---|
230 | vecteur, u, v, tabnorme, indice2d, indicereduit, missing=1e5, _extra = ex |
---|
231 | ;----------------------------------------------------------- |
---|
232 | ; We complete the caption. |
---|
233 | ;----------------------------------------------------------- |
---|
234 | if terre[0] ne -1 then mini = min(tabnorme[where(t2 eq 1)], max = maxi, /nan) $ |
---|
235 | ELSE mini = min(tabnorme, max = maxi, /nan) |
---|
236 | |
---|
237 | if litchamp(vecteur.(0), /u) NE '' then $ |
---|
238 | vectlegende = {minmax:[mini, maxi], unite:litchamp(vecteur.(0), /u)} $ |
---|
239 | ELSE vectlegende = {minmax:[mini, maxi], unite:varunit} |
---|
240 | |
---|
241 | |
---|
242 | sortie: |
---|
243 | if keyword_set(key_performance) NE 0 THEN print, 'temps ajoutvect', systime(1)-tempsun |
---|
244 | return |
---|
245 | end |
---|