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

Last change on this file since 297 was 297, checked in by pinsard, 17 years ago

typo

  • 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 one 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;-
106;
107PRO plt1d, tab, param2, param3, param4, BOXZOOM = boxzoom, SIN = sin $
108           , MININ = minin, MAXIN = maxin, TYPEIN = typein, ENDPOINTS = endpoints $
109           , COL1D = col1d, STY1D = sty1d, OV1D = ov1d, X = x, Y = y, Z = z, TT = tt $
110           , REVERSE_X = reverse_x, REVERSE_Y = reverse_y, SWITCHXY = switchxy $
111           , _EXTRA = ex
112;
113  compile_opt idl2, strictarrsubs
114;
115@cm_4mesh
116@cm_4data
117  IF NOT keyword_set(key_forgetold) THEN BEGIN
118@updatenew
119@updatekwd
120  ENDIF
121;------------------------------------------------------------
122  tempsun = systime(1)          ; pour key_performance
123;--------------------------------------------------------------
124; 1st part: initialization small calculations...
125;--------------------------------------------------------------
126;--------------------------------------------------------------
127;--------------------------------------------------------------
128; verification of the type's value
129;--------------------------------------------------------------
130;
131  if n_elements(param2) NE 0 then type = param2
132  if n_elements(param3) NE 0 then min = param3
133  if n_elements(param4) NE 0 then max = param4
134  if n_elements(minin) NE 0 then min = minin
135  if n_elements(maxin) NE 0 then max = maxin
136  if keyword_set(tt) then typein = 't'
137  if keyword_set(typein) then BEGIN
138    if size(type, /type) NE 7 AND size(type, /type) NE 0 then begin
139      if n_elements(min) NE 0 then max = min
140      min = type
141    endif
142    type = typein
143  endif
144;
145  checktypeminmax, 'plt1d', TYPE = type, MIN = min, MAX = max, ENDPOINTS = endpoints $
146    , XX = keyword_set(x), YY = keyword_set(y), ZZ = keyword_set(z)
147  if type EQ 't' then BEGIN
148    pltt, tab, type, min, max, BOXZOOM = boxzoom, SIN = sin, TYPEIN = typein $
149      , COL1D = col1d, STY1D = sty1d, OV1D = ov1d, ENDPOINTS = endpoints, _extra = ex
150    return
151  endif
152;--------------------------------------------------------------
153; I2) reinitialization. !p.,!x.,!y.
154; Comment: We do not reinitialize when we call back plt1d
155;--------------------------------------------------------------
156  if NOT keyword_set(ov1d) then reinitplt
157;--------------------------------------------------------------
158; I1) Reading of the field
159;--------------------------------------------------------------
160   if (keyword_set(boxzoom) OR keyword_set(endpoints)) THEN BEGIN
161     savedbox = 1b
162     saveboxparam, 'boxparam4plt1d.dat'
163   ENDIF
164;
165  if keyword_set(endpoints) then begin
166    section, tab, z1d, glam, gphi, ENDPOINTS = endpoints, TYPE = type $
167      , BOXZOOM = boxzoom, DIREC = direc
168    nx = n_elements(glam)
169    ny = nx
170    if strupcase(vargrid) EQ 'W' then begin
171      z = gdepw[firstzw:lastzw]
172      nz = nzw
173    ENDIF ELSE BEGIN
174      z = gdept[firstzt:lastzt]
175      nz = nzt
176    ENDELSE
177  ENDIF ELSE BEGIN
178    z1d = checkfield(tab, 'plt1d', TYPE = type, BOXZOOM = boxzoom $
179                     , direc = direc, _extra = ex)
180    grille, mask, glam, gphi, gdep, nx, ny, nz, type = type
181  ENDELSE
182  if n_elements(z2d) EQ 1 AND z1d[0] EQ -1 then BEGIN
183    IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat'
184    return
185endif
186; We build the mask. For this, the array must be hidden (Automatically done at valmask
187; value if we pass in moyenne or grossemoyenne)
188  mask = fltarr(n_elements(z1d))
189  if n_elements(valmask) EQ 0 then valmask = 1e20
190  nan = total(finite(z1d, /nan))  < 1
191  if keyword_set(nan) then begin
192    notanum = where(finite(z1d) EQ 0)
193    z1d[notanum] = 0
194    mask[where(z1d LT valmask/10)] = 1
195    z1d[notanum] = !values.f_nan
196  ENDIF ELSE mask[where(z1d LT valmask/10)] = 1
197;-----------------------------------------------------------------------------
198; determination of the min and of the max after the average
199;-----------------------------------------------------------------------------
200  nan = total(finite(z1d, /nan)) < 1
201  determineminmax, z1d, mask, mi, ma, MININ = min, MAXIN = max, nan = nan, INTERVALLE = intervalle, _extra = ex
202  if n_elements(z2d) EQ 1 AND z1d[0] EQ -1 THEN return
203;-----------------------------------------------------------------------------
204;-----------------------------------------------------------------------------
205  if NOT keyword_set(ov1d) THEN placedessin, 'autre', posfenetre, posbar, contour = contour, DIREC = direc, endpoints = endpoints, _extra = ex
206;--------------------------------------------------------------
207;--------------------------------------------------------------
208; 2nd part: Drawing
209;--------------------------------------------------------------
210;-----------------------------------------------------------------------------
211; definition of the abscisse and ordinate vectors.
212; The triangulation is defined in order to the drawing be done from the
213; left bottom to the right up. So the matrix have to be shown like this,
214; from which some transpose and reverse
215;-----------------------------------------------------------------------------
216;-----------------------------------------------------------------------------
217  case type of
218    'y': begin
219      yy = z1d
220      IF (size(gphi))[0] EQ 1 then xx = gphi ELSE BEGIN
221        IF keyword_set(key_irregular) THEN BEGIN
222          cln = (where(gphi EQ max(gphi)))[0]
223          xx = reform(gphi[cln MOD nx, *])
224        ENDIF ELSE xx = reform(gphi[0, *])
225      ENDELSE
226      if keyword_set(sin) then xx = sin(!pi/180.*xx)
227      min0 = lat1 & max0 = lat2
228    END
229    'x':begin
230      yy = z1d
231      xx = glam[*, 0]
232      min0 = lon1 & max0 = lon2
233    END
234    'z':begin
235      yy = reverse(gdep, 1)
236      xx = reverse(z1d, 1)
237      min0 = 0 & max0 = 0
238      case n_elements(boxzoom) of
239        0:!y.range = [vert1, vert2]
240        1:!y.range = [0, boxzoom]
241        2:!y.range = boxzoom
242        4:!y.range = [vert1, vert2]
243        5:!y.range = [0, boxzoom[4]]
244        6:!y.range = boxzoom[4:5]
245      endcase
246      if NOT keyword_set(ov1d) then !y.range = reverse(!y.range)
247    END
248  ENDCASE
249;-----------------------------------------------------------
250;-----------------------------------------------------------
251;   definition of axes
252;----------------------------------------------------------
253;    if keyword_set(integrationtps) then axe, type, time[0], time[jpt-1], SIN = sin, _extra = ex $
254;    ELSE axe, type, SIN = sin
255  if NOT keyword_set(ov1d) then axe, type, SIN = sin
256;------------------------------------------------------------
257;------------------------------------------------------------
258; drawing
259;------------------------------------------------------------
260;------------------------------------------------------------
261  if type EQ 'z' then begin
262    idx = where(xx NE valmask)
263    if NOT keyword_set(ov1d) then BEGIN
264      if min EQ mi then !x.range = [min-abs(max-min)/5., max+abs(max-min)/5.] $
265      ELSE !x.range = [min, max]
266    ENDIF
267  ENDIF ELSE BEGIN
268    idx = where(yy NE valmask)
269    if NOT keyword_set(ov1d) then BEGIN
270      if min EQ mi then !y.range = [min-abs(max-min)/5., max+abs(max-min)/5.] $
271      ELSE !y.range = [min, max]
272    ENDIF
273  ENDELSE
274;
275  if NOT keyword_set(ov1d) then BEGIN
276    legende, mi, ma, type, CONTOUR = contour, DIREC = direc, ENDPOINTS = endpoints, _EXTRA = ex
277;
278  ENDIF
279  IF keyword_set(switchxy)  THEN BEGIN
280    tmp = xx
281    xx = yy
282    yy = temporary(tmp)
283    if NOT keyword_set(ov1d) then BEGIN
284      tmp = !x
285      !x = !y
286      !y = temporary(tmp)
287    ENDIF
288  ENDIF
289  if NOT keyword_set(ov1d) then BEGIN
290    if keyword_set(reverse_x) then !x.range = reverse(!x.range)
291    if keyword_set(reverse_y) then !y.range = reverse(!y.range)
292  ENDIF
293;
294  xx = xx[idx]
295  yy = yy[idx]
296  if (not keyword_set(col1d)) then col1d = 0
297  if keyword_set(sty1d) then BEGIN ;If we want to make bars
298    IF strlowcase(strtrim(sty1d)) EQ 'bar' then begin
299      !y.range = [!y.range[0]-(!y.range[1]-!y.range[0])*.05, !y.range[1]]
300      bar_plot, yy, background = (!d.n_colors-1) < 255,  $
301        baselines = replicate(!y.range[0], n_elements(yy)), barnames = ['', ''], $
302        colors    = replicate(col1d, n_elements(yy)), /outline
303      if n_elements(ex) NE 0 then BEGIN
304; To have a black frame
305        if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0
306      ENDIF
307      plot, [0], [0], /noerase, /nodata, _extra = ex
308      GOTO, fini
309    ENDIF
310  ENDIF
311;
312  if NOT keyword_set(ov1d) then BEGIN
313;
314    plot, xx, yy, color = col1d, linestyle = sty1d, thick = 2, title = '', subtitle = '', _extra = ex
315    if n_elements(ex) NE 0 then BEGIN
316; To have a 0 colored frame and trace a line at y=0
317      if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0
318      if (where(tag_names(ex) EQ 'LINESTYLE'))[0] NE -1 then ex.LINESTYLE = 0
319      if (where(tag_names(ex) EQ 'THICK'))[0] NE -1 then ex.THICK = 0
320    ENDIF
321    plot, !x.range, [0, 0], /noerase, /nodata $
322      , xstyle = 1+4*(keyword_set(endpoints) AND $
323                      ((type EQ 'x' AND lat1 NE lat2) OR (type EQ 'y' AND lon1 NE lon2))) $
324      , ystyle = 1, _extra = ex
325; Add of an axis in the case where we use endpoints
326    if keyword_set(endpoints) then addaxe, endpoints, type, posfenetre, _EXTRA = ex
327; Trace a line at x=0
328    plot, [0, 0], !y.range, /noerase, /nodata, title = '', subtitle = '', _extra = ex
329  ENDIF ELSE oplot, xx, yy, color = col1d, linestyle = sty1d, thick = 2, _extra = ex
330;------------------------------------------------------------
331;------------------------------------------------------------
332; 3rd part: Possible print.
333;------------------------------------------------------------
334;------------------------------------------------------------
335fini:
336  terminedessin, _extra = ex
337  if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat'
338;------------------------------------------------------------
339  if n_elements(key_performance) NE 0 then $
340    IF key_performance EQ 1 THEN print, 'temps plt1d', systime(1)-tempsun
341;------------------------------------------------------------
342;------------------------------------------------------------
343;------------------------------------------------------------
344  return
345end
Note: See TracBrowser for help on using the repository browser.