source: trunk/SRC/ToBeReviewed/PLOTS/VECTEUR/ajoutvect.pro @ 325

Last change on this file since 325 was 325, checked in by pinsard, 16 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.2 KB
Line 
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;-
48PRO ajoutvect,vecteur, vectlegende, UNVECTSUR=unvectsur,VECTMIN=vectmin, VECTMAX=vectmax, _EXTRA = ex
49;
50  compile_opt idl2, strictarrsubs
51;
52@common
53   tempsun = systime(1)         ; For key_performance
54;----------------------------------------------------------------------------
55;
56   u = litchamp(vecteur.(0))
57   u = checkfield(u, 'plt', TYPE = 'xy', /NOQUESTION)
58   v = litchamp(vecteur.(1))
59   v = checkfield(v, 'plt', TYPE = 'xy', /NOQUESTION)
60;-----------------------------------------------------------
61;-----------------------------------------------------------
62; We recuperate possible informations on fields
63;-----------------------------------------------------------
64   grilleu = litchamp(vecteur.(0), /grid)
65   if grilleu EQ '' then grilleu = 'U'
66   grillev = litchamp(vecteur.(1), /grid)
67   if grillev EQ '' then grillev = 'V'
68
69   IF grilleu EQ 'V' AND grillev EQ 'U' THEN inverse = 1
70   IF grilleu EQ grillev THEN interpolle  = 0 ELSE interpolle = 1
71   if keyword_set(inverse) then begin
72      rien = u
73      u = v
74      v = rien
75   endif
76;------------------------------------------------------------
77; We find common points between u and v
78;------------------------------------------------------------
79   if interpolle then begin
80      indicexu = (lindgen(jpi))[firstxu:firstxu+nxu-1]
81      indicexv = (lindgen(jpi))[firstxv:firstxv+nxv-1]
82      indicex = inter(indicexu, indicexv)
83      indiceyu = (lindgen(jpj))[firstyu:firstyu+nyu-1]
84      indiceyv = (lindgen(jpj))[firstyv:firstyv+nyv-1]
85      indicey = inter(indiceyu, indiceyv)
86      nx = n_elements(indicex)
87      ny = n_elements(indicey)
88      indice2d = lindgen(jpi, jpj)
89      indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1]
90;------------------------------------------------------------
91; extraction of u and v on the appropriated domain
92;------------------------------------------------------------
93      case 1 of
94         (size(u))[0] NE 2 OR (size(v))[0] NE 2: return
95         (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $
96          (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN
97            if nxu NE nx then $
98             if indicex[0] EQ firstxu then u = u[0:nx-1, *] ELSE u = u[1: nx, *]
99            IF nxv NE nx THEN $
100             if indicex[0] EQ firstxv then v = v[0:nx-1, *] ELSE v = v[1: nx, *]
101            IF nyu NE ny THEN $
102             if indicey[0] EQ firstyu then u = u[*, 0:ny-1] ELSE u = u[*, 1: ny]
103            IF nyv NE ny THEN $
104             if indicey[0] EQ firstyv then v = v[*, 0:ny-1] ELSE v = v[*, 1: ny]
105         END
106         (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND $
107          (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN
108            u = u[indice2d]
109            v = v[indice2d]
110         END
111         ELSE:BEGIN
112            ras = report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs')
113            return
114         end
115      endcase
116;------------------------------------------------------------------
117; We reshape u and v to make sure that none dimension has been erased.
118;------------------------------------------------------------------
119      if ny EQ 1 then begin
120         u = reform(u, nx, ny)
121         v = reform(v, nx, ny)
122      endif
123;------------------------------------------------------------------
124; construction of u and v at points T
125;-----------------------------------------------------------
126      a=u[0,*]
127      u=(u+shift(u,1,0))/2.
128      if NOT keyword_set(key_periodic) OR nx NE jpi then u[0,*]=a
129      a=v[*,0]
130      v=(v+shift(v,0,1))/2.
131      if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0]=a
132;----------------------------------------------------------------------------
133; attribution of the mask and of longitude and latitude arrays.
134; We recuperate the complete grid to establish a big mask extensive
135; in the four directions to cover points for which a land point has
136; been considerated (do a small drawing)
137;----------------------------------------------------------------------------
138      vargrid='T'
139      msku = (umask())[indice2d+jpi*jpj*firstzt]
140      mskv = (vmask())[indice2d+jpi*jpj*firstzt]
141      glam = glamt[indice2d]
142      gphi = gphit[indice2d]
143      if ny EQ 1 then begin
144         msku = reform(msku, nx, ny)
145         mskv = reform(mskv, nx, ny)
146;          glam = reform(glam, nx, ny)
147;          gphi = reform(gphi, nx, ny)
148      endif
149;-----------------------------------------------------------
150; We mask u and v the long of coasts (the place where we
151; can not calculate the average)
152;-----------------------------------------------------------
153; extension of the mask
154      u = u*msku*shift(msku,1,0)
155      v = v*mskv*shift(mskv,0,1)
156   ENDIF ELSE BEGIN
157      u = u*tmask[firstxt:lastxt,firstyt:lastyt,firstzt]
158      v = v*tmask[firstxt:lastxt,firstyt:lastyt,firstzt]
159      indice2d = lindgen(jpi, jpj)
160      indice2d = indice2d[firstxt:lastxt, firstyt:lastyt]
161      nx = nxt
162      ny = nyt
163   endelse
164   tabnorme=sqrt(u^2+v^2)
165   nan = where(finite(u, /nan) EQ 1)
166   if nan[0] NE -1 then u[nan] = 1e5
167   nan = where(finite(v, /nan) EQ 1)
168   if nan[0] NE -1 then v[nan] = 1e5
169   if keyword_set(vectmin) then BEGIN
170      toosmall=where(tabnorme lt vectmin)
171      if toosmall[0] NE -1 then begin
172         u[toosmall] = 1e5
173         v[toosmall] = 1e5
174      ENDIF
175   endif
176   if keyword_set(vectmax) then BEGIN
177      toobig=where(tabnorme gt vectmax)
178      if toobig[0] NE -1 then begin
179         u[toobig] = 1e5
180         v[toobig] = 1e5
181      ENDIF
182   ENDIF
183;-----------------------------------------------------------
184; Put back of a big value on all points for which we can do the calculation.
185;-----------------------------------------------------------
186   if interpolle then t2 = msku*shift(msku,1,0)*mskv*shift(mskv,0,1) $
187   ELSE t2 = tmask[firstxt:lastxt,firstyt:lastyt,firstzt]
188   if NOT keyword_set(key_periodic) OR nx NE jpi then t2[0, *]=0.
189   t2[*,0]=0.
190   terre=where(t2 eq 0)
191   if terre[0] ne -1 then begin
192      u[terre]=1e5
193      v[terre]=1e5
194   ENDIF
195;-----------------------------------------------------------
196; trace only one vector one two
197;-----------------------------------------------------------
198   if keyword_set(unvectsur) then BEGIN ;
199; indx is a vector containing number of columns to be selected.
200; indy is a vector containing number of lines to be selected.
201      if n_elements(unvectsur) EQ 1 then begin
202         indx = where((lindgen(nx) MOD unvectsur[0]) eq 0)
203         indy = where((lindgen(ny) MOD unvectsur[0]) eq 0)
204      ENDIF ELSE BEGIN
205         indx = where((lindgen(nx) MOD unvectsur[0]) eq 0)
206         indy = where((lindgen(ny) MOD unvectsur[1]) eq 0)
207     ENDELSE
208; From indx and indy, we will construct an array which will give indexes
209; of intersections points of columns specified by indx.
210      indicereduit = indx#replicate(1,n_elements(indy))+nx*replicate(1,n_elements(indx))#indy
211; We reduce arrays which will be passed to vecteur.
212      u = u[indicereduit]
213      v = v[indicereduit]
214      tabnorme = tabnorme[indicereduit]
215      t2 = t2[indicereduit]
216;
217   endif
218;-----------------------------------------------------------
219;
220;-----------------------------------------------------------
221   if keyword_set(inverse) then begin
222      rien = u
223      u = v
224      v = rien
225   endif
226;-----------------------------------------------------------
227; Drawing of vectors.
228;----------------------------------------------------------
229   vecteur, u, v, tabnorme, indice2d, indicereduit, missing=1e5, _extra = ex
230;-----------------------------------------------------------
231; We complete the caption.
232;-----------------------------------------------------------
233   if terre[0] ne -1 then mini = min(tabnorme[where(t2 eq 1)], max = maxi, /nan) $
234   ELSE mini = min(tabnorme, max = maxi, /nan)
235
236   if litchamp(vecteur.(0), /u) NE '' then $
237    vectlegende = {minmax:[mini, maxi], unite:litchamp(vecteur.(0), /u)} $
238   ELSE vectlegende = {minmax:[mini, maxi], unite:varunit}
239
240
241sortie:
242   if keyword_set(key_performance) NE 0 THEN print, 'temps ajoutvect', systime(1)-tempsun
243   return
244end
Note: See TracBrowser for help on using the repository browser.