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

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

improvements of headers (typo, links, paragraphes, etc)

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