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

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

corrections of some misspellings in some *.pro

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