source: trunk/procs/ajoutvectz.pro @ 12

Last change on this file since 12 was 2, checked in by post_it, 17 years ago

Initial import from ~/POST_IT/

File size: 7.6 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:ajoutvectz
6;
7; PURPOSE:surimprimme des vecteur sur un champ tarce par pltz
8;
9; CATEGORY:grafique
10;
11; CALLING SEQUENCE:ajoutvectz,vecteur
12;
13; INPUTS:
14;       vecteur: une structure a 2 elements contenant les 2 matrices U
15;       et V des valeurs de la composante horizontale et verticale du
16;       champ de vecteurs a tracer.
17;       par ex:
18;       vecteur={matriceu:lec('unsurface'),matricev:lec('vnsurface')}
19;       rq:le nom des elements de vecteur n''a aucune importance.
20;       vecteur={u:lec('unsurface'),v:lec('vnsurface')} convient aussi
21;
22; KEYWORD PARAMETERS:
23;
24;       /UNVECTSUR:un scalaire n on un tableau a 2 elements [n1,n2].
25;         dans le premier cas, on tracera un vecteur sur n suivant les
26;         x et les y.
27;         dans le second cas on tracera un vecteur sur n1 suivant x
28;         et un vecteur sur n2 suivant y
29;       Rq; pour tracer tous les vecteurs suivant y et 1 sur 2 suivant
30;       x mettre unvectsur=[2,1]
31;
32;       VECTMIN=norme minimun des vecteurs a tracer
33;
34;       VECTMAX=norme minimun des vecteurs a tracer
35;
36; OUTPUTS:
37;
38; COMMON BLOCKS:
39;       common.pro             
40;
41; SIDE EFFECTS:
42;
43; RESTRICTIONS:
44;; EXAMPLE:
45;
46; MODIFICATION HISTORY: Eric Guilyardi (ericg@lodyc.jussieu.fr)
47;                       Sebastien Masson (smassom@lodyc.jussieu.fr)
48;                       26/9/00 (on board R/V Marion Dufresne)
49;-
50;------------------------------------------------------------
51;------------------------------------------------------------
52;------------------------------------------------------------
53pro ajoutvectz,vecteur, vectlegende, UNVECTSUR=unvectsur,VECTMIN=vectmin, VECTMAX=vectmax, _EXTRA = ex, TYPE = type, BOITE = boite
54@common
55   tempsun = systime(1)         ; pour key_performance
56;----------------------------------------------------------------------------
57;
58   u = litchamp(vecteur.(0))
59   grilleu = litchamp(vecteur.(0), /grid)
60   vargrid = grilleu
61   boitesave = boite
62   u = checkfield(u, 'pltz', TYPE = type, BOITE = boite, /NOQUESTION, /VECTEUR)
63   boite = boitesave
64
65   w = litchamp(vecteur.(1))
66   grillew = litchamp(vecteur.(1), /grid)
67   vargrid = grillew
68   w = checkfield(w, 'pltz', TYPE = type, BOITE = boite, /NOQUESTION, /VECTEUR)
69
70;------------------------------------------------------------
71; on recupere les eventuelles info sur les champs
72;------------------------------------------------------------
73   CASE type OF
74      'yz': IF grilleu EQ '' then grilleu = 'V'
75      'xz': IF grilleu EQ '' then grilleu = 'U'
76      ELSE: IF grilleu EQ '' then grilleu = 'V'
77   ENDCASE
78   IF grillew EQ '' then grillew = 'W'
79   
80   IF grilleu EQ 'T' AND grillew EQ 'T' THEN interpolle  = 0 ELSE interpolle = 1
81
82;------------------------------------------------------------
83; on trouve les points que u et v ont en communs
84;------------------------------------------------------------
85   if interpolle then begin
86      CASE type OF
87         'yz': indicehx = (lindgen(jpj))[firstyv:firstyv+nyv-1]
88         'xz': indicehx = (lindgen(jpi))[firstxu:firstxu+nxu-1]
89      ENDCASE
90      CASE type OF
91         'yz': indicehw = (lindgen(jpj))[firstyt:firstyt+nyt-1]
92         'xz': indicehw = (lindgen(jpi))[firstxt:firstxt+nxt-1]
93      ENDCASE
94
95      indicex = inter(indicehx, indicehw)
96
97      indicezh = (lindgen(jpk))[firstzt:firstzt+nzt-1]
98      indicezw = (lindgen(jpk))[firstzw:firstzw+nzw-1]
99
100      indicez = inter(indicezh, indicezw)
101
102      nx = n_elements(indicex)
103      nz = n_elements(indicez)
104
105      CASE type OF
106      'yz': BEGIN & nxh = nyv & firsth = firstyv & END
107      'xz': BEGIN & nxh = nxu & firsth = firstxu & END
108      ENDCASE
109
110;------------------------------------------------------------
111; extraction de u et v sur le domaine qui convient
112;------------------------------------------------------------
113      if nxh NE nx then $
114       if indicex[0] EQ firsth then u = u[0:nx-1, *] ELSE u = u[1: nx, *]
115      IF nxt NE nx THEN $
116       if indicex[0] EQ firstxt then w = w[0:nx-1, *] ELSE w = w[1: nx, *]
117      IF nzt NE nz THEN $
118       if indicez[0] EQ firstzt then u = u[*, 0:nz-1] ELSE u = u[*, 1: nz]
119      IF nzw NE nz THEN $
120       if indicez[0] EQ firstzw then w = w[*, 0:nz-1] ELSE w = w[*, 1: nz]
121;------------------------------------------------------------------
122; on reform u et w pour s'assurer qu'aucune dimension n'a ete ecrasee
123;------------------------------------------------------------------
124      if nz EQ 1 then begin
125         u = reform(u, nx, nz)
126         w = reform(w, nx, nz)
127      endif
128;------------------------------------------------------------------
129; construction de u et w aux pts T
130;-----------------------------------------------------------
131
132      terre = where(u GE valmask/10.)
133      IF terre[0] NE -1 THEN u(terre) = !VALUES.F_NAN
134      terre = where(w GE valmask/10.)
135      IF terre[0] NE -1 THEN w(terre) = !VALUES.F_NAN
136
137      a=u(0,*)
138      u=(u+shift(u,1,0))/2.
139      u(0,*)=a
140
141      a=w(*,0)
142      w=(w+shift(w,0,1))/2.
143      w(*,0) = a
144
145      vargrid='T'
146
147   ENDIF
148;-----------------------------------------------------------
149; tracer qu'un vecteur sur
150;-----------------------------------------------------------
151   if keyword_set(unvectsur) then BEGIN ;
152; indx est un vecteur contenant les numero des colonnes a selectionner
153; indz est un vecteur contenant les numero des lignes a selectionner
154      if n_elements(unvectsur) EQ 1 then begin
155         indx = where((lindgen(nx) MOD unvectsur[0]) eq 0)
156         indz = where((lindgen(nz) MOD unvectsur[0]) eq 0)
157      ENDIF ELSE BEGIN
158         indx = where((lindgen(nx) MOD unvectsur[0]) eq 0)
159         indz = where((lindgen(nz) MOD unvectsur[1]) eq 0)
160      ENDELSE
161; a partir de indx et indz on va construire un tableau d''indices 2d
162; qui donnera les indices des points intersections des colonnes
163; specifiee par indx
164      indicereduit = indx#replicate(1,n_elements(indz))+nx*replicate(1,n_elements(indx))#indz
165; on reduit les tableaux qui vont etre passes a vecteur.
166      u = u[indicereduit]
167      w = w[indicereduit]
168;
169   endif
170;-----------------------------------------------------------
171; trace des vecteurs
172;----------------------------------------------------------
173
174   CASE type OF
175      'yz': xgrid = gphit((firstxt+lastxt)/2, indicex[0]:indicex[nx-1])
176      'xz': xgrid = glamt(indicex[0]:indicex[nx-1], (firstyt+lastyt)/2)
177   ENDCASE
178
179   x0 = xgrid[*]#replicate(1, nz)
180   y0 = replicate(1, nx)#gdept(indicez[0]:indicez[nz-1])
181
182
183;   print, !x.range, !y.range
184;   print, '  Min/Max Hvect', min(u(where (u LE valmask/10.))), max(u(where (u LE valmask/10.)))
185;   print, '  Min/Max Zvect', min(w(where (w LE valmask/10.))), max(w(where (w LE valmask/10.)))
186
187   norme = sqrt(max(u(where (u LE valmask/10.)))^2+max(w(where (w LE valmask/10.)))^2)
188
189;   modif du rapport d'aspect
190
191   deltax = (!p.position[2]-!p.position[0])
192   deltaz = (!p.position[3]-!p.position[1])
193   rph = petitfeuille/grandfeuille*(  key_portrait)+1.*(1-key_portrait)
194   rpz = grandfeuille/petitfeuille*(1-key_portrait)+key_portrait
195
196   CASE !d.name OF
197      'PS': scale = grandfeuille*deltax/(ABS(!x.range[1]-!x.range[0]))*.4
198      ELSE: scale = grandfeuille*deltax/(ABS(!x.range[1]-!x.range[0]))*.4
199   ENDCASE
200   
201
202;   print, ABS(!x.range[1]-!x.range[0]), ABS(!y.range[1]-!y.range[0])
203;   print, deltax, deltaz
204;   print, scale
205
206   x1 = x0+u*rph*ABS(!x.range[1]-!x.range[0])/deltax*scale
207   y1 = y0-w*rpz*ABS(!y.range[1]-!y.range[0])/deltaz*scale
208
209   arrow, x0, y0, x1, y1, /data, thick = 1.5, hthick = 1.5, hsize = !D.X_SIZE / 400
210;hsize = !D.X_SIZE / 500 or -0.4
211
212
213sortie:
214   if keyword_set(key_performance) NE 0 THEN print, 'temps ajoutvectz', systime(1)-tempsun
215   return
216end
217
218
Note: See TracBrowser for help on using the repository browser.