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>, <pro>TV</pro>, <pro>AXE</pro>, <pro>LEGENDE</pro>, <pro>BARRECOULEUR</pro>, <pro>TERMINEDESSIN</pro> |
---|
58 | ; |
---|
59 | ; @examples |
---|
60 | ; IDL> tvplus, dist(100) |
---|
61 | ; |
---|
62 | ; @history |
---|
63 | ; Aug 2006: Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
64 | ; |
---|
65 | ; @version |
---|
66 | ; $Id$ |
---|
67 | ; |
---|
68 | ;- |
---|
69 | ; |
---|
70 | PRO pltv, data, min, max, BOTTOM = bottom, BOXZOOM = boxzoom $ |
---|
71 | , C_MASK = c_mask, C_NAN = c_nan, MININ = minin, MAXIN = maxin $ |
---|
72 | , MASKVAL = maskval, NCOLORS = ncolors, NOINTERP = nointerp $ |
---|
73 | , _EXTRA = ex |
---|
74 | ; |
---|
75 | compile_opt idl2, strictarrsubs |
---|
76 | ; |
---|
77 | @cm_general ; for key_performance |
---|
78 | ;-------------------------------------------------------------- |
---|
79 | tempsun = systime(1) ; for key_performance |
---|
80 | ;-------------------------------------------------------------- |
---|
81 | ;-------------------------------------------------------------- |
---|
82 | ; I2) Reading of the field and checkup. |
---|
83 | ;-------------------------------------------------------------- |
---|
84 | IF n_elements(minin) NE 0 THEN min = minin |
---|
85 | IF n_elements(maxin) NE 0 THEN max = maxin |
---|
86 | IF size(data, /type) NE 8 THEN z2d = reform(float(data)) ELSE z2d = data |
---|
87 | IF size(z2d, /n_dimensions) NE 2 then BEGIN |
---|
88 | if keyword_set(boxzoom) then BEGIN |
---|
89 | savedbox = 1b |
---|
90 | saveboxparam, 'boxparam4pltv.dat' |
---|
91 | ENDIF |
---|
92 | z2d = checkfield(temporary(z2d), 'plt', TYPE = 'xy', direc = direc, BOXZOOM = boxzoom) |
---|
93 | if n_elements(z2d) EQ 1 AND z2d[0] EQ -1 then BEGIN |
---|
94 | IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4pltv.dat' |
---|
95 | return |
---|
96 | ENDIF |
---|
97 | ENDIF |
---|
98 | dtasize = size(z2d, /dimensions) |
---|
99 | ;------------------------------------------------------------ |
---|
100 | ; def of ncolmax, bottom, topcol et ncolors |
---|
101 | ;------------------------------------------------------------ |
---|
102 | ncolmax = !d.n_colors < 256 |
---|
103 | IF n_elements(bottom) EQ 0 THEN bottom = 1 |
---|
104 | IF NOT keyword_set(ncolors) then ncolors = ncolmax - 1 - bottom |
---|
105 | topcol = (bottom + ncolors - 1) < (ncolmax - 1) |
---|
106 | ;------------------------------------------------------------ |
---|
107 | ; Do we have NaN values in z2d??? |
---|
108 | ;------------------------------------------------------------ |
---|
109 | msknan = finite(z2d, /nan) |
---|
110 | nan = total(msknan) |
---|
111 | IF keyword_set(nan) THEN nanind = where(temporary(msknan) EQ 1) |
---|
112 | ;------------------------------------------------------------ |
---|
113 | ; get the mask |
---|
114 | ;------------------------------------------------------------ |
---|
115 | IF n_elements(maskval) EQ 0 THEN maskval = 1.e20 |
---|
116 | IF abs(maskval) LT 1e6 THEN BEGIN |
---|
117 | IF keyword_set(nan) THEN z2d[nanind] = 1.e20 |
---|
118 | msk = z2d NE maskval |
---|
119 | ENDIF ELSE BEGIN |
---|
120 | IF keyword_set(nan) THEN z2d[nanind] = 0 |
---|
121 | msk = abs(z2d) LT abs(maskval)/10. |
---|
122 | ENDELSE |
---|
123 | maskind = where(msk EQ 0, masked) |
---|
124 | IF keyword_set(nan) THEN z2d[nanind] = !values.f_nan |
---|
125 | ;------------------------------------------------------------ |
---|
126 | ; get the real min/max and the user defined min/max of the array |
---|
127 | ;------------------------------------------------------------ |
---|
128 | determineminmax, z2d, msk, truemin, truemax, MININ = min, MAXIN = max, NAN = nan |
---|
129 | z2d = min > temporary(z2d) < max |
---|
130 | ;------------------------------------------------------------ |
---|
131 | ; apply other keywords (nointerp, c_nan, c_mask) |
---|
132 | ;------------------------------------------------------------ |
---|
133 | IF NOT keyword_set(nointerp) THEN BEGIN |
---|
134 | ; interpolation between bottom and bottom+ncolors-1 |
---|
135 | m = 1.*(ncolors-1)/(max-min) |
---|
136 | p = bottom - 1.*min*m |
---|
137 | z2d = m * temporary(z2d) + p |
---|
138 | ENDIF |
---|
139 | ; set c_nan for NaN values |
---|
140 | IF keyword_set(nan) THEN BEGIN |
---|
141 | IF n_elements(c_nan) NE 0 THEN cnan = 0 > c_nan < (ncolmax -1) ELSE cnan = (ncolmax -1) |
---|
142 | z2d[nanind] = cnan |
---|
143 | ENDIF |
---|
144 | ; c_mask for masked values |
---|
145 | IF keyword_set(masked) THEN BEGIN |
---|
146 | IF n_elements(c_mask) NE 0 THEN cmask = 0 > c_mask < (ncolmax - 1) ELSE cmask = (ncolmax -1) |
---|
147 | z2d[maskind] = cmask |
---|
148 | ENDIF |
---|
149 | z2d = round(temporary(z2d)) |
---|
150 | ; use byte type to save memory |
---|
151 | z2d = byte(temporary(z2d)) |
---|
152 | ;-------------------------------------------------------------- |
---|
153 | ; . |
---|
154 | ;-------------------------------------------------------------- |
---|
155 | if NOT keyword_set(overplot) then reinitplt, /z, /invert |
---|
156 | placedessin, 'pltv', posplot, posbar, dtasize, _extra = ex |
---|
157 | ;-------------------------------------------------------------- |
---|
158 | ; 3) Drawing |
---|
159 | ;-------------------------------------------------------------- |
---|
160 | |
---|
161 | xsize = !p.position[2] - !p.position[0] |
---|
162 | ysize = !p.position[3] - !p.position[1] |
---|
163 | IF !d.name EQ 'X' THEN BEGIN |
---|
164 | xsize = ceil(xsize * !d.x_size) |
---|
165 | ysize = ceil(ysize * !d.y_size) |
---|
166 | z2d = congrid(z2d, xsize, ysize) |
---|
167 | ENDIF |
---|
168 | |
---|
169 | tv, z2d, !p.position[0], !p.position[1] $ |
---|
170 | , xsize = xsize, ysize = ysize $ |
---|
171 | , /normal, _EXTRA = ex |
---|
172 | |
---|
173 | ;------------------------------------------------------------ |
---|
174 | ; caption + display of these. |
---|
175 | ;------------------------------------------------------------ |
---|
176 | axe, 'pltv', dtasize, _EXTRA = ex |
---|
177 | legende, truemin, truemax, 'plt', DIREC = direc $ |
---|
178 | , INTERVALLE = float(max-min)/(topcol-bottom) $ |
---|
179 | , _extra = ex |
---|
180 | plot, [0], [0], /noerase, /nodata, xstyle = 1, ystyle = 1 |
---|
181 | |
---|
182 | IF keyword_set(masked) THEN tracemask, msk, indgen(dtasize[0]), indgen(dtasize[1]) |
---|
183 | ;------------------------------------------------------------ |
---|
184 | ; color bar |
---|
185 | ;------------------------------------------------------------ |
---|
186 | barrecouleur, 0, min, max, 10, bottom = bottom, position = posbar, ncolors = (topcol-bottom+1), _extra = ex |
---|
187 | ; 4) End of drawing |
---|
188 | terminedessin, _extra=ex |
---|
189 | ; |
---|
190 | if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4pltv.dat' |
---|
191 | if keyword_set(key_performance) NE 0 THEN print, 'time pltv', systime(1)-tempsun |
---|
192 | ; |
---|
193 | return |
---|
194 | end |
---|