source: trunk/ToBeReviewed/PLOTS/legende.pro @ 42

Last change on this file since 42 was 42, checked in by pinsard, 18 years ago

upgrade of PLOTS according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 11.1 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:legende.pro
6;
7; PURPOSE:fournit les legendes
8;
9; CATEGORY:graph annexe
10;
11; CALLING SEQUENCE:legende, mi,ma,coupe,title,subtitle,xtitle,ytitle
12;
13; INPUTS:mi et ma: le max et le min du dessin (cf plt.pro et pltz.pro)
14;        coupe=caractere de 2 lettres donnant le type de coupe (par ex:'xz')
15;
16; KEYWORD PARAMETERS:
17;
18;       TITRE: chaine de caracteres qui doit etre le titre du dessin. Par
19; defaut le titre est le nom vairmer du champ
20;
21;       ENDPOINTS:utilise qd on fait des coupes veticales en diagonale
22;
23; OUTPUTS:le titre, sous-titre,titre de x et titre de y
24;
25; COMMON BLOCKS:
26;       common.pro
27;
28; SIDE EFFECTS: l''utilisation de la variable globale langage permet
29; de changer de langue ou de facon de legender facilement. On peut
30; facilement personnaliser la chose en rajoutant un cas au case sur la
31; valeur de langage.
32;
33; RESTRICTIONS:
34;
35; EXAMPLE:
36;
37; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr)
38;                       14/8/98
39;                       Eric Guilyardi (ericg@lodyc.jussieu.fr) GB version
40;                       11/6/99
41;-
42;------------------------------------------------------------
43;------------------------------------------------------------
44;------------------------------------------------------------
45pro legende,mi,ma,coupe,CONTOUR = contour,ENDPOINTS = endpoints, DIREC = direc $
46            , VECTLEGENDE = vectlegende $
47            , INTERVALLE = intervalle, TYPE_YZ = type_yz, VARNAME2 = varname2 $
48            , NPTS = npts, _EXTRA = ex
49@common
50   tempsun = systime(1)         ; pour key_performance
51;------------------------------------------------------------
52   grille, -1, -1, -1, gdep, nx, ny, nz
53;
54; English legends
55;
56   fmt_mm = '(f12.2)'
57   fmt_bt = '(f7.1)'
58   colorf = ''
59   contourf = 'Contour plot,'
60   vecteurf = 'Vector norm  '
61   expf = ''
62   datef = '   '
63   fieldf = '   '
64   depthf = '   '
65   endpointsf = 'Diag. Section'
66   zonalf = ''
67   IF key_onearth THEN latintf = 'latitudes in ' ELSE latintf = 'j index in '
68   timintf = 'time in '
69   onf = ' - '
70   depthf2 = 'Depth (m)'
71   Meridf = 'Zonal Mean  '
72   IF key_onearth THEN lonintf = 'longitudes in ' ELSE lonintf = 'i in '
73   hovxt = 'XT-plot   '
74   diaghovxt = 'Diag. XT-plot   '
75   depintf = 'depths in '
76   timef = 'Time'
77   hovyt = 'YT-plot   '
78   diaghovyt = 'Diag. YT-plot   '
79   hovzt = 'ZT-plot   '
80   hovt = ''
81   IF key_onearth THEN lontitle = 'Longitude' ELSE lontitle = 'i index'
82   IF key_onearth THEN lattitle = 'Latitude' ELSE lattitle = 'j index'
83   
84   vertz = depthf2
85   legniv = ' m'
86   IF keyword_set(TYPE_YZ) THEN BEGIN
87     IF type_yz EQ 'hPa' THEN vertz = 'hPa'
88     IF type_yz EQ 'hPa' THEN legniv = ' hPa'
89   ENDIF
90;
91; Start legende
92;
93;------------------------------------------------------------
94; definition et complement eventuelle de !p.subtitle
95;------------------------------------------------------------
96   if n_elements(varunit) ne 0 then unite='('+varunit+')' else unite=''
97   !p.subtitle=colorf+unite+': Min= '+strtrim(string(format=fmt_mm,mi), 2)$
98    +', Max= '+strtrim(string(format=fmt_mm,ma), 2)
99   if keyword_set(intervalle) then BEGIN
100      if intervalle NE -1 then $
101       !p.subtitle=!p.subtitle+', Int= '+strtrim(string(format=fmt_mm,intervalle), 2)
102   endif
103   if size(contour, /type) EQ 8 then BEGIN ; c''est une structure
104      unite='('+contour.(1)+')'
105      !p.subtitle=!p.subtitle+'!C '+contourf+unite $
106       +': Min= '+strtrim(string(format=fmt_mm,contour.(0)[0]), 2)$
107       +', Max= '+strtrim(string(format=fmt_mm,contour.(0)[1]), 2)
108      if contour.inter NE -1  then $
109       !p.subtitle=!p.subtitle+', Int= '+strtrim(string(format=fmt_mm,contour.inter), 2)
110   ENDIF
111   if size(vectlegende, /type) EQ 8  then begin
112      unite='('+vectlegende.(1)+')'
113      !p.subtitle=!p.subtitle+'!C '+vecteurf+unite $
114       +': Min= '+strtrim(string(format=fmt_mm,vectlegende.(0)[0]), 2)$
115       +', Max= '+strtrim(string(format=fmt_mm,vectlegende.(0)[1]), 2)
116   endif
117;------------------------------------------------------------
118; mise en forme des dimensions du sous domaine
119;------------------------------------------------------------
120   la1=strtrim(string(format=fmt_bt, lat1), 2)
121   la2=strtrim(string(format=fmt_bt, lat2), 2)
122   lo1=strtrim(string(format=fmt_bt, lon1), 2)
123   lo2=strtrim(string(format=fmt_bt, lon2), 2)
124   pr1=strtrim(string(format=fmt_bt, vert1), 2)
125   pr2=strtrim(string(format=fmt_bt, vert2), 2)
126;------------------------------------------------------------
127; gestion de la date
128;------------------------------------------------------------
129   if n_elements(vardate) EQ 0 then vardate = ''
130   if NOT keyword_set(direc) then direc = ''
131   if strpos(direc, 't') NE -1 then begin
132      svardate = strtrim(vairdate(time[0]), 1)+' - '+strtrim(vairdate(time[jpt-1]), 1)
133   ENDIF ELSE svardate = vardate
134;------------------------------------------------------------
135; case sur le cas auquel s''applique la legende
136;------------------------------------------------------------
137   case coupe of
138      'xy':begin         
139        if strupcase(vargrid) EQ 'W' then firstz = firstzw $
140        ELSE firstz = firstzt
141        if(strpos(direc, 'z') EQ -1 AND firstz NE 0) then BEGIN
142          prof = strtrim(round(gdep[0]), 1)
143          !p.title = expf+varexp+datef+svardate+fieldf+varname+depthf+prof+legniv
144        ENDIF ELSE !p.title = expf+varexp+datef+svardate+fieldf+varname
145        !x.title = lontitle
146        !y.title = lattitle
147      end
148
149      'xz':begin
150         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(ny, 1)
151         IF long(n) LE 3 THEN zonalf = 'Section   '
152         if keyword_set(endpoints) AND lat1 NE lat2 then $
153          !p.title = endpointsf+varexp+datef+svardate+fieldf+varname ELSE $
154          !p.title = zonalf+varexp+datef+svardate+fieldf+varname
155         !x.title = lontitle
156         if keyword_set(endpoints) AND lat1 EQ lat2 then BEGIN
157           IF key_onearth THEN !x.title = !x.title+' at '+strtrim(lataxe(0, 0, lat1), 1) ELSE !x.title = !x.title+' at j index '+strtrim(lat1, 1)
158         ENDIF
159         !y.title = depthf2
160      end
161
162      'yz':begin
163         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(nx, 1)
164         IF long(n) LE 3 THEN meridf = ''
165         if keyword_set(endpoints) AND lon1 NE lon2 then $
166          !p.title = endpointsf+varexp+datef+svardate+fieldf+varname ELSE $
167          !p.title = meridf+varexp+datef+svardate+fieldf+varname
168         !y.title = vertz
169         !x.title = lattitle
170         if keyword_set(endpoints) AND lon1 EQ lon2 then BEGIN
171           IF key_onearth THEN !x.title = !x.title+' at '+strtrim(lonaxe(0, 0, lon1), 1) ELSE !x.title = !x.title+' at i index '+strtrim(lon1, 1)
172         ENDIF
173      end
174
175      'xt':begin
176;         IF keyword_set(npts) THEN n = strtrim(npts, 1)
177         if keyword_set(endpoints) AND lat1 NE lat2 then $
178          !p.title = diaghovxt+varexp+fieldf+varname ELSE $
179         !p.title  =     hovxt+varexp+fieldf+varname
180         IF (time[(size(time))[0]-1] - time[0]) GE 10 THEN !y.title = timef
181         !x.title = lontitle
182         if keyword_set(endpoints) AND lat1 EQ lat2 then BEGIN
183           IF key_onearth THEN !x.title = !x.title+' at '+strtrim(lataxe(0, 0, lat1), 1) ELSE !x.title = !x.title+' at j index '+strtrim(lat1, 1)
184         ENDIF
185      end
186
187      'yt':begin
188;         IF keyword_set(npts) THEN n = strtrim(npts, 1)
189         if keyword_set(endpoints) AND lon1 NE lon2 then $
190          !p.title = diaghovyt+varexp+fieldf+varname ELSE $
191         !p.title  =     hovyt+varexp+fieldf+varname
192         IF (time[(size(time))[0]-1] - time[0]) GE 10 THEN !x.title = timef
193         !y.title = lattitle
194         if keyword_set(endpoints) AND lon1 EQ lon2 then BEGIN
195           IF key_onearth THEN !x.title = !x.title+' at '+strtrim(lonaxe(0, 0, lon1), 1) ELSE !x.title = !x.title+' at i index '+strtrim(lon1, 1)
196         ENDIF
197      end
198
199      'zt':begin
200;         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(nx*ny, 1)
201         !p.title = hovzt+varexp+fieldf+varname
202         !y.title = depthf2
203         IF (time[(size(time))[0]-1] - time[0]) GE 10 THEN !x.title = timef
204      end
205      't':begin
206;         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE BEGIN
207;            if keyword_set(integration3d) then n=strtrim(nx*ny*nz, 1) ELSE n=strtrim(nx*ny, 1)
208;         ENDELSE
209         !p.title = hovt+varexp+fieldf+varname
210         !y.title = varname
211         IF (time[(size(time))[0]-1] - time[0]) GE 10 THEN !x.title = timef
212      end
213      'x':begin           
214;         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(ny*nz, 1)
215         if keyword_set(endpoints) AND lat1 NE lat2 then $
216          !p.title = endpointsf+varexp+datef+svardate+fieldf+varname ELSE $
217         !p.title  =            varexp+datef+svardate+fieldf+varname
218         !x.title = lontitle
219         if keyword_set(endpoints) AND lat1 EQ lat2 then BEGIN
220           IF key_onearth THEN !x.title = !x.title+' at '+strtrim(lataxe(0, 0, lat1), 1) ELSE !x.title = !x.title+' at j index '+strtrim(lat1, 1)
221         ENDIF
222         !y.title = varname
223      end
224      'y':begin           
225;         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(nx*nz, 1)
226         if keyword_set(endpoints) AND lon1 NE lon2 then $
227          !p.title = endpointsf+varexp+datef+svardate+fieldf+varname ELSE $
228         !p.title  =            varexp+datef+svardate+fieldf+varname
229         !x.title = lattitle
230         if keyword_set(endpoints) AND lon1 EQ lon2 then BEGIN
231           IF key_onearth THEN !x.title = !x.title+' at '+strtrim(lonaxe(0, 0, lon1), 1) ELSE !x.title = !x.title+' at i index '+strtrim(lon1, 1)
232         ENDIF
233         !y.title = varname
234      end
235      'z':begin
236         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(nx*ny, 1)
237         !p.title = varexp+datef+svardate+fieldf+varname
238         !y.title = depthf2
239         !x.title = varname
240      end
241      'yfx': BEGIN
242         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(nx*ny*nz, 1)
243         !p.title = varexp+datef+svardate+varunit
244         !x.title = varname2
245         !y.title = varname
246      END
247      else:
248   ENDCASE
249   if keyword_set(direc) then BEGIN
250      if strpos(direc, 'x') NE -1 then $
251       !p.subtitle = lonintf+'['+lo1+', '+lo2+']'+onf+'('+strtrim(nx, 1)+' points)  !C' +!p.subtitle
252      if strpos(direc, 'y') NE -1 then BEGIN
253         if strpos(!p.subtitle, '[') EQ -1 then $
254          !p.subtitle = latintf+'['+la1+', '+la2+']'+onf+'('+strtrim(ny, 1)+' points)  !C'+!p.subtitle $
255         ELSE !p.subtitle = latintf+'['+la1+', '+la2+']'+onf+'('+strtrim(ny, 1)+' points)  '+!p.subtitle
256      ENDIF
257      if strpos(direc, 'z') NE -1 AND (nz NE 1 OR coupe NE 'xy') then BEGIN
258         if strpos(!p.subtitle, '[') EQ -1 then $
259          !p.subtitle = depintf+'['+pr1+', '+pr2+']'+onf+'('+strtrim(nz, 1)+' points)  !C'+!p.subtitle $
260         ELSE !p.subtitle = depintf+'['+pr1+', '+pr2+']'+onf+'('+strtrim(nz, 1)+' points)  '+!p.subtitle
261      ENDIF
262   ENDIF
263   if keyword_set(endpoints) AND coupe NE 'yt' AND lat1 NE lat2 then !p.title = !p.title+'!C!C'
264   
265   if keyword_set(key_performance) THEN print, 'temps legende', systime(1)-tempsun
266   return
267end
Note: See TracBrowser for help on using the repository browser.