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

Last change on this file since 134 was 134, checked in by navarro, 18 years ago

change *.pro file properties (del eof-style, del executable, set keywords Id

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.6 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:ajoutvect
6;
7; PURPOSE:surimprimme des vecteur sur un champ tarce par plt
8;
9; CATEGORY:grafique
10;
11; CALLING SEQUENCE:ajoutvect,vecteur
12;
13; INPUTS:
14;       vecteur: une structure a 2 elements contenant les 2 matrices U
15;       et V des valeurs de la composante zonale et meridienne 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;
45; EXAMPLE:
46;
47; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr)
48;                       10/3/1999
49;                       11/6/1999 compatibilite avec NAN et la lecture
50;                       des structures.
51;-
52;------------------------------------------------------------
53;------------------------------------------------------------
54;------------------------------------------------------------
55pro ajoutvect,vecteur, vectlegende, UNVECTSUR=unvectsur,VECTMIN=vectmin, VECTMAX=vectmax, _EXTRA = ex
56;
57  compile_opt idl2, strictarrsubs
58;
59@common
60   tempsun = systime(1)         ; pour key_performance
61;----------------------------------------------------------------------------
62;
63   u = litchamp(vecteur.(0))
64   u = checkfield(u, 'plt', TYPE = 'xy', /NOQUESTION)
65   v = litchamp(vecteur.(1))
66   v = checkfield(v, 'plt', TYPE = 'xy', /NOQUESTION)
67;-----------------------------------------------------------
68;------------------------------------------------------------
69; on recupere les eventuelles info sur les champs
70;------------------------------------------------------------
71   grilleu = litchamp(vecteur.(0), /grid)
72   if grilleu EQ '' then grilleu = 'U'
73   grillev = litchamp(vecteur.(1), /grid)
74   if grillev EQ '' then grillev = 'V'
75
76   IF grilleu EQ 'V' AND grillev EQ 'U' THEN inverse = 1
77   IF grilleu EQ grillev THEN interpolle  = 0 ELSE interpolle = 1
78   if keyword_set(inverse) then begin
79      rien = u
80      u = v
81      v = rien
82   endif
83;------------------------------------------------------------
84; on trouve les points que u et v ont en communs
85;------------------------------------------------------------
86   if interpolle then begin
87      indicexu = (lindgen(jpi))[firstxu:firstxu+nxu-1]
88      indicexv = (lindgen(jpi))[firstxv:firstxv+nxv-1]
89      indicex = inter(indicexu, indicexv)
90      indiceyu = (lindgen(jpj))[firstyu:firstyu+nyu-1]
91      indiceyv = (lindgen(jpj))[firstyv:firstyv+nyv-1]
92      indicey = inter(indiceyu, indiceyv)
93      nx = n_elements(indicex)
94      ny = n_elements(indicey)
95      indice2d = lindgen(jpi, jpj)
96      indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1]
97;------------------------------------------------------------
98; extraction de u et v sur le domaine qui convient
99;------------------------------------------------------------
100      case 1 of
101         (size(u))[0] NE 2 OR (size(v))[0] NE 2: return
102         (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $
103          (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN
104            if nxu NE nx then $
105             if indicex[0] EQ firstxu then u = u[0:nx-1, *] ELSE u = u[1: nx, *]
106            IF nxv NE nx THEN $
107             if indicex[0] EQ firstxv then v = v[0:nx-1, *] ELSE v = v[1: nx, *]
108            IF nyu NE ny THEN $
109             if indicey[0] EQ firstyu then u = u[*, 0:ny-1] ELSE u = u[*, 1: ny]
110            IF nyv NE ny THEN $
111             if indicey[0] EQ firstyv then v = v[*, 0:ny-1] ELSE v = v[*, 1: ny]
112         END
113         (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND $
114          (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN
115            u = u[indice2d]
116            v = v[indice2d]
117         END
118         ELSE:BEGIN
119            ras = report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs')
120            return
121         end
122      endcase
123;------------------------------------------------------------------
124; on reform u et v pour s'assurer qu'aucune dimension n'a ete ecrasee
125;------------------------------------------------------------------
126      if ny EQ 1 then begin
127         u = reform(u, nx, ny)
128         v = reform(v, nx, ny)
129      endif
130;------------------------------------------------------------------
131; construction de u et v aux pts T
132;-----------------------------------------------------------
133      a=u[0,*]
134      u=(u+shift(u,1,0))/2.
135      if NOT keyword_set(key_periodic) OR nx NE jpi then u[0,*]=a
136      a=v[*,0]
137      v=(v+shift(v,0,1))/2.
138      if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0]=a
139;----------------------------------------------------------------------------
140; attribution du mask et des tableau de longitude et latitude
141; on recupere la grille complette pour etablir un grand mask etendu ds les 4
142; directions pour couvrir les points pour lesquels un pt terre a ete pris en
143; compte (faire un petit dessin...)
144;----------------------------------------------------------------------------
145      vargrid='T'
146      msku = (umask())[indice2d+jpi*jpj*firstzt]
147      mskv = (vmask())[indice2d+jpi*jpj*firstzt]
148      glam = glamt[indice2d]
149      gphi = gphit[indice2d]
150      if ny EQ 1 then begin
151         msku = reform(msku, nx, ny)
152         mskv = reform(mskv, nx, ny)
153;          glam = reform(glam, nx, ny)
154;          gphi = reform(gphi, nx, ny)
155      endif
156;-----------------------------------------------------------
157; on masque u et v le long des cotes (la on l''on ne peut pas calculer
158; la moyenne)
159;-----------------------------------------------------------
160; extention du mask
161      u = u*msku*shift(msku,1,0)
162      v = v*mskv*shift(mskv,0,1)
163   ENDIF ELSE BEGIN
164      u = u*tmask[firstxt:lastxt,firstyt:lastyt,firstzt]
165      v = v*tmask[firstxt:lastxt,firstyt:lastyt,firstzt]
166      indice2d = lindgen(jpi, jpj)
167      indice2d = indice2d[firstxt:lastxt, firstyt:lastyt]
168      nx = nxt
169      ny = nyt
170   endelse
171   tabnorme=sqrt(u^2+v^2)
172   nan = where(finite(u, /nan) EQ 1)
173   if nan[0] NE -1 then u[nan] = 1e5
174   nan = where(finite(v, /nan) EQ 1)
175   if nan[0] NE -1 then v[nan] = 1e5
176   if keyword_set(vectmin) then BEGIN
177      toosmall=where(tabnorme lt vectmin)
178      if toosmall[0] NE -1 then begin
179         u[toosmall] = 1e5
180         v[toosmall] = 1e5
181      ENDIF
182   endif
183   if keyword_set(vectmax) then BEGIN
184      toobig=where(tabnorme gt vectmax)
185      if toobig[0] NE -1 then begin
186         u[toobig] = 1e5
187         v[toobig] = 1e5
188      ENDIF
189   ENDIF
190;-----------------------------------------------------------
191; remise d''une grande valeur sur tous les points pour lesquelles on ne
192; put faire le calcul
193;-----------------------------------------------------------
194   if interpolle then t2 = msku*shift(msku,1,0)*mskv*shift(mskv,0,1) $
195   ELSE t2 = tmask[firstxt:lastxt,firstyt:lastyt,firstzt]
196   if NOT keyword_set(key_periodic) OR nx NE jpi then t2[0, *]=0.
197   t2[*,0]=0.
198   terre=where(t2 eq 0)
199   if terre[0] ne -1 then begin
200      u[terre]=1e5
201      v[terre]=1e5
202   ENDIF
203;-----------------------------------------------------------
204; tracer qu'un vecteur sur
205;-----------------------------------------------------------
206   if keyword_set(unvectsur) then BEGIN ;
207; indx est un vecteur contenant les numero des colonnes a selectionner
208; indy est un vecteur contenant les numero des lignes a selectionner
209      if n_elements(unvectsur) EQ 1 then begin
210         indx = where((lindgen(nx) MOD unvectsur[0]) eq 0)
211         indy = where((lindgen(ny) MOD unvectsur[0]) eq 0)
212      ENDIF ELSE BEGIN
213         indx = where((lindgen(nx) MOD unvectsur[0]) eq 0)
214         indy = where((lindgen(ny) MOD unvectsur[1]) eq 0)
215      ENDELSE
216; a partir de indx et indy on va construire un tableau d''indices 2d
217; qui donnera les indices des points intersections des colonnes
218; specifiee par indx
219      indicereduit = indx#replicate(1,n_elements(indy))+nx*replicate(1,n_elements(indx))#indy
220; on reduit les tableaux qui vont etre passes a vecteur.
221      u = u[indicereduit]
222      v = v[indicereduit]
223      tabnorme = tabnorme[indicereduit]
224;
225   endif
226;-----------------------------------------------------------
227;
228;-----------------------------------------------------------
229   if keyword_set(inverse) then begin
230      rien = u
231      u = v
232      v = rien
233   endif
234;-----------------------------------------------------------
235; trace des vecteurs
236;----------------------------------------------------------
237   vecteur, u, v, tabnorme, indice2d, indicereduit, missing=1e5, _extra = ex
238;-----------------------------------------------------------
239; on complete la legende
240;-----------------------------------------------------------
241   if terre[0] ne -1 then mini = min(tabnorme[where(t2 eq 1)], max = maxi, /nan) $
242   ELSE mini = min(tabnorme, max = maxi, /nan)
243   
244   if litchamp(vecteur.(0), /u) NE '' then $
245    vectlegende = {minmax:[mini, maxi], unite:litchamp(vecteur.(0), /u)} $
246   ELSE vectlegende = {minmax:[mini, maxi], unite:varunit}
247
248
249sortie:
250   if keyword_set(key_performance) NE 0 THEN print, 'temps ajoutvect', systime(1)-tempsun
251   return
252end
253
254
Note: See TracBrowser for help on using the repository browser.