source: trunk/procs/ajoutvectz.pro @ 203

Last change on this file since 203 was 203, checked in by pinsard, 14 years ago

remove trailing blanks

  • Property svn:keywords set to Id
File size: 8.6 KB
Line 
1;+
2;
3; surimprimme des vecteur sur un champ trace par <pro>pltz</pro>
4;
5; @categories
6; Graphics
7;
8; @param VECTEUR {in}{required}{type=structure}
9; une structure a 2 elements contenant les 2 matrices U
10;       et V des valeurs de la composante horizontale et verticale du
11;       champ de vecteurs a tracer.
12;
13;       par ex:
14;       vecteur={matriceu:lec('unsurface'),matricev:lec('vnsurface')}
15;       rq:le nom des elements de vecteur n''a aucune importance.
16;       vecteur={u:lec('unsurface'),v:lec('vnsurface')} convient aussi
17;
18; @keyword UNVECTSUR
19; un scalaire n ou un tableau a 2 elements [n1,n2].
20;
21; Dans le premier cas, on tracera un vecteur sur n suivant les
22; x et les y.
23; Dans le second cas on tracera un vecteur sur n1 suivant x
24; et un vecteur sur n2 suivant y
25;
26; Rq: pour tracer tous les vecteurs suivant y et 1 sur 2 suivant
27; x mettre unvectsur=[2,1]
28;
29; @keyword VECTMIN
30; norme minimun des vecteurs a tracer
31;
32; @keyword VECTMAX
33; norme minimun des vecteurs a tracer
34;
35; @keyword VECTMIN
36;
37; @keyword VECTMAX
38;
39; @keyword _EXTRA
40;
41; @keyword TYPE
42;
43; @examples
44;
45; IDL> vecteur={matriceu:lec('unsurface'),matricev:lec('vnsurface')}
46; IDL> ajoutvectz, vecteur, $
47;    , UNVECTSUR=unvectsur $
48;    , VECTMIN=vectmin $
49;    , VECTMAX=vectmax $
50;    , _EXTRA=extra $
51;    , TYPE = type $
52;    , BOITE = boite
53;
54; @uses
55; <pro>common<pro>
56; <pro>litchamp<pro>
57;
58; @todo
59;
60; fix pb in param vecteur description with idldoc. It seems that {...}
61; have side effects
62;
63; in example current pb with lec('vnsurface')
64;
65; IDL> vecteur={matriceu:lec('unsurface'),matricev:lec('vnsurface')}
66; % L.145 /usr/lodyc/incas/fplod/SAXO_DIR_ws/SRC/Obsolete/lec.pro rev. 378:
67; % le nom du champ doit commencer par VO ou SO
68;
69; @history
70; - fplod 20091209T094630Z aedon.locean-ipsl.upmc.fr (Darwin)
71;
72;   * check parameters
73;   * remove vectlegend parameter (unused)
74;
75; - Eric Guilyardi (ericg\@lodyc.jussieu.fr) Sebastien Masson (smassom\@lodyc.jussieu.fr)
76;
77;   * 26/9/00 (on board R/V Marion Dufresne)
78;
79; @version
80; $Id$
81;
82;-
83PRO ajoutvectz, vecteur $
84    , UNVECTSUR=unvectsur $
85    , VECTMIN=vectmin $
86    , VECTMAX=vectmax $
87    , _EXTRA=extra $
88    , TYPE = type $
89    , BOITE = boite
90;
91  compile_opt idl2, strictarrsubs
92;
93@common
94;
95  tempsun = systime(1)         ; pour key_performance
96;
97; Return to caller if errors
98 ON_ERROR, 2
99;
100 usage='ajoutvectz, vecteur ' $
101    + ', UNVECTSUR=unvectsur' $
102    + ', VECTMIN=vectmin' $
103    + ', VECTMAX=vectmax' $
104    + ', _EXTRA=extra' $
105    + ', TYPE = type' $
106    + ', BOITE = boite'
107;
108 nparam = N_PARAMS()
109 IF (nparam LT 2) THEN BEGIN
110    ras = report(['Incorrect number of arguments.' $
111          + '!C' $
112          + 'Usage : ' + usage])
113    stop
114 ENDIF
115 arg_type = size(vecteur,/type)
116 IF (arg_type NE 8) THEN BEGIN
117   ras = report(['Incorrect arg type vecteur' $
118          + '!C' $
119          + 'Usage : ' + usage])
120    stop
121 ENDIF
122
123
124;----------------------------------------------------------------------------
125;
126   u = litchamp(vecteur.(0))
127   grilleu = litchamp(vecteur.(0), /grid)
128   vargrid = grilleu
129   boitesave = boite
130   u = checkfield(u, 'pltz', TYPE = type, BOITE = boite, /NOQUESTION, /VECTEUR)
131   boite = boitesave
132
133   w = litchamp(vecteur.(1))
134   grillew = litchamp(vecteur.(1), /grid)
135   vargrid = grillew
136   w = checkfield(w, 'pltz', TYPE = type, BOITE = boite, /NOQUESTION, /VECTEUR)
137
138;------------------------------------------------------------
139; on recupere les eventuelles info sur les champs
140;------------------------------------------------------------
141   CASE type OF
142      'yz': IF grilleu EQ '' then grilleu = 'V'
143      'xz': IF grilleu EQ '' then grilleu = 'U'
144      ELSE: IF grilleu EQ '' then grilleu = 'V'
145   ENDCASE
146   IF grillew EQ '' then grillew = 'W'
147
148   IF grilleu EQ 'T' AND grillew EQ 'T' THEN interpolle = 0 ELSE interpolle = 1
149
150;------------------------------------------------------------
151; on trouve les points que u et v ont en communs
152;------------------------------------------------------------
153   if interpolle then begin
154      CASE type OF
155         'yz': indicehx = (lindgen(jpj))[firstyv:firstyv+nyv-1]
156         'xz': indicehx = (lindgen(jpi))[firstxu:firstxu+nxu-1]
157      ENDCASE
158      CASE type OF
159         'yz': indicehw = (lindgen(jpj))[firstyt:firstyt+nyt-1]
160         'xz': indicehw = (lindgen(jpi))[firstxt:firstxt+nxt-1]
161      ENDCASE
162
163      indicex = inter(indicehx, indicehw)
164
165      indicezh = (lindgen(jpk))[firstzt:firstzt+nzt-1]
166      indicezw = (lindgen(jpk))[firstzw:firstzw+nzw-1]
167
168      indicez = inter(indicezh, indicezw)
169
170      nx = n_elements(indicex)
171      nz = n_elements(indicez)
172
173      CASE type OF
174      'yz': BEGIN & nxh = nyv & firsth = firstyv & END
175      'xz': BEGIN & nxh = nxu & firsth = firstxu & END
176      ENDCASE
177
178;------------------------------------------------------------
179; extraction de u et v sur le domaine qui convient
180;------------------------------------------------------------
181      if nxh NE nx then $
182       if indicex[0] EQ firsth then u = u[0:nx-1, *] ELSE u = u[1: nx, *]
183      IF nxt NE nx THEN $
184       if indicex[0] EQ firstxt then w = w[0:nx-1, *] ELSE w = w[1: nx, *]
185      IF nzt NE nz THEN $
186       if indicez[0] EQ firstzt then u = u[*, 0:nz-1] ELSE u = u[*, 1: nz]
187      IF nzw NE nz THEN $
188       if indicez[0] EQ firstzw then w = w[*, 0:nz-1] ELSE w = w[*, 1: nz]
189;------------------------------------------------------------------
190; on reform u et w pour s'assurer qu'aucune dimension n'a ete ecrasee
191;------------------------------------------------------------------
192      if nz EQ 1 then begin
193         u = reform(u, nx, nz)
194         w = reform(w, nx, nz)
195      endif
196;------------------------------------------------------------------
197; construction de u et w aux pts T
198;-----------------------------------------------------------
199
200      terre = where(u GE valmask/10.)
201      IF terre[0] NE -1 THEN u[terre] = !VALUES.F_NAN
202      terre = where(w GE valmask/10.)
203      IF terre[0] NE -1 THEN w[terre] = !VALUES.F_NAN
204
205      a=u[0,*]
206      u=(u+shift(u,1,0))/2.
207      u[0,*]=a
208
209      a=w[*,0]
210      w=(w+shift(w,0,1))/2.
211      w[*,0] = a
212
213      vargrid='T'
214
215   ENDIF
216;-----------------------------------------------------------
217; tracer qu'un vecteur sur
218;-----------------------------------------------------------
219   if keyword_set(unvectsur) then BEGIN ;
220; indx est un vecteur contenant les numero des colonnes a selectionner
221; indz est un vecteur contenant les numero des lignes a selectionner
222      if n_elements(unvectsur) EQ 1 then begin
223         indx = where((lindgen(nx) MOD unvectsur[0]) eq 0)
224         indz = where((lindgen(nz) MOD unvectsur[0]) eq 0)
225      ENDIF ELSE BEGIN
226         indx = where((lindgen(nx) MOD unvectsur[0]) eq 0)
227         indz = where((lindgen(nz) MOD unvectsur[1]) eq 0)
228      ENDELSE
229; a partir de indx et indz on va construire un tableau d''indices 2d
230; qui donnera les indices des points intersections des colonnes
231; specifiee par indx
232      indicereduit = indx#replicate(1,n_elements(indz))+nx*replicate(1,n_elements(indx))#indz
233; on reduit les tableaux qui vont etre passes a vecteur.
234      u = u[indicereduit]
235      w = w[indicereduit]
236;
237   endif
238;-----------------------------------------------------------
239; trace des vecteurs
240;----------------------------------------------------------
241
242   CASE type OF
243      'yz': xgrid = gphit[(firstxt+lastxt)/2, indicex[0]:indicex[nx-1]]
244      'xz': xgrid = glamt[indicex[0]:indicex[nx-1], (firstyt+lastyt)/2]
245   ENDCASE
246
247   x0 = xgrid[*]#replicate(1, nz)
248   y0 = replicate(1, nx)#gdept[indicez[0]:indicez[nz-1]]
249
250
251;   print, !x.range, !y.range
252;   print, '  Min/Max Hvect', min(u(where (u LE valmask/10.))), max(u(where (u LE valmask/10.)))
253;   print, '  Min/Max Zvect', min(w(where (w LE valmask/10.))), max(w(where (w LE valmask/10.)))
254
255   norme = sqrt(max(u(where (u LE valmask/10.)))^2+max(w(where (w LE valmask/10.)))^2)
256
257;   modif du rapport d'aspect
258
259   deltax = (!p.position[2]-!p.position[0])
260   deltaz = (!p.position[3]-!p.position[1])
261   rph = petitfeuille/grandfeuille*(  key_portrait)+1.*(1-key_portrait)
262   rpz = grandfeuille/petitfeuille*(1-key_portrait)+key_portrait
263
264   CASE !d.name OF
265      'PS': scale = grandfeuille*deltax/(ABS(!x.range[1]-!x.range[0]))*.4
266      ELSE: scale = grandfeuille*deltax/(ABS(!x.range[1]-!x.range[0]))*.4
267   ENDCASE
268
269
270;   print, ABS(!x.range[1]-!x.range[0]), ABS(!y.range[1]-!y.range[0])
271;   print, deltax, deltaz
272;   print, scale
273
274   x1 = x0+u*rph*ABS(!x.range[1]-!x.range[0])/deltax*scale
275   y1 = y0-w*rpz*ABS(!y.range[1]-!y.range[0])/deltaz*scale
276
277   arrow, x0, y0, x1, y1, /data, thick = 1.5, hthick = 1.5, hsize = !D.X_SIZE / 400
278;hsize = !D.X_SIZE / 500 or -0.4
279
280
281sortie:
282   if keyword_set(key_performance) NE 0 THEN print, 'temps ajoutvectz', systime(1)-tempsun
283end
284
285
Note: See TracBrowser for help on using the repository browser.