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

Last change on this file since 142 was 142, checked in by navarro, 18 years ago

english and nicer header (2a)

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