source: trunk/SRC/ToBeReviewed/PLOTS/DESSINE/plt1d.pro @ 367

Last change on this file since 367 was 367, checked in by pinsard, 16 years ago

typo and translation

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.8 KB
Line 
1;+
2;
3; @file_comments
4; Trace 1d graphs: x,y,z (or t but in this case, we recall directly pltt)
5;
6; @categories
7; Graphics
8;
9; @param TAB {in}{required}
10; The field whose we want to make the hovmoeller map can be 2 kind of thing:
11;       1) An array which can be:
12;          * 2d, 3d or 4d:  array xy, xyz. xyt or xyzt. In this case, the array will pass
13;          in moyenne or grossemoyenne to be averaged and become  an array 1d.
14;          * 1d:Nevertheless, the type must be specified in order to we know which trace
15;          it is about. To have a correct caption, respecify the  extraction zone via BOXZOOM.
16;       2) a structure respecting all criterions specified by <pro>litchamp</pro>
17;          See IDL> xhelp,'litchamp'. The array contained in the structure
18;          respecting criterions of case 1)
19;
20; @param PARAM2 {in}{required}
21; Min value we want to consider in the contour's drawing.
22; Note: could also be the type of plot:'x','y','z'
23;
24; @param PARAM3 {in}{optional}{default=min/max of tab (on ocean points)}
25; Max value we want to consider in the contour's drawing.
26; Note: if param2 is defined as 'x','y','z' then param3 is used to define the min (see param2)
27;
28; @param PARAM4 {in}{optional}{default=max of tab (on ocean points)}
29; Type of plot (can be only 'x','y','z' for plt1d).
30; Note: if param2 is defined as 'xy' then param4 is used to define the max (see param3)
31;
32; @keyword BOXZOOM
33; Vector indicating the geographic zone (3d) on which the extraction of the field must
34; be done to do the hovmoeller.
35;  If BOXZOOM has :
36; 1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]]
37; 2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]]
38; 4 elements: The extraction is made on [Boxzoom, vert1, vert2]
39; 5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]]
40; 6 elements: The extraction is made on Boxzoom
41;
42; Where lon1, lon2,lat1,lat2,vert1,vert2 are global variables defined at the last
43; <pro>domdef</pro> !
44;
45; @keyword COL1D
46;  --OBSOLETE--Color number when we make a trace 1d by default, 0.
47; It is better to use the keyword COLOR used by plot.
48;
49; @keyword ENDPOINTS
50; keyword specifying that we want to make a vertical cut in diagonal.
51; Then coordinated of extremities of these ones are defined by the 4 elements
52; of the vector ENDPOINTS: [x1,y1,x2,y2] which are coordinates.
53;
54; @keyword MAXIN
55; Allows to specify the max value we want to consider in the drawing of contour
56; helping by the keyword instead of the argument max.
57; If the argument and the keyword are specified in the same time, it is the
58; value specified by the keyword which is retained.
59;
60; @keyword MININ
61; Allows to specify the min value we want to consider in the drawing of contour
62; helping by the keyword instead of the argument min.
63; If the argument and the keyword are specified in the same time, it is the
64; value specified by the keyword which is retained.
65;
66; @keyword OV1D
67; Allow the double exposure of an 1d curve to a precedent 1d trace.
68;
69; @keyword REVERSE_X
70; To invert the x axis (so as the drawing)
71;
72; @keyword REVERSE_Y
73; To invert the y axis (so as the drawing)
74;
75; @keyword SIN
76; Activate this keyword if we want the x axis to be traced in sinus of the
77; latitude when we make a drawing f(y)
78;
79; @keyword STY1D
80; --OBSOLETE--
81; Number of the style used when we make a 1d drawing. We should better use the
82; keyword LINESTYLE which is tho one of the plot. Beware, this keyword is still
83; useful if we want to d bars instead of curves, put sty1d='bar'
84;
85; @keyword TYPEIN
86; allows to specify the type of hovmoeller we want to do
87;             'xt','yt','zt','t'
88; with help of a keyword rather than the argument type. If the argument and the
89; keyword are specified in the same time, it is the value specified by the
90; keyword which is retained.
91;
92; @keyword _EXTRA
93; Used to pass keywords
94;
95; @history
96; creation 24/6/99 Eric Guilyardi
97; (a partir routine pltt de Sebastien Masson)
98; 8/7/1999 Sebastien Masson (smasson\@lodyc.jussieu.fr)
99; inspection des travaux finis
100; 8/2/2000 Sebastien Masson: checkfield
101;
102; @version
103; $Id$
104;
105;-
106PRO plt1d, tab, param2, param3, param4, BOXZOOM=boxzoom, SIN=sin $
107         , MININ=minin, MAXIN=maxin, TYPEIN=typein, ENDPOINTS=endpoints $
108         , COL1D=col1d, STY1D=sty1d, OV1D=ov1d, X=x, Y=y, Z=z, TT=tt $
109         , REVERSE_X=reverse_x, REVERSE_Y=reverse_y, SWITCHXY=switchxy $
110         , _EXTRA=ex
111;
112  compile_opt idl2, strictarrsubs
113;
114@cm_4mesh
115@cm_4data
116  IF NOT keyword_set(key_forgetold) THEN BEGIN
117@updatenew
118@updatekwd
119  ENDIF
120;------------------------------------------------------------
121  tempsun = systime(1)          ; pour key_performance
122;--------------------------------------------------------------
123; 1st part: initialization small calculations...
124;--------------------------------------------------------------
125;--------------------------------------------------------------
126;--------------------------------------------------------------
127; verification of the type's value
128;--------------------------------------------------------------
129;
130  if n_elements(param2) NE 0 then type = param2
131  if n_elements(param3) NE 0 then min = param3
132  if n_elements(param4) NE 0 then max = param4
133  if n_elements(minin) NE 0 then min = minin
134  if n_elements(maxin) NE 0 then max = maxin
135  if keyword_set(tt) then typein = 't'
136  if keyword_set(typein) then BEGIN
137    if size(type, /type) NE 7 AND size(type, /type) NE 0 then begin
138      if n_elements(min) NE 0 then max = min
139      min = type
140    endif
141    type = typein
142  endif
143;
144  checktypeminmax, 'plt1d', TYPE = type, MIN = min, MAX = max, ENDPOINTS = endpoints $
145    , XX = keyword_set(x), YY = keyword_set(y), ZZ = keyword_set(z)
146  if type EQ 't' then BEGIN
147    pltt, tab, type, min, max, BOXZOOM = boxzoom, SIN = sin, TYPEIN = typein $
148      , COL1D = col1d, STY1D = sty1d, OV1D = ov1d, ENDPOINTS = endpoints, _extra = ex
149    return
150  endif
151;--------------------------------------------------------------
152; I2) reinitialization. !p.,!x.,!y.
153; Comment: We do not reinitialize when we call back plt1d
154;--------------------------------------------------------------
155  if NOT keyword_set(ov1d) then reinitplt
156;--------------------------------------------------------------
157; I1) Reading of the field
158;--------------------------------------------------------------
159   if (keyword_set(boxzoom) OR keyword_set(endpoints)) THEN BEGIN
160     savedbox = 1b
161     saveboxparam, 'boxparam4plt1d.dat'
162   ENDIF
163;
164  if keyword_set(endpoints) then begin
165    section, tab, z1d, glam, gphi, ENDPOINTS = endpoints, TYPE = type $
166      , BOXZOOM = boxzoom, DIREC = direc
167    nx = n_elements(glam)
168    ny = nx
169    if strupcase(vargrid) EQ 'W' then begin
170      z = gdepw[firstzw:lastzw]
171      nz = nzw
172    ENDIF ELSE BEGIN
173      z = gdept[firstzt:lastzt]
174      nz = nzt
175    ENDELSE
176  ENDIF ELSE BEGIN
177    z1d = checkfield(tab, 'plt1d', TYPE = type, BOXZOOM = boxzoom $
178                     , direc = direc, _extra = ex)
179    grille, mask, glam, gphi, gdep, nx, ny, nz, type = type
180  ENDELSE
181  if n_elements(z2d) EQ 1 AND z1d[0] EQ -1 then BEGIN
182    IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat'
183    return
184endif
185; We build the mask. For this, the array must be hidden (Automatically done at valmask
186; value if we pass in moyenne or grossemoyenne)
187  mask = fltarr(n_elements(z1d))
188  if n_elements(valmask) EQ 0 then valmask = 1e20
189  nan = total(finite(z1d, /nan))  < 1
190  if keyword_set(nan) then begin
191    notanum = where(finite(z1d) EQ 0)
192    z1d[notanum] = 0
193    mask[where(z1d LT valmask/10)] = 1
194    z1d[notanum] = !values.f_nan
195  ENDIF ELSE mask[where(z1d LT valmask/10)] = 1
196;-----------------------------------------------------------------------------
197; determination of the min and of the max after the average
198;-----------------------------------------------------------------------------
199  nan = total(finite(z1d, /nan)) < 1
200  determineminmax, z1d, mask, mi, ma, MININ = min, MAXIN = max, nan = nan, INTERVALLE = intervalle, _extra = ex
201  if n_elements(z2d) EQ 1 AND z1d[0] EQ -1 THEN return
202;-----------------------------------------------------------------------------
203;-----------------------------------------------------------------------------
204  if NOT keyword_set(ov1d) THEN placedessin, 'autre', posfenetre, posbar, contour = contour, DIREC = direc, endpoints = endpoints, _extra = ex
205;--------------------------------------------------------------
206;--------------------------------------------------------------
207; 2nd part: Drawing
208;--------------------------------------------------------------
209;-----------------------------------------------------------------------------
210; definition of the abscisse and ordinate vectors.
211; The triangulation is defined in order to the drawing be done from the
212; left bottom to the right up. So the matrix have to be shown like this,
213; from which some transpose and reverse
214;-----------------------------------------------------------------------------
215;-----------------------------------------------------------------------------
216  case type of
217    'y': begin
218      yy = z1d
219      IF (size(gphi))[0] EQ 1 then xx = gphi ELSE BEGIN
220        IF keyword_set(key_irregular) THEN BEGIN
221          cln = (where(gphi EQ max(gphi)))[0]
222          xx = reform(gphi[cln MOD nx, *])
223        ENDIF ELSE xx = reform(gphi[0, *])
224      ENDELSE
225      if keyword_set(sin) then xx = sin(!pi/180.*xx)
226      min0 = lat1 & max0 = lat2
227    END
228    'x':begin
229      yy = z1d
230      xx = glam[*, 0]
231      min0 = lon1 & max0 = lon2
232    END
233    'z':begin
234      yy = reverse(gdep, 1)
235      xx = reverse(z1d, 1)
236      min0 = 0 & max0 = 0
237      case n_elements(boxzoom) of
238        0:!y.range = [vert1, vert2]
239        1:!y.range = [0, boxzoom]
240        2:!y.range = boxzoom
241        4:!y.range = [vert1, vert2]
242        5:!y.range = [0, boxzoom[4]]
243        6:!y.range = boxzoom[4:5]
244      endcase
245      if NOT keyword_set(ov1d) then !y.range = reverse(!y.range)
246    END
247  ENDCASE
248;-----------------------------------------------------------
249;-----------------------------------------------------------
250;   definition of axes
251;----------------------------------------------------------
252;    if keyword_set(integrationtps) then axe, type, time[0], time[jpt-1], SIN = sin, _extra = ex $
253;    ELSE axe, type, SIN = sin
254  if NOT keyword_set(ov1d) then axe, type, SIN = sin
255;------------------------------------------------------------
256;------------------------------------------------------------
257; drawing
258;------------------------------------------------------------
259;------------------------------------------------------------
260  if type EQ 'z' then begin
261    idx = where(xx NE valmask)
262    if NOT keyword_set(ov1d) then BEGIN
263      if min EQ mi then !x.range = [min-abs(max-min)/5., max+abs(max-min)/5.] $
264      ELSE !x.range = [min, max]
265    ENDIF
266  ENDIF ELSE BEGIN
267    idx = where(yy NE valmask)
268    if NOT keyword_set(ov1d) then BEGIN
269      if min EQ mi then !y.range = [min-abs(max-min)/5., max+abs(max-min)/5.] $
270      ELSE !y.range = [min, max]
271    ENDIF
272  ENDELSE
273;
274  if NOT keyword_set(ov1d) then BEGIN
275    legende, mi, ma, type, CONTOUR = contour, DIREC = direc, ENDPOINTS = endpoints, _EXTRA = ex
276;
277  ENDIF
278  IF keyword_set(switchxy)  THEN BEGIN
279    tmp = xx
280    xx = yy
281    yy = temporary(tmp)
282    if NOT keyword_set(ov1d) then BEGIN
283      tmp = !x
284      !x = !y
285      !y = temporary(tmp)
286    ENDIF
287  ENDIF
288  if NOT keyword_set(ov1d) then BEGIN
289    if keyword_set(reverse_x) then !x.range = reverse(!x.range)
290    if keyword_set(reverse_y) then !y.range = reverse(!y.range)
291  ENDIF
292;
293  xx = xx[idx]
294  yy = yy[idx]
295  if (not keyword_set(col1d)) then col1d = 0
296  if keyword_set(sty1d) then BEGIN ;If we want to make bars
297    IF strlowcase(strtrim(sty1d)) EQ 'bar' then begin
298      !y.range = [!y.range[0]-(!y.range[1]-!y.range[0])*.05, !y.range[1]]
299      bar_plot, yy, background = (!d.n_colors-1) < 255,  $
300        baselines = replicate(!y.range[0], n_elements(yy)), barnames = ['', ''], $
301        colors    = replicate(col1d, n_elements(yy)), /outline
302      if n_elements(ex) NE 0 then BEGIN
303; To have a black frame
304        if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0
305      ENDIF
306      plot, [0], [0], /noerase, /nodata, _extra = ex
307      GOTO, fini
308    ENDIF
309  ENDIF
310;
311  if NOT keyword_set(ov1d) then BEGIN
312;
313    plot, xx, yy, color = col1d, linestyle = sty1d, thick = 2, title = '', subtitle = '', _extra = ex
314    if n_elements(ex) NE 0 then BEGIN
315; To have a 0 colored frame and trace a line at y=0
316      if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0
317      if (where(tag_names(ex) EQ 'LINESTYLE'))[0] NE -1 then ex.LINESTYLE = 0
318      if (where(tag_names(ex) EQ 'THICK'))[0] NE -1 then ex.THICK = 0
319    ENDIF
320    plot, !x.range, [0, 0], /noerase, /nodata $
321      , xstyle = 1+4*(keyword_set(endpoints) AND $
322                      ((type EQ 'x' AND lat1 NE lat2) OR (type EQ 'y' AND lon1 NE lon2))) $
323      , ystyle = 1, _extra = ex
324; Add of an axis in the case where we use endpoints
325    if keyword_set(endpoints) then addaxe, endpoints, type, posfenetre, _EXTRA = ex
326; Trace a line at x=0
327    plot, [0, 0], !y.range, /noerase, /nodata, title = '', subtitle = '', _extra = ex
328  ENDIF ELSE oplot, xx, yy, color = col1d, linestyle = sty1d, thick = 2, _extra = ex
329;------------------------------------------------------------
330;------------------------------------------------------------
331; 3rd part: Possible print.
332;------------------------------------------------------------
333;------------------------------------------------------------
334fini:
335  terminedessin, _extra = ex
336  if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat'
337;------------------------------------------------------------
338  if n_elements(key_performance) NE 0 then $
339    IF key_performance EQ 1 THEN print, 'temps plt1d', systime(1)-tempsun
340;------------------------------------------------------------
341;------------------------------------------------------------
342;------------------------------------------------------------
343  return
344end
Note: See TracBrowser for help on using the repository browser.