source: trunk/SRC/ToBeReviewed/PLOTS/DESSINE/pltv.pro @ 260

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

only uppercase between <proidl>...</proidl> in perspective of links to /usr/local_macosx/idl/idl_6.2/idl_6.2/

  • Property svn:keywords set to Id
File size: 7.4 KB
Line 
1;+
2;
3; @file_comments
4; Draw 2d plots with TV procedure
5;
6; @categories find a file
7; graphic
8;
9; @param DATA {in}{required}
10; The field we want to display can be:
11;    1) an array. If the array is not a 2D array, its mean along
12;       the z and t direction will be automatically performed
13;       (as it is done in plt).
14;    2) a structure respecting all criterions specified by
15;       <pro>litchamp</pro> cf. IDL> xhelp,'litchamp'
16;
17; @param MIN {in}{optional}{default=min of DATA (on non-masked points)}
18;
19; @param MAX {in}{optional}{default=max of DATA (on non-masked points)}
20;
21; @keyword BOTTOM {default=0}
22; The lowest color index of the colors to be used
23;
24; @keyword BOXZOOM
25; Vector indicating the geographic zone on which we want to cut the map.
26;  If BOXZOOM has :
27; 1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]]
28; 2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]]
29; 4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])]
30; 5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]]
31; 6 elements: The extraction is made on Boxzoom
32;
33; Where lon1, lon2, lat1, lat2 are global variables defined at the last
34; <pro>domdef</pro> !
35;
36; @keyword C_NAN {default=!d.n_colors < 255}
37; The color number that should be used for the NaN values.
38;
39; @keyword C_MASK {default=0}
40; The color number that should be used for the mask values.
41;
42; @keyword MASKVAL {default=1.e+20}
43; The mask value. Note that if abs(mask) < 1.e6, then the
44; exact value of the mask is used to find the maskwd point.
45; if abs(mask) > 1.e6, the test to find the masked value is ge
46; abs(mask)/10. This is necessary to avoid the rounding errors
47;
48; @keyword NCOLORS {default=(d.n_colors < 256) - 1 - BOTTOM}
49; number of colors to be used.
50;
51; @keyword NOINTERP
52; Used this keyword if you don't want that the values
53; are interpolated from BOTTOM using NCOLORS colors.
54; This can be for example useful when working on byte type arrays.
55;
56; @keyword _EXTRA
57; Used to pass keywords to <pro>placedessin</pro>, <proidl>TV</proidl>,
58; <pro>axe</pro>, <pro>legende</pro>, <pro>barrecouleur</pro>,
59; <pro>terminedessin</pro>
60;
61; @examples
62; IDL> tvplus, dist(100)
63;
64; @history
65; Aug 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr)
66;
67; @version
68; $Id$
69;
70;-
71;
72PRO pltv, data, min, max, BOTTOM = bottom, BOXZOOM = boxzoom $
73          , C_MASK = c_mask, C_NAN = c_nan, MININ = minin, MAXIN = maxin $
74          , MASKVAL = maskval, NCOLORS = ncolors, NOINTERP = nointerp $
75          , _EXTRA = ex
76;
77  compile_opt idl2, strictarrsubs
78;
79  @cm_general ; for key_performance
80;--------------------------------------------------------------
81  tempsun = systime(1)          ; for key_performance
82;--------------------------------------------------------------
83;--------------------------------------------------------------
84; I2) Reading of the field and checkup.
85;--------------------------------------------------------------
86  IF n_elements(minin) NE 0 THEN min = minin
87  IF n_elements(maxin) NE 0 THEN max = maxin
88  IF size(data, /type) NE 8 THEN z2d = reform(float(data)) ELSE z2d = data
89  IF size(z2d, /n_dimensions) NE 2 then BEGIN
90    if keyword_set(boxzoom) then BEGIN
91      savedbox = 1b
92      saveboxparam, 'boxparam4pltv.dat'
93    ENDIF
94    z2d = checkfield(temporary(z2d), 'plt', TYPE = 'xy', direc = direc, BOXZOOM = boxzoom)
95    if n_elements(z2d) EQ 1 AND z2d[0] EQ -1 then BEGIN
96      IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4pltv.dat'
97      return
98    ENDIF
99  ENDIF
100  dtasize = size(z2d, /dimensions)
101;------------------------------------------------------------
102; def of ncolmax, bottom, topcol et ncolors
103;------------------------------------------------------------
104  ncolmax = !d.n_colors < 256
105  IF n_elements(bottom) EQ 0 THEN bottom = 1
106  IF NOT keyword_set(ncolors) then ncolors = ncolmax - 1 - bottom
107  topcol = (bottom + ncolors - 1) < (ncolmax - 1)
108;------------------------------------------------------------
109; Do we have NaN values in z2d???
110;------------------------------------------------------------
111  msknan = finite(z2d, /nan)
112  nan = total(msknan)
113  IF keyword_set(nan) THEN nanind = where(temporary(msknan) EQ 1)
114;------------------------------------------------------------
115; get the mask
116;------------------------------------------------------------
117  IF n_elements(maskval) EQ 0 THEN maskval = 1.e20
118  IF abs(maskval) LT 1e6 THEN BEGIN
119    IF keyword_set(nan) THEN z2d[nanind] = 1.e20
120    msk = z2d NE maskval
121  ENDIF ELSE BEGIN
122    IF keyword_set(nan) THEN z2d[nanind] = 0
123    msk = abs(z2d) LT abs(maskval)/10.
124  ENDELSE
125  maskind = where(msk EQ 0, masked)
126  IF keyword_set(nan) THEN z2d[nanind] = !values.f_nan
127;------------------------------------------------------------
128; get the real min/max and the user defined min/max of the array
129;------------------------------------------------------------
130  determineminmax, z2d, msk, truemin, truemax, MININ = min, MAXIN = max, NAN = nan
131  z2d = min > temporary(z2d) < max
132;------------------------------------------------------------
133; apply other keywords (nointerp, c_nan, c_mask)
134;------------------------------------------------------------
135  IF NOT keyword_set(nointerp) THEN BEGIN
136; interpolation between bottom and bottom+ncolors-1
137    m = 1.*(ncolors-1)/(max-min)
138    p = bottom - 1.*min*m
139    z2d = m * temporary(z2d) + p
140  ENDIF
141; set c_nan for NaN values
142  IF keyword_set(nan) THEN BEGIN
143    IF n_elements(c_nan) NE 0 THEN cnan = 0 > c_nan < (ncolmax -1) ELSE cnan = (ncolmax -1)
144    z2d[nanind] = cnan
145  ENDIF
146; c_mask for masked values
147  IF keyword_set(masked) THEN BEGIN
148    IF n_elements(c_mask) NE 0 THEN cmask = 0 > c_mask < (ncolmax - 1) ELSE cmask = (ncolmax -1)
149    z2d[maskind] = cmask
150  ENDIF
151  z2d = round(temporary(z2d))
152; use byte type to save memory
153  z2d = byte(temporary(z2d))
154;--------------------------------------------------------------
155; .
156;--------------------------------------------------------------
157  if NOT keyword_set(overplot) then reinitplt, /z, /invert
158  placedessin, 'pltv', posplot, posbar, dtasize, _extra = ex
159;--------------------------------------------------------------
160; 3) Drawing
161;--------------------------------------------------------------
162
163   xsize = !p.position[2] - !p.position[0]
164   ysize = !p.position[3] - !p.position[1]
165   IF !d.name EQ 'X' THEN BEGIN
166     xsize = ceil(xsize * !d.x_size)
167     ysize = ceil(ysize * !d.y_size)
168     z2d = congrid(z2d, xsize, ysize)
169   ENDIF
170
171   tv, z2d, !p.position[0], !p.position[1] $
172       , xsize = xsize, ysize = ysize $
173       , /normal, _EXTRA = ex
174
175;------------------------------------------------------------
176;  caption + display of these.
177;------------------------------------------------------------
178   axe, 'pltv', dtasize, _EXTRA = ex
179   legende, truemin, truemax, 'plt', DIREC = direc $
180            , INTERVALLE = float(max-min)/(topcol-bottom) $
181            , _extra = ex
182   plot, [0], [0], /noerase, /nodata, xstyle = 1, ystyle = 1
183
184   IF keyword_set(masked) THEN tracemask, msk, indgen(dtasize[0]), indgen(dtasize[1])
185;------------------------------------------------------------
186; color bar
187;------------------------------------------------------------
188   barrecouleur, 0, min,  max, 10, bottom = bottom, position = posbar, ncolors = (topcol-bottom+1), _extra = ex
189; 4) End of drawing
190   terminedessin, _extra=ex
191;
192  if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4pltv.dat'
193  if keyword_set(key_performance) NE 0 THEN print, 'time pltv', systime(1)-tempsun
194;
195   return
196end
Note: See TracBrowser for help on using the repository browser.