source: trunk/SRC/ToBeReviewed/PLOTS/legende.pro @ 159

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

header improvements + xxx doc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.9 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7; Provide caption
8;
9; @categories
10; Graphics
11;
12; @param MI {in}{required}
13; The min of the drawing
14;
15; @param MA {in}{required}
16; The max of the plot
17;
18; @param COUPE
19; Charactere containing two letters giving the type of the cut  (for example: 'xz').
20;
21; @keyword CONTOUR
22; If we want to trace contours of a different field than the one
23; whose we have the colored drawing (by examlpe E-P in color and QSR in contours).
24; It must be a field respecting same caracteristics than the argument number one of plt.
25;
26; @keyword ENDPOINTS
27; Used when we do vertical cuts in diagonal.
28;
29; @keyword _EXTRA
30; used to pass your keywords
31;
32; @uses
33; common.pro
34;
35; @restrictions
36; The use of the global variable langage allows to change the language and the caption easily.
37;
38; @history
39;  Sebastien Masson (smasson\@lodyc.jussieu.fr)
40;                       14/8/98
41;                       Eric Guilyardi (ericg\@lodyc.jussieu.fr) GB version
42;                       11/6/99
43;
44; @version
45; $Id$
46;
47;-
48;------------------------------------------------------------
49;------------------------------------------------------------
50;------------------------------------------------------------
51pro legende, mi, ma, coupe, CONTOUR = contour, ENDPOINTS = endpoints, DIREC = direc $
52             , VECTLEGENDE = vectlegende $
53             , INTERVALLE = intervalle, TYPE_YZ = type_yz, VARNAME2 = varname2 $
54             , NPTS = npts, _EXTRA = ex
55;
56  compile_opt idl2, strictarrsubs
57;
58@common
59  tempsun = systime(1)          ; pour key_performance
60;------------------------------------------------------------
61  grille, -1, -1, -1, gdep, nx, ny, nz
62;
63; English legends
64;
65  fmt_mm = '(f12.2)'
66  fmt_bt = '(f7.1)'
67  colorf = ''
68  contourf = 'Contour plot,'
69  vecteurf = 'Vector norm  '
70  expf = ''
71  datef = '   '
72  fieldf = '   '
73  depthf = '   '
74  endpointsf = 'Diag. Section'
75  zonalf = ''
76  IF key_onearth THEN latintf = 'latitudes in ' ELSE latintf = 'j index in '
77  timintf = 'time in '
78  onf = ' - '
79  depthf2 = 'Depth (m)'
80  Meridf = 'Zonal Mean  '
81  IF key_onearth THEN lonintf = 'longitudes in ' ELSE lonintf = 'i in '
82  hovxt = 'XT-plot   '
83  diaghovxt = 'Diag. XT-plot   '
84  depintf = 'depths in '
85  timef = 'Time'
86  hovyt = 'YT-plot   '
87  diaghovyt = 'Diag. YT-plot   '
88  hovzt = 'ZT-plot   '
89  hovt = ''
90  IF key_onearth THEN lontitle = 'Longitude' ELSE lontitle = 'i index'
91  IF key_onearth THEN lattitle = 'Latitude' ELSE lattitle = 'j index'
92 
93  vertz = depthf2
94  legniv = ' m'
95  IF keyword_set(TYPE_YZ) THEN BEGIN
96    IF type_yz EQ 'hPa' THEN vertz = 'hPa'
97    IF type_yz EQ 'hPa' THEN legniv = ' hPa'
98  ENDIF
99;
100; Start legende
101;
102;------------------------------------------------------------
103; definition and possible complement of !p.subtitle
104;------------------------------------------------------------
105  if n_elements(varunit) ne 0 then unite = '('+varunit+')' else unite = ''
106  !p.subtitle = colorf+unite+': Min= '+strtrim(string(format = fmt_mm, mi), 2)$
107                +', Max= '+strtrim(string(format = fmt_mm, ma), 2)
108  if keyword_set(intervalle) then BEGIN
109    if intervalle NE -1 then $
110       !p.subtitle = !p.subtitle+', Int= '+strtrim(string(format = fmt_mm, intervalle), 2)
111  endif
112  if size(contour, /type) EQ 8 then BEGIN ; it is a structure
113    unite = '('+contour.(1)+')'
114    !p.subtitle = !p.subtitle+'!C '+contourf+unite $
115                  +': Min= '+strtrim(string(format = fmt_mm, contour.(0)[0]), 2)$
116                  +', Max= '+strtrim(string(format = fmt_mm, contour.(0)[1]), 2)
117    if contour.inter NE -1  then $
118       !p.subtitle = !p.subtitle+', Int= '+strtrim(string(format = fmt_mm, contour.inter), 2)
119  ENDIF
120  if size(vectlegende, /type) EQ 8  then begin
121    unite = '('+vectlegende.(1)+')'
122    !p.subtitle = !p.subtitle+'!C '+vecteurf+unite $
123                  +': Min= '+strtrim(string(format = fmt_mm, vectlegende.(0)[0]), 2)$
124                  +', Max= '+strtrim(string(format = fmt_mm, vectlegende.(0)[1]), 2)
125  endif
126;------------------------------------------------------------
127; Shapping of subdomain 's dimensions
128;------------------------------------------------------------ 
129  la1 = strtrim(string(format = fmt_bt, lat1), 2)
130  la2 = strtrim(string(format = fmt_bt, lat2), 2)
131  lo1 = strtrim(string(format = fmt_bt, lon1), 2)
132  lo2 = strtrim(string(format = fmt_bt, lon2), 2)
133  pr1 = strtrim(string(format = fmt_bt, vert1), 2)
134  pr2 = strtrim(string(format = fmt_bt, vert2), 2)
135;------------------------------------------------------------
136; Management of the date
137;------------------------------------------------------------ 
138  if n_elements(vardate) EQ 0 then vardate = ''
139  if NOT keyword_set(direc) then direc = ''
140  if strpos(direc, 't') NE -1 then begin
141    svardate = strtrim(vairdate(time[0]), 1)+' - '+strtrim(vairdate(time[jpt-1]), 1)
142  ENDIF ELSE svardate = vardate
143;------------------------------------------------------------
144; case on the caes where the caption is applied
145;------------------------------------------------------------   
146  case coupe of
147    'xy':begin         
148      if strupcase(vargrid) EQ 'W' then firstz = firstzw $
149      ELSE firstz = firstzt
150      if(strpos(direc, 'z') EQ -1 AND firstz NE 0) then BEGIN
151        prof = strtrim(round(gdep[0]), 1)
152        !p.title = expf+varexp+datef+svardate+fieldf+varname+depthf+prof+legniv
153      ENDIF ELSE !p.title = expf+varexp+datef+svardate+fieldf+varname
154      !x.title = lontitle
155      !y.title = lattitle
156    end
157
158    'xz':begin
159      IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n = strtrim(ny, 1)
160      IF long(n) LE 3 THEN zonalf = 'Section   '
161      if keyword_set(endpoints) AND lat1 NE lat2 then $
162         !p.title = endpointsf+varexp+datef+svardate+fieldf+varname ELSE $
163            !p.title = zonalf+varexp+datef+svardate+fieldf+varname
164      !x.title = lontitle
165      if keyword_set(endpoints) AND lat1 EQ lat2 then BEGIN
166        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)
167      ENDIF
168      !y.title = depthf2
169    end
170
171    'yz':begin
172      IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n = strtrim(nx, 1)
173      IF long(n) LE 3 THEN meridf = ''
174      if keyword_set(endpoints) AND lon1 NE lon2 then $
175         !p.title = endpointsf+varexp+datef+svardate+fieldf+varname ELSE $
176            !p.title = meridf+varexp+datef+svardate+fieldf+varname
177      !y.title = vertz
178      !x.title = lattitle
179      if keyword_set(endpoints) AND lon1 EQ lon2 then BEGIN
180        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)
181      ENDIF
182    end
183
184    'xt':begin
185;         IF keyword_set(npts) THEN n = strtrim(npts, 1)
186      if keyword_set(endpoints) AND lat1 NE lat2 then $
187         !p.title = diaghovxt+varexp+fieldf+varname ELSE $
188            !p.title  =     hovxt+varexp+fieldf+varname
189      IF (time[(size(time))[0]-1] - time[0]) GE 10 THEN !y.title = timef
190      !x.title = lontitle
191      if keyword_set(endpoints) AND lat1 EQ lat2 then BEGIN
192        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)
193      ENDIF
194    end
195
196    'yt':begin
197;         IF keyword_set(npts) THEN n = strtrim(npts, 1)
198      if keyword_set(endpoints) AND lon1 NE lon2 then $
199         !p.title = diaghovyt+varexp+fieldf+varname ELSE $
200            !p.title  =     hovyt+varexp+fieldf+varname
201      IF (time[(size(time))[0]-1] - time[0]) GE 10 THEN !x.title = timef
202      !y.title = lattitle
203      if keyword_set(endpoints) AND lon1 EQ lon2 then BEGIN
204        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)
205      ENDIF
206    end
207
208    'zt':begin
209;         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(nx*ny, 1)
210      !p.title = hovzt+varexp+fieldf+varname
211      !y.title = depthf2
212      IF (time[(size(time))[0]-1] - time[0]) GE 10 THEN !x.title = timef
213    end
214    't':begin
215;         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE BEGIN
216;            if keyword_set(integration3d) then n=strtrim(nx*ny*nz, 1) ELSE n=strtrim(nx*ny, 1)
217;         ENDELSE
218      !p.title = hovt+varexp+fieldf+varname
219      !y.title = varname
220      IF (time[(size(time))[0]-1] - time[0]) GE 10 THEN !x.title = timef
221    end
222    'x':begin           
223;         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(ny*nz, 1)
224      if keyword_set(endpoints) AND lat1 NE lat2 then $
225         !p.title = endpointsf+varexp+datef+svardate+fieldf+varname ELSE $
226            !p.title  =            varexp+datef+svardate+fieldf+varname
227      !x.title = lontitle
228      if keyword_set(endpoints) AND lat1 EQ lat2 then BEGIN
229        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)
230      ENDIF
231      !y.title = varname
232    end
233    'y':begin           
234;         IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n=strtrim(nx*nz, 1)
235      if keyword_set(endpoints) AND lon1 NE lon2 then $
236         !p.title = endpointsf+varexp+datef+svardate+fieldf+varname ELSE $
237            !p.title  =            varexp+datef+svardate+fieldf+varname
238      !x.title = lattitle
239      if keyword_set(endpoints) AND lon1 EQ lon2 then BEGIN
240        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)
241      ENDIF
242      !y.title = varname
243    end
244    'z':begin
245      IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n = strtrim(nx*ny, 1)
246      !p.title = varexp+datef+svardate+fieldf+varname
247      !y.title = depthf2
248      !x.title = varname
249    end
250    'yfx': BEGIN
251      IF keyword_set(npts) THEN n = strtrim(npts, 1) ELSE n = strtrim(nx*ny*nz, 1)
252      !p.title = varexp+datef+svardate+varunit
253      !x.title = varname2
254      !y.title = varname
255    END
256    else:
257  ENDCASE
258  if keyword_set(direc) then BEGIN
259    if strpos(direc, 'x') NE -1 then $
260       !p.subtitle = lonintf+'['+lo1+', '+lo2+']'+onf+'('+strtrim(nx, 1)+' points)  !C' +!p.subtitle
261    if strpos(direc, 'y') NE -1 then BEGIN
262      if strpos(!p.subtitle, '[') EQ -1 then $
263         !p.subtitle = latintf+'['+la1+', '+la2+']'+onf+'('+strtrim(ny, 1)+' points)  !C'+!p.subtitle $
264      ELSE !p.subtitle = latintf+'['+la1+', '+la2+']'+onf+'('+strtrim(ny, 1)+' points)  '+!p.subtitle
265    ENDIF
266    if strpos(direc, 'z') NE -1 AND (nz NE 1 OR coupe NE 'xy') then BEGIN
267      if strpos(!p.subtitle, '[') EQ -1 then $
268         !p.subtitle = depintf+'['+pr1+', '+pr2+']'+onf+'('+strtrim(nz, 1)+' points)  !C'+!p.subtitle $
269      ELSE !p.subtitle = depintf+'['+pr1+', '+pr2+']'+onf+'('+strtrim(nz, 1)+' points)  '+!p.subtitle
270    ENDIF
271  ENDIF
272  if keyword_set(endpoints) AND coupe NE 'yt' AND lat1 NE lat2 then !p.title = !p.title+'!C!C'
273 
274  if keyword_set(key_performance) THEN print, 'temps legende', systime(1)-tempsun
275  return
276end
Note: See TracBrowser for help on using the repository browser.