source: trunk/SRC/ToBeReviewed/PLOTS/DESSINE/pltz.pro @ 231

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

improvements/corrections of some *.pro headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 21.0 KB
Line 
1;+
2;
3; @file_comments
4; Trace vertical graphs.
5;
6; @categories
7; Graphics
8;
9; @param TAB
10; The field whose we want to make a vertical cut can be 2 kind of thing:
11;         1) An 2d or 3d array.
12;         If the field is 2d, indicate, with the keyword BOXZOOM, geographic delineations of the boxzoom.
13;         If the field is 3d, we extract the section on we average possibly before to do the plot.
14;         2)  a structure respecting all criterions specified by <pro>litchamp</pro>.
15;          See IDL> xhelp,'litchamp'. The array contained in the structure must be 2 or 3d (See case 1)
16;
17; ces arguments ne sont pas obligatoires:
18;
19;       MAX: valeur maximum que l'on veut prendre en compte dans le trace
20; des contours. Par defaut on prend le max de tab1 (sur les pts mer)
21;
22;       MIN: valeur minimum que l'on veut prendre en compte dans le trace
23; des contours. Par defaut on prend le min de tab1 (sur les pts mer)
24;
25; @keyword BOXZOOM
26; Vector indicating the geographic zone on which we want to cut the map.
27;  If BOXZOOM has :
28; 1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]]
29; 2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]]
30; 4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])]
31; 5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]]
32; 6 elements: The extraction is made on Boxzoom
33;
34; Where lon1, lon2,lat1,lat2 are global variables defined at the last domdef!
35;
36; @keyword CONTINTERVALLE
37; When CONTOUR is activated, it is the value between 2 isolines
38; traced by a trait. So it can be different from the one specified by INTERVALLE which,
39; in this case, does not control colored isolines in color anymore. If there is noone
40; specified min, we choose a contour min which goes well with the specified interval!
41; If this keyword is not specified, we trace 20 isolines from the min to the max.
42;
43; @keyword CONTLABEL {type=integer}
44; When CONTOUR is activated, if n
45; is different of 0, choose the label type corresponding to n cases for
46; the traced by a traitisolines. To specify the type of label of the
47; colored contour, use LABEL
48;
49; @keyword CONTMAX {default=max of the keyword CONTOUR (on ocean points)}
50; When CONTOUR is activated, max value we want to consider in the isoline
51; traced by a trait's line.
52;
53; @keyword CONTMIN {default=min of the keyword CONTOUR (on ocean points)}
54; When CONTOUR is activated, min value we want to consider in the isoline
55; traced by a trait's line.
56;
57; @keyword CONTNLEVEL {default=20}
58; When  CONTOUR is activated, it is the number of contours
59; traced by a trait for drawing (active if
60; CONTLABEL=0).
61;
62; @keyword CONTOUR
63; If we want to trace contours of a different field than the one
64; whose we have the colored drawing (by example E-P in color and QSR in contours).
65; It must be a field respecting same characteristics than the argument number one of plt.
66;
67; @keyword ENDPOINTS
68; keyword specifying that we want to make a vertical cut in diagonal. Then coordinated of extremities
69; of these one are defined by the 4 elements of the vector ENDPOINTS: [x1,y1,x2,y2] which are
70; coordinates.
71;
72; @keyword INTERVALLE
73; Value of an internal between to isoline. If there is none specified min,
74; we choose a min contour which goes well with the specified interval!. If this keyword is not
75; specified, we trace 20 isoline from the min to the max. Comment: When CONTOUR is activated,
76; INTERVALLE only specify the interval between 2 colored isoline. To specify the interval
77; between 2 isolines traced by a trait, use CONTINTERVALLE.
78;
79; @keyword INV
80; Invert the color vector used to color the graph
81;               (without use the black, the white and the used palette)
82;
83; @keyword ZRATIO {default=2./3}
84; When the drawing has a zoomed part, it is the size rapport between the zoomed part,
85; hz (zoom height), and the whole drawing, ht (total height).
86;
87; @keyword LABEL {default=0}{type=integer}
88; It choose the label's type corresponding to cases in <pro>label</pro>
89; Comment: When CONTOUR is activated, it only specify the label's type for colored isolines.
90; For these one traced by a trait, use CONTLABEL.
91;
92; @keyword MAXIN
93; to specify the max value we want to plot with a keyword instead of with the
94; input parameter max. If max is defined by both, parameter and keyword, the
95; keyword is retained.
96;
97; @keyword MININ
98; to specify the min value we want to plot with a keyword instead of with the
99; input parameter min. If min is defined by both, parameter and keyword, the
100; keyword is retained.
101;
102; @keyword NLEVEL {default=20}
103; Number of contour to draw by default =20. active if
104; LABEL=0 or is not specified.
105;
106; @keyword NOTRI
107; To force not to use the triangulation. Beware, in this case, the
108; drawing only works if the grid is undeformed (It means that each point of a longitude
109; give one latitude and each point of a latitude give one longitude) except if we use
110; the keyword CELL_FILL=2.
111; Comment: if the field contain points !values.f_nan, then we even do a triangulation.
112;
113; @keyword OVERPLOT
114; To make a plot over an other one.
115; Comment: Contrarily to the use of CONTOUR or VECTEUR, the use of this keyword
116; does not the caption and/or the color bar.
117;
118; @keyword SIN
119; Activate this keyword if we want the x axis to be traced in sinus of the
120; latitude when we make a drawing f(y)
121;
122; @keyword STRICTFILL
123; Activate this keyword to that the filling of contours be
124; precisely done between the min and the max specified letting values inferior at the
125; specified min and values superior at the specified max in white.
126;
127; @keyword STYLE {default=style=0}
128; Contour's style to adopt to draw isolines
129;
130; @keyword WDEPTH
131; To specify that the field is at W depth instead of T
132; depth (automatically activated if vargrid eq 'W')
133;
134; @keyword XZ
135; Force to make a cut following xz
136;
137; @keyword YZ
138; Force to make a cut following yz
139;
140; @keyword ZOOM  {default=200m or max depth if it is inferior at 200m}
141; Depth where i can make our maximum zoom.
142;
143; @uses
144; common.pro
145;
146; @history
147;  Sebastien Masson (smasson\@lodyc.jussieu.fr)
148; 7/1999
149; Sebastien Masson 08/02/2000 checkfield and
150; notri keyword.
151;
152; @version
153; $Id$
154;
155; @todo seb L.20 à 26, L.215 à 221
156;
157;-
158;
159PRO pltz, tab, giventype, givenmin, givenmax, BOXZOOM = boxzoom, CONTOUR = contour $
160          , ENDPOINTS = endpoints, INTERVALLE = intervalle, INV = inv, ZRATIO = zratio $
161          , CONTINTERVALLE = contintervalle, LABEL = label, CONTLABEL = contlabel $
162          , STYLE = style, CONTMAX = contmax, SIN = sin, TYPEIN = typein $
163          , CONTMIN = contmin, NLEVEL = nlevel, CONTNLEVEL = contnlevel $
164          , NOTRI = notri, USETRI = usetri, FILLXDIR = fillxdir $
165          , ZOOM = zoom, XZ = xz, YZ = yz, MININ = minin, MAXIN = maxin $
166          , STRICTFILL = strictfill, OVERPLOT = overplot, MASKFILL = maskfill $
167          , WDEPTH = wdepth, REALSECTION = realsection $
168          , _EXTRA = ex
169;
170  compile_opt idl2, strictarrsubs
171;
172@cm_4mesh
173@cm_4data
174@cm_4ps
175  IF NOT keyword_set(key_forgetold) THEN BEGIN
176@updatenew
177@updatekwd
178  ENDIF
179;--------------------------------------------------------------
180  tempsun = systime(1)          ; For key_performance
181;------------------------------------------------------------
182;--------------------------------------------------------------
183; 1st part: initialization small calculations...
184;--------------------------------------------------------------
185; Comment: we do not reinitializate when we call back plt in loop to use contour.
186  if n_elements(contour) ne 4 AND NOT keyword_set(overplot) then reinitplt
187;
188  if n_elements(contour) ne 4 THEN saveboxparam, 'boxparam4pltz.dat'
189;--------------------------------------------------------------
190;  Reading of the field.
191;--------------------------------------------------------------
192  if n_elements(giventype) NE 0 then type = giventype
193  if n_elements(givenmin) NE 0 then min = givenmin
194  if n_elements(givenmax) NE 0 then max = givenmax
195  if n_elements(minin) NE 0 then min = minin
196  if n_elements(maxin) NE 0 then max = maxin
197  if n_elements(realsection) EQ 0 then realsection = 1
198  IF n_elements(usetri) EQ 0 THEN BEGIN
199    IF n_elements(notri) NE 0 THEN usetri = 2-notri ELSE usetri = 1
200  ENDIF
201; no need of triangulation
202  IF usetri EQ 1 AND keyword_set(realsection) THEN usetri = 0
203; did we specify the type ?
204  if keyword_set(typein) then BEGIN
205    if size(type, /type) NE 7 AND size(type, /type) NE 0 then begin
206      if n_elements(min) NE 0 then max = min
207      min = type
208    endif
209    type = typein
210  ENDIF
211;
212  checktypeminmax, 'pltz', TYPE = type, MIN = min, MAX = max $
213    , XZ = xz, YZ = yz, ENDPOINTS = endpoints, _extra = ex
214;
215  if keyword_set(endpoints) then begin
216    section, tab, z2d, glam, gphi, ENDPOINTS = endpoints, TYPE = type $
217    , BOXZOOM = boxzoom, DIREC = direc, WDEPTH = wdepth, _extra = ex
218    if z2d[0] EQ -1 AND n_elements(contour) ne 4 then BEGIN
219      restoreboxparam, 'boxparam4pltz.dat'
220      return
221    ENDIF
222    nx = n_elements(glam)
223    ny = nx
224    if strupcase(vargrid) EQ 'W' then begin
225      gdep = gdepw[firstzw:lastzw]
226      nz = nzw
227    ENDIF ELSE BEGIN
228      gdep = gdept[firstzt:lastzt]
229      nz = nzt
230    ENDELSE
231    mask = z2d LE valmask/10.
232  ENDIF ELSE BEGIN
233    z2d = checkfield(tab, 'pltz', TYPE = type, BOXZOOM = boxzoom $
234                     , DIREC = direc, WDEPTH = wdepth, _extra = ex)
235    if z2d[0] EQ -1 AND n_elements(contour) ne 4 then BEGIN
236      restoreboxparam, 'boxparam4pltz.dat'
237      return
238    ENDIF
239    IF realsection EQ 1 THEN grille, mask, glam, gphi, gdep, nx, ny, nz, type = type, WDEPTH = wdepth $
240    ELSE grille, mask, glam, gphi, gdep, nx, ny, nz, WDEPTH = wdepth
241  ENDELSE
242  IF size(gdep, /n_dimensions) EQ 2 THEN usetri = 2
243;---------------------------------------------------------------
244  profmax = !y.range[0]
245  profmin = !y.range[1]
246  if not keyword_set(zoom) then zoom = 200
247  zoom = zoom[0]
248  IF zoom LT profmin THEN zoom = profmax
249  if zoom GE vert2 then zoom = profmax
250; construction of the mask and of the axis
251  axis4pltz, type, mask, glam, gphi, gdep, XXAXIS = xxaxis, ZZAXIS = zzaxis, SIN = sin, ZRATIO = zratio, ZOOM = zoom, PROFMAX = profmax, PROFMIN = profmin, _extra = ex
252; to draw from bottom to top (avoid using cell_fill)
253  z2d = reverse(z2d, 2)
254;-----------------------------------------------------------------------------
255; Determination of the mi:min and of the ma:max of z2d in the same way
256; as max: max and min: min for the drawing.
257;-----------------------------------------------------------------------------
258  nan = total(finite(z2d, /nan)) < 1
259; Do we need to do an autoscale ???
260  autoscale = testvar(var = min) EQ testvar(var = max) AND NOT keyword_set(intervalle)
261  determineminmax, z2d, mask, mi, ma, MININ = min, MAXIN = max, nan = nan, INTERVALLE = intervalle, _extra = ex
262  if z2d[0] EQ -1 THEN GOTO, sortie
263; We do an autoscale if needed.
264  if autoscale then autoscale, min, max, intervalle
265;--------------------------------------------------------------
266;--------------------------------------------------------------
267; 2nd part: drawing
268;--------------------------------------------------------------
269;--------------------------------------------------------------
270  if n_elements(contour) NE 4 AND NOT keyword_set(overplot) THEN $
271    placedessin, 'pltz', posfenetre, posbar, contour = contour, endpoints = endpoints $
272    , direc = direc, _extra = ex
273;------------------------------------------------------------
274;--------------------------------------------------------------
275; choice of labels
276;-----------------------------------------------------------
277  if keyword_set(intervalle) AND NOT keyword_set(label) then label = 1
278  if keyword_set(label) eq 0 then cas = 0 else cas = label
279  label, cas, min, max, ncontour, level_z2d, colnumb, NLEVEL = nlevel $
280         , INTERVALLE = intervalle, strictfill = strictfill
281;--------------------------------------------------------------
282; choice of style
283;-----------------------------------------------------------
284  if not keyword_set(style) then style = 0
285  style, style, level_z2d, linestyle, thick
286  if keyword_set(inv) then colnumb = reverse(colnumb)
287;-----------------------------------------------------------
288;   definition of axes
289;----------------------------------------------------------
290  if NOT keyword_set(overplot) THEN axe, type, SIN = sin, _EXTRA = ex
291  !y.range = [-1, 0]
292;--------------------------------------------------------------
293; extrapolation of datas on lands and specifying of the min/max value
294;--------------------------------------------------------------
295; define masknan
296  if keyword_set(nan) then BEGIN
297    masknan = finite(z2d)
298    z2d[where(masknan EQ 0)] = max
299  ENDIF ELSE masknan = 1
300  IF n_elements(fillxdir) EQ 0  THEN fillxdir = 1
301  IF keyword_set(fillxdir) THEN BEGIN
302; filling the mask values only in the x direction.
303    z2d = remplit(z2d, nite = nx*(1-(n_elements(maskfill) NE 0)) $
304                  , mask = mask*masknan, /basique $
305                  , /fillxdir, _extra = ex)
306; if some lines contains no field (the bottom line for ex) it must be
307; also filled with 8 neighbourg method
308    IF (where(total(mask*masknan, 1) EQ 0))[0] NE -1 THEN $
309      z2d = remplit(z2d, nite = 1-(n_elements(maskfill) NE 0) $
310                    , mask = z2d LT valmask/10, /basique, _extra = ex)
311  ENDIF ELSE BEGIN
312; filling the mask values with 8 neighbourg
313    z2d = remplit(z2d, nite = (1+(vargrid NE 'T')+keyword_set(nan)) $
314                  *(1-(n_elements(maskfill) NE 0)), mask = mask*masknan $
315                  , /basique, _extra = ex)
316  ENDELSE
317  if keyword_set(strictfill) EQ 0 AND n_elements(maskfill) EQ 0 $
318    then z2d = min > z2d <  max
319  if n_elements(maskfill) NE 0 then BEGIN
320    z2d = z2d*mask*masknan
321    if maskfill NE 0 then z2d = temporary(z2d) + maskfill*(1b-mask*masknan)
322  ENDIF
323;----------------------------------------------------------
324; check the mask and the triangulation according to the grid type and
325; nan values. find the coordinates of the mask
326;----------------------------------------------------------
327;   if (where(mask EQ 0))[0] EQ -1 AND NOT keyword_set(nan) then notri = 1
328;   if keyword_set(notri) then trifield = -1 $
329;   ELSE trifield = triangule(mask,/basic)
330  if (usetri GE 1 AND (vargrid EQ 'T' OR vargrid EQ 'W')) $
331    OR (usetri EQ 2 AND (vargrid NE 'T' AND vargrid NE 'W')) THEN $
332    trifield = triangule(mask, /basic)
333;
334  IF NOT keyword_set(endpoints)  THEN BEGIN
335    if keyword_set(nan) then trinan = triangule(masknan, /basic, coinmonte = coinmontenan, coindescend = coindescendnan)
336    maskorg = mask
337    decoupeterre, mask, glammsk, gphimsk, gdepmsk, type = type, WDEPTH = wdepth, REALSECTION = realsection
338    axis4pltz, type, mask, glammsk, gphimsk, gdepmsk, XXAXIS = xmask, ZZAXIS = zmask, SIN = sin, ZRATIO = zratio, ZOOM = zoom, PROFMAX = profmax, PROFMIN = profmin, _extra = ex
339  ENDIF ELSE BEGIN
340    xmask = xxaxis
341    zmask = zzaxis
342  ENDELSE
343;
344  if (usetri GE 1 AND (vargrid NE 'T' AND vargrid NE 'W')) THEN BEGIN
345    IF keyword_set(realsection) THEN trimsk = triangule(mask, /basic) $
346    ELSE trimsk = triangule(mask, /basic, coinmonte = coinmontemask $
347                            , coindescend = coindescendmask)
348  ENDIF
349;------------------------------------------------------------
350; dessin en lui meme
351;------------------------------------------------------------
352  IF n_elements(romszinfos) EQ 1 THEN BEGIN
353; add one line at bottom to have nicer plot (colors go until the ocean bottom)
354    IF n_elements(romszinfos.h) NE 1 THEN BEGIN
355      CASE type OF
356        'xz':romsh = moyenne(romszinfos.h, 'y')
357        'yz':romsh = moyenne(romszinfos.h, 'x')
358      ENDCASE
359      IF nzt EQ jpk THEN BEGIN
360        z2d = [[z2d], [z2d[*, jpk-1]]]
361        zzaxis = [[zzaxis], [romsh]]
362      ENDIF
363    ENDIF
364  ENDIF
365  pltbase, z2d, xxaxis, zzaxis, mask, xmask, zmask $
366    , level_z2d, colnumb, overplot = overplot $
367    , contour = contour, trichamp = trifield, trimsk = trimsk  $
368    , c_linestyle = linestyle $
369    , c_labels = 1-(indgen(n_elements(level_z2d)) MOD 2) $
370    , c_thick = thick, unsur2 = unsur2 $
371    , maskorg = maskorg, masknan = masknan, trinan = trinan $
372    , coinmontenan = coinmontenan, coindescendnan = coindescendnan $
373    , coinmontemask = coinmontemask, coindescendmask = coindescendmask $
374    , REALSECTION = realsection, USETRI = usetri, _extra = ex
375;------------------------------------------------------------
376; recall of pltz in loop when contour is activated
377;------------------------------------------------------------
378  if n_elements(contour) eq 4 then BEGIN ; It is the second time I pass in pltt
379    contour = {mietma:[mi, ma], unit:varunit, inter:intervalle} ; I send back the min, the max and the unity
380    return
381  endif
382  if keyword_set(contour) THEN BEGIN
383    pourlegende = [1, 1, 1, 1]
384    oldattributs = saveatt()
385    oldcolnumb = colnumb
386    pltz, contour, contmin, contmax, CONTOUR = pourlegende, ZRATIO = zratio $
387      , INTERVALLE = contintervalle, LABEL = contlabel, STYLE = style, /noerase  $
388      , NLEVEL = contnlevel, ZOOM = zoom, BOXZOOM = boxzoom, ENDPOINTS = endpoints $
389      , STRICTFILL = strictfill, REALSECTION = realsection, MASKFILL = maskfill $
390      , USETRI = usetri, WDEPTH = wdepth, _extra = ex
391    restoreatt, oldattributs
392    colnumb = oldcolnumb
393  ENDIF
394;------------------------------------------------------------
395;------------------------------------------------------------
396; 3rd part: drawing of the frame, caption, colorbar...
397;------------------------------------------------------------
398  if keyword_set(overplot) then BEGIN
399    !y.range =  [zoom, profmin] ; We get back on physic coordinates
400    plot, [0], [0], /nodata, /noerase, title = '', subtitle = '', xstyle = 5, ystyle = 5
401    GOTO, fini
402  endif
403;------------------------------------------------------------
404; Caption + display of them
405;------------------------------------------------------------
406  legende, mi, ma, type, CONTOUR = pourlegende, INTERVALLE = intervalle, DIREC = direc, endpoints = endpoints, _EXTRA = ex
407  if type eq 'yz' then xaxe = 'lataxe' else xaxe = 'lonaxe'
408  if keyword_set(sin) OR NOT key_onearth then xaxe = ''
409; Frame applied by default
410  plot, [xxaxis[0], xxaxis[n_elements(xxaxis)-1]], [-zratio, -zratio], /noerase $
411    , xstyle = 1+4*(keyword_set(endpoints) AND ((type EQ 'xz' AND lat1 NE lat2) OR (type EQ 'yz' AND lon1 NE lon2))) $
412    , xtickformat = xaxe, _extra = ex
413; Add of an axis in the case of we use endpoints
414  if keyword_set(endpoints) then addaxe, endpoints, type, posfenetre, _EXTRA = ex
415;------------------------------------------------------------
416; Y axis in 1 or 2 part
417;------------------------------------------------------------
418  if n_elements(ex) NE 0 then BEGIN
419; To do not put title anymore
420    if (where(tag_names(ex) EQ 'TITLE'))[0] NE -1 then ex.TITLE = ' '
421; To do not put subtitle anymore
422    if (where(tag_names(ex) EQ 'SUBTITLE'))[0] NE -1 then ex.SUBTITLE = ' '
423; To have just one ytitle
424    if (where(tag_names(ex) EQ 'YTITLE'))[0] NE -1 then BEGIN
425      ytitle = ex.YTITLE
426      ex.YTITLE = ' '
427    endif
428  ENDIF
429  htotal = posfenetre[3]-posfenetre[1]
430  hzoom = 1.*zratio*htotal
431  if zoom LT profmax then $
432    plot, [0], [0], /nodata, /noerase, ystyle = 1, yrange = [profmax, zoom+0.001] $
433    , position = posfenetre+[0, 0, 0, -hzoom], _extra = ex, title = '', subtitle = '', ytitle = ''
434;
435  !y.range =  [zoom, profmin]   ; We get back in physic coordinates!
436  plot, [0], [0], /nodata, /noerase, ystyle = 1, _extra = ex $
437    , title = '', subtitle = '', ytitle = '', position = posfenetre+[0, htotal-hzoom, 0, 0]
438;------------------------------------------------------------
439; to write the ytitle...
440;------------------------------------------------------------
441  if !d.name EQ 'PS' then $
442    xs = (max(page_size, min = mi)*(1-key_portrait) + mi*key_portrait)*!d.x_px_cm $
443  ELSE xs = !d.x_size
444  if n_elements(ytitle) NE 0 then !y.title = ytitle
445  charsize = chkstru(ex, 'ycharsize', /extract)
446  if charsize EQ -1 then charsize = !p.charsize
447  IF chkstru(ex, 'charsize') THEN ex.charsize = charsize
448  if chkstru(ex, 'ytitle', /extract) NE '' then $
449    decalage = string(format = '(e10.3)', profmax)
450  decalage = float(strmid(decalage, strpos(decalage, 'e')+1))
451  posy = posfenetre[1]+1.*htotal/2
452  posx = posfenetre[0]-(decalage+3)*!d.x_ch_size*charsize/xs
453  xyouts, posx, posy, !y.title, /normal, orientation = 90, color = 0, ALIGNMENT = .5, charsize = charsize, _extra = ex
454
455;------------------------------------------------------------
456; colorbar
457;------------------------------------------------------------
458  colnumb = colnumb[0:ncontour-1-keyword_set(strictfill)]
459  barrecouleur, colnumb, min,  max, (ncontour-keyword_set(strictfill))/2 $
460                , position = posbar, _extra = ex
461;------------------------------------------------------------
462;------------------------------------------------------------
463; 4th part: possible print
464;------------------------------------------------------------
465;------------------------------------------------------------
466fini:
467  terminedessin, _extra = ex
468;------------------------------------------------------------
469;------------------------------------------------------------
470;------------------------------------------------------------
471;------------------------------------------------------------
472sortie:
473  restoreboxparam, 'boxparam4pltz.dat'
474;
475  if keyword_set(key_performance) NE 0 THEN print, 'temps pltz', systime(1)-tempsun
476  return
477end
Note: See TracBrowser for help on using the repository browser.