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

Last change on this file since 293 was 293, 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
RevLine 
[2]1;+
2;
[142]3; @file_comments
[163]4; Trace 1d graphs: x,y,z (or t but in this case, we recall directly pltt)
[2]5;
[142]6; @categories
7; Graphics
[2]8;
[231]9; @param TAB {in}{required}
[142]10; The field whose we want to make the hovmoller map can be 2 kind of thing:
11;       1) An array which can be:
[231]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
[163]15;          it is about. To have a correct caption, respecify the  extraction zone via BOXZOOM.
[231]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)
[2]19;
[231]20; @param PARAM2 {in}{required}
[142]21; Min value we want to consider in the contour's drawing.
22; Note: could also be the type of plot:'x','y','z'
[231]23;
24; @param PARAM3 {in}{optional}{default=min/max of tab (on ocean points)}
[142]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)
[2]27;
[231]28; @param PARAM4 {in}{optional}{default=max of tab (on ocean points)}
[142]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)
[2]31;
[142]32; @keyword BOXZOOM
[231]33; Vector indicating the geographic zone (3d) on which the extraction of the field must
[142]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
[2]41;
[254]42; Where lon1, lon2,lat1,lat2,vert1,vert2 are global variables defined at the last
43; <pro>domdef</pro> !
[2]44;
[254]45; @keyword COL1D
[231]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.
[2]48;
[231]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.
[2]53;
[231]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.
[2]59;
[231]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.
[2]65;
[142]66; @keyword OV1D
67; Allow the double exposure of an 1d curve to a precedent 1d trace.
[2]68;
[231]69; @keyword REVERSE_X
[142]70; To invert the x axis (so as the drawing)
[2]71;
[231]72; @keyword REVERSE_Y
[142]73; To invert the y axis (so as the drawing)
[2]74;
[231]75; @keyword SIN
76; Activate this keyword if we want the x axis to be traced in sinus of the
[142]77; latitude when we make a drawing f(y)
[2]78;
[231]79; @keyword STY1D
[142]80; --OBSOLETE--
[231]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
[142]83; useful if we want to d bars instead of curves, put sty1d='bar'
[2]84;
[142]85; @keyword TYPEIN
86; allows to specify the type of hovmoller we want to do
[231]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
[142]90; keyword which is retained.
[2]91;
[231]92; @keyword _EXTRA
93; Used to pass keywords
[2]94;
[231]95; @history
96; creation 24/6/99 Eric Guilyardi
[142]97; (a partir routine pltt de Sebastien Masson)
[231]98; 8/7/1999 Sebastien Masson (smasson\@lodyc.jussieu.fr)
[2]99; inspection des travaux finis
100; 8/2/2000 Sebastien Masson: checkfield
[142]101;
[231]102; @version
[142]103; $Id$
104;
[2]105;-
[231]106;
107PRO plt1d, tab, param2, param3, param4, BOXZOOM = boxzoom, SIN = sin $
[35]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 $
[232]111           , _EXTRA = ex
[114]112;
113  compile_opt idl2, strictarrsubs
114;
[35]115@cm_4mesh
116@cm_4data
117  IF NOT keyword_set(key_forgetold) THEN BEGIN
118@updatenew
119@updatekwd
120  ENDIF
[2]121;------------------------------------------------------------
[35]122  tempsun = systime(1)          ; pour key_performance
[2]123;--------------------------------------------------------------
[142]124; 1st part: initialization small calculations...
[2]125;--------------------------------------------------------------
126;--------------------------------------------------------------
127;--------------------------------------------------------------
[142]128; verification of the type's value
[2]129;--------------------------------------------------------------
[35]130;
[142]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
[35]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'
[231]137  if keyword_set(typein) then BEGIN
[35]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 $
[231]146    , XX = keyword_set(x), YY = keyword_set(y), ZZ = keyword_set(z)
[35]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
[2]152;--------------------------------------------------------------
[142]153; I2) reinitialization. !p.,!x.,!y.
154; Comment: We do not reinitializate when we call back plt1d
[2]155;--------------------------------------------------------------
[35]156  if NOT keyword_set(ov1d) then reinitplt
[2]157;--------------------------------------------------------------
[142]158; I1) Reading of the field
[2]159;--------------------------------------------------------------
[35]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
[231]168    nx = n_elements(glam)
[35]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
[231]177  ENDIF ELSE BEGIN
[35]178    z1d = checkfield(tab, 'plt1d', TYPE = type, BOXZOOM = boxzoom $
179                     , direc = direc, _extra = ex)
[172]180    grille, mask, glam, gphi, gdep, nx, ny, nz, type = type
[35]181  ENDELSE
[251]182  if n_elements(z2d) EQ 1 AND z1d[0] EQ -1 then BEGIN
[35]183    IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat'
184    return
[142]185endif
[293]186; We build the mask. For this, the array must be hidden (Automatically done at valmask
[142]187; value if we pass in moyenne or grossemoyenne)
[35]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
[114]194    mask[where(z1d LT valmask/10)] = 1
[35]195    z1d[notanum] = !values.f_nan
[114]196  ENDIF ELSE mask[where(z1d LT valmask/10)] = 1
[2]197;-----------------------------------------------------------------------------
[142]198; determination of the min and of the max after the average
[2]199;-----------------------------------------------------------------------------
[35]200  nan = total(finite(z1d, /nan)) < 1
201  determineminmax, z1d, mask, mi, ma, MININ = min, MAXIN = max, nan = nan, INTERVALLE = intervalle, _extra = ex
[251]202  if n_elements(z2d) EQ 1 AND z1d[0] EQ -1 THEN return
[2]203;-----------------------------------------------------------------------------
204;-----------------------------------------------------------------------------
[35]205  if NOT keyword_set(ov1d) THEN placedessin, 'autre', posfenetre, posbar, contour = contour, DIREC = direc, endpoints = endpoints, _extra = ex
[2]206;--------------------------------------------------------------
207;--------------------------------------------------------------
[142]208; 2nd part: Drawing
[2]209;--------------------------------------------------------------
210;-----------------------------------------------------------------------------
[142]211; definition of the abscisse and ordinate vectors.
[231]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,
[142]214; from which some transpose and reverse
[2]215;-----------------------------------------------------------------------------
216;-----------------------------------------------------------------------------
[35]217  case type of
218    'y': begin
219      yy = z1d
[231]220      IF (size(gphi))[0] EQ 1 then xx = gphi ELSE BEGIN
221        IF keyword_set(key_irregular) THEN BEGIN
[74]222          cln = (where(gphi EQ max(gphi)))[0]
223          xx = reform(gphi[cln MOD nx, *])
224        ENDIF ELSE xx = reform(gphi[0, *])
225      ENDELSE
[35]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
[231]233    END
[35]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)
[231]247    END
248  ENDCASE
[2]249;-----------------------------------------------------------
250;-----------------------------------------------------------
[142]251;   definition of axes
[2]252;----------------------------------------------------------
253;    if keyword_set(integrationtps) then axe, type, time[0], time[jpt-1], SIN = sin, _extra = ex $
254;    ELSE axe, type, SIN = sin
[35]255  if NOT keyword_set(ov1d) then axe, type, SIN = sin
[2]256;------------------------------------------------------------
257;------------------------------------------------------------
[142]258; drawing
[2]259;------------------------------------------------------------
260;------------------------------------------------------------
[35]261  if type EQ 'z' then begin
262    idx = where(xx NE valmask)
[231]263    if NOT keyword_set(ov1d) then BEGIN
[35]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
[231]267  ENDIF ELSE BEGIN
[35]268    idx = where(yy NE valmask)
[231]269    if NOT keyword_set(ov1d) then BEGIN
[35]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
[231]273  ENDELSE
[2]274;
[231]275  if NOT keyword_set(ov1d) then BEGIN
[35]276    legende, mi, ma, type, CONTOUR = contour, DIREC = direc, ENDPOINTS = endpoints, _EXTRA = ex
[2]277;
[35]278  ENDIF
279  IF keyword_set(switchxy)  THEN BEGIN
280    tmp = xx
281    xx = yy
282    yy = temporary(tmp)
[231]283    if NOT keyword_set(ov1d) then BEGIN
[35]284      tmp = !x
285      !x = !y
286      !y = temporary(tmp)
287    ENDIF
288  ENDIF
[231]289  if NOT keyword_set(ov1d) then BEGIN
[35]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
[2]293;
[35]294  xx = xx[idx]
295  yy = yy[idx]
296  if (not keyword_set(col1d)) then col1d = 0
[142]297  if keyword_set(sty1d) then BEGIN ;If we want to make bars
[35]298    IF strlowcase(strtrim(sty1d)) EQ 'bar' then begin
[231]299      !y.range = [!y.range[0]-(!y.range[1]-!y.range[0])*.05, !y.range[1]]
[35]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
[231]303      if n_elements(ex) NE 0 then BEGIN
[142]304; To have a black frame
[35]305        if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0
[2]306      ENDIF
[35]307      plot, [0], [0], /noerase, /nodata, _extra = ex
308      GOTO, fini
[231]309    ENDIF
[35]310  ENDIF
311;
[231]312  if NOT keyword_set(ov1d) then BEGIN
[35]313;
314    plot, xx, yy, color = col1d, linestyle = sty1d, thick = 2, title = '', subtitle = '', _extra = ex
[231]315    if n_elements(ex) NE 0 then BEGIN
[142]316; To have a 0 colored frame and trace a line at y=0
[35]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
[142]325; Add of an axis in the case where we use endpoints
[35]326    if keyword_set(endpoints) then addaxe, endpoints, type, posfenetre, _EXTRA = ex
[142]327; Trace a line at x=0
[35]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
[2]330;------------------------------------------------------------
331;------------------------------------------------------------
[142]332; 3rd part: Possible print.
[2]333;------------------------------------------------------------
334;------------------------------------------------------------
335fini:
[35]336  terminedessin, _extra = ex
337  if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat'
[2]338;------------------------------------------------------------
[35]339  if n_elements(key_performance) NE 0 then $
[231]340    IF key_performance EQ 1 THEN print, 'temps plt1d', systime(1)-tempsun
[2]341;------------------------------------------------------------
342;------------------------------------------------------------
343;------------------------------------------------------------
[35]344  return
[2]345end
Note: See TracBrowser for help on using the repository browser.