1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Overlayer contour to trace a field which can be mask. |
---|
5 | ; Elementary brick of <pro>plt</pro>, <pro>pltz</pro> and <pro>pltt</pro>. |
---|
6 | ; |
---|
7 | ; @categories |
---|
8 | ; Graphics |
---|
9 | ; |
---|
10 | ; @param Z2D {in}{required} |
---|
11 | ; The table to trace |
---|
12 | ; |
---|
13 | ; @param X {in}{required} |
---|
14 | ; Axis. Vector or array of the same size that z2d. This is the coordinate of z2d on x. |
---|
15 | ; |
---|
16 | ; @param Y {in}{required} |
---|
17 | ; Axis. Vector or array of the same size that z2d. This is the coordinate of z2d on y. |
---|
18 | ; |
---|
19 | ; @param MASK {in}{required}{type=array} |
---|
20 | ; It is the array who mask z2d (with 0s on points we want to mask and 1s on others). |
---|
21 | ; If z2d is not masked, put this argument equal to 1. |
---|
22 | ; |
---|
23 | ; @param XM {in}{required} |
---|
24 | ; Axis of the mask. Vector or array of the same size that mask. |
---|
25 | ; This is the coordinate of mask on x. |
---|
26 | ; |
---|
27 | ; @param YM {in}{required} |
---|
28 | ; Axis of the mask. Vector or array of the same size that mask. |
---|
29 | ; This is the coordinate of mask on y. |
---|
30 | ; |
---|
31 | ; @param LEVELS {in}{optional}{type=vector} |
---|
32 | ; Vectors which contain levels needed at the contour. |
---|
33 | ; If it is not given, we take 20 levels between the min and the max. |
---|
34 | ; |
---|
35 | ; @param COLORS {in}{optional}{type=vector} |
---|
36 | ; Vectors which contain colors needed at the contour. |
---|
37 | ; If it is not given, we take 20 levels between the min and the max. |
---|
38 | ; |
---|
39 | ; @keyword COLORTRICHAMP |
---|
40 | ; The color we want to use to draw the triangulation which is used to make contours of the field. |
---|
41 | ; |
---|
42 | ; @keyword COLORTRIMASK |
---|
43 | ; The color we want to use to draw the triangulation which is used to make contours of the mask. |
---|
44 | ; |
---|
45 | ; @keyword COLOR_C |
---|
46 | ; To draw the contour in color instead of in black |
---|
47 | ; with filling in color |
---|
48 | ; |
---|
49 | ; @keyword CONT_NOFILL |
---|
50 | ; Activate it not to fill the point mask to let them transparent! |
---|
51 | ; Comment: Nevertheless, we trace mask's contour. |
---|
52 | ; |
---|
53 | ; @keyword CONT_COLOR {default= (!d.n_colors - 1) < 255 =>white} |
---|
54 | ; The color of the continent. |
---|
55 | ; |
---|
56 | ; @keyword DESSTRICHAMP |
---|
57 | ; To draw the triangulation which is used to make field's contours. |
---|
58 | ; |
---|
59 | ; @keyword DESSTRIMASK |
---|
60 | ; To draw the triangulation which is used to make mask's contours. |
---|
61 | ; |
---|
62 | ; @keyword FORPLT |
---|
63 | ; To activate if we want that the drawing of coast be realized by <pro>tracecote</pro> rather than <pro>tracemask</pro>. |
---|
64 | ; |
---|
65 | ; @keyword I_COLORS {type=vector} |
---|
66 | ; It is a vector specifying the colors to use to trace contours. |
---|
67 | ; It is the same thing that c_colors which act on contours. |
---|
68 | ; |
---|
69 | ; @keyword MORE {default=10} |
---|
70 | ; Number to give to avoid style's bugs: |
---|
71 | ; % Out of range subscript encountered: <LONG Array[38911]>. |
---|
72 | ; % Execution halted at: PLTBASE 151 |
---|
73 | ; If the bug still exist, increase the value of more! |
---|
74 | ; (The explanation and the justification of this method do not have scientific bases yet...). |
---|
75 | ; |
---|
76 | ; @keyword NOFILL |
---|
77 | ; To make just isolines with no filling |
---|
78 | ; |
---|
79 | ; @keyword NOCONTOUR |
---|
80 | ; To make just colors. |
---|
81 | ; |
---|
82 | ; @keyword CONTSTRIDE {type=integer} {default=1} |
---|
83 | ; To trace one isoline every contstride. |
---|
84 | ; |
---|
85 | ; @keyword UNSUR2 |
---|
86 | ; Obsolete. use CONTSTRIDE = 2 |
---|
87 | ; |
---|
88 | ; @keyword UNLABSUR {type=integer} |
---|
89 | ; I specify we only label one contour on two. |
---|
90 | ; |
---|
91 | ; @keyword CONTOUR |
---|
92 | ; To be used since <pro>plt</pro>, <pro>pltz</pro> or <pro>pltt</pro>. (Have a look on these routines). |
---|
93 | ; |
---|
94 | ; @keyword _EXTRA |
---|
95 | ; Used to pass keywords |
---|
96 | ; |
---|
97 | ; @uses |
---|
98 | ; <pro>common</pro> |
---|
99 | ; |
---|
100 | ; @restrictions |
---|
101 | ; In the case of z2d, x and y are arrays of same size, we have to put them as vectors: z2d[*], x[*], y[*]. |
---|
102 | ; |
---|
103 | ; @history |
---|
104 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
105 | ; ???? |
---|
106 | ; 8/2/2000 check if the tri array is not equal to |
---|
107 | ; -1. allow contour without using a triangulation. |
---|
108 | ; |
---|
109 | ; @version |
---|
110 | ; $Id$ |
---|
111 | ; |
---|
112 | ; @todo seb L.172 à 173 |
---|
113 | ; |
---|
114 | ;- |
---|
115 | PRO pltbase, z2d, x, y, mask, xm, ym, levels, colors $ |
---|
116 | , UNSUR2=unsur2, CONTSTRIDE = contstride, CONTOUR=contour $ |
---|
117 | , NOCONTOUR=nocontour, NOFILL=nofill $ |
---|
118 | , TRICHAMP=trichamp, TRIMSK=trimsk $ |
---|
119 | , REALCONT=realcont, NAN=nan, USETRI=usetri $ |
---|
120 | , COLORTRICHAMP=colortrichamp, COLORTRIMASK=colortrimask $ |
---|
121 | , COLORTRINAN=colortrinan $ |
---|
122 | , COLORPOINTS=colorpoints, DRAWPOINTS=drawpoints $ |
---|
123 | , TH_TRICHAMP=th_trichamp, TH_TRIMASK=th_trimask $ |
---|
124 | , DESSTRICHAMP=desstrichamp, DESSTRIMASK=desstrimask $ |
---|
125 | , DESSTRINAN=desstrinan, COLOR_C=color_c $ |
---|
126 | , I_COLORS=i_colors, CONT_COLOR=CONT_COLOR $ |
---|
127 | , CONT_NOFILL=cont_nofill, UNLABSUR=unlabsur $ |
---|
128 | , COINMONTEMASK=coinmontemask, COINDESCENDMASK=coindescendmask $ |
---|
129 | , COINMONTENAN=coinmontenan, COINDESCENDNAN=coindescendnan $ |
---|
130 | , INDICEZOOMMASK=indicezoommask, INDICEZOOMNAN=indicezoomnan $ |
---|
131 | , MASKORG=maskorg, MASKNAN=masknan, TRINAN=trinan $ |
---|
132 | , FORPLT=forplt, REALSECTION=realsection $ |
---|
133 | , MORE=more, EXCHANGE_XY=exchange_xy $ |
---|
134 | , _EXTRA=ex |
---|
135 | ; |
---|
136 | compile_opt idl2, strictarrsubs |
---|
137 | ; |
---|
138 | @cm_4mesh |
---|
139 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
140 | @updatenew |
---|
141 | @updatekwd |
---|
142 | ENDIF |
---|
143 | ;--------------------------------------------------------- |
---|
144 | ; |
---|
145 | ; Explanation concerning contour. This keyword is activated when we trace a |
---|
146 | ; colored contour different from the one with black trait. |
---|
147 | ; If it is activated (case n_elements(contour) NE 0), we pass 2 time in pltbase: |
---|
148 | ; 1) We trace colors then we leave, it is the case: |
---|
149 | ; n_elements(contour) NE 0 AND n_elements(contour) NE 4) |
---|
150 | ; 2) We trace contours in traits then continents, it is the case: |
---|
151 | ; n_elements(contour) NE 0 AND n_elements(contour) EQ 4) |
---|
152 | ; |
---|
153 | ;------------------------------------------------------------ |
---|
154 | tempsun = systime(1) ; To key_performance |
---|
155 | if n_elements(mask) EQ 0 then mask = 1b |
---|
156 | if n_elements(masknan) EQ 0 then masknan = 1b |
---|
157 | IF total(mask) EQ n_elements(z2d) THEN mask = 1b |
---|
158 | ;---------------------------------------------------------------------- |
---|
159 | ; If levels and colors aren't given |
---|
160 | ;---------------------------------------------------------------------- |
---|
161 | if n_params() EQ 4 then $ |
---|
162 | label, 0, min(z2d*mask), max(z2d*mask), ncontour, levels, colors |
---|
163 | ; attention bidouille inexplicable pour que tout se passe bien avec les |
---|
164 | ; postcript ds pltz!!! |
---|
165 | if n_elements(contour) LE 4 AND !x.type EQ 0 THEN $ |
---|
166 | plot, [0], [0], xstyle = 5, ystyle = 5, /nodata, /noerase, title = '', subtitle = '' |
---|
167 | ;---------------------------------------------------------------------- |
---|
168 | ; Is cell_fill is a part of _extra, we desactive it if it is nt equal to 2 |
---|
169 | ;---------------------------------------------------------------------- |
---|
170 | IF chkstru(ex, 'CELL_FILL') THEN BEGIN |
---|
171 | cell_fill = ex.CELL_FILL |
---|
172 | if ex.CELL_FILL NE 2 then ex.CELL_FILL = 0 |
---|
173 | ENDIF ELSE cell_fill = 0 ; |
---|
174 | ;---------------------------------------------------------------------- |
---|
175 | ; I) Filling contours with colors |
---|
176 | ;---------------------------------------------------------------------- |
---|
177 | if NOT keyword_set(more) then more = 10 |
---|
178 | if NOT keyword_set(nofill) AND NOT keyword_set(color_c) then begin |
---|
179 | if n_elements(contour) NE 4 THEN BEGIN |
---|
180 | if usetri EQ 2 then BEGIN |
---|
181 | IF size(x, /n_dimensions) EQ 1 THEN x = x#replicate(1, (size(z2d))[2]) |
---|
182 | IF size(y, /n_dimensions) EQ 1 THEN y = replicate(1, (size(z2d))[1])#y |
---|
183 | contour, [z2d[*], fltarr(more)], [x[*], fltarr(more)] $ |
---|
184 | , [y[*], fltarr(more)], levels = levels, c_color = colors $ |
---|
185 | , /noerase, /fill, TRIANGULATION = trichamp, _extra = ex |
---|
186 | ENDIF ELSE BEGIN |
---|
187 | IF size(x, /n_dimensions) EQ 2 THEN x = x[*, 0] |
---|
188 | IF size(y, /n_dimensions) EQ 2 THEN y = reform(y[0, *]) |
---|
189 | contour, z2d, x, y, levels = levels, c_color = colors, /noerase $ |
---|
190 | , /fill, _extra = ex |
---|
191 | ENDELSE |
---|
192 | ENDIF |
---|
193 | ENDIF |
---|
194 | if n_elements(contour) NE 0 AND n_elements(contour) NE 4 THEN GOTO, fini |
---|
195 | IF chkstru(ex, 'C_ORIENTATION') THEN ex = extractstru(ex, 'C_ORIENTATION') |
---|
196 | IF chkstru(ex, 'C_SPACING') THEN ex = extractstru(ex, 'C_SPACING') |
---|
197 | IF chkstru(ex, 'C_COLORS') THEN ex = extractstru(ex, 'C_COLORS') |
---|
198 | ;------------------------------------------------------------ |
---|
199 | ; II) Drawing contours with lines |
---|
200 | ;------------------------------------------------------------ |
---|
201 | if n_elements(contour) EQ 4 OR n_elements(contour) EQ 0 THEN BEGIN |
---|
202 | ; |
---|
203 | ; we put the masked values to NaN |
---|
204 | ; |
---|
205 | IF (n_elements(mask) GT 1 OR n_elements(masknan) GT 1) $ |
---|
206 | AND NOT keyword_set(cont_nofill) THEN BEGIN |
---|
207 | IF keyword_set(maskorg) THEN tonan = maskorg*masknan ELSE tonan = mask*masknan |
---|
208 | tonan = where(remplit(tonan, nite = 1, mask = tonan $ |
---|
209 | , /basique, fillval = 0 $ |
---|
210 | , fillxdir = keyword_set(realsection)) EQ 0, count) |
---|
211 | IF count NE 0 THEN z2d[temporary(tonan)] = !values.f_nan |
---|
212 | ENDIF |
---|
213 | ; |
---|
214 | ; We do not pass if we have to make differents contours... |
---|
215 | ; In the case of unsur2 is activated, we reduce levels |
---|
216 | if NOT keyword_set(nocontour) then begin |
---|
217 | IF keyword_set(unsur2) THEN levels = levels[where(zeroun(n_elements(levels) ) eq 1)] |
---|
218 | IF keyword_set(contstride) THEN levels = levels[where((indgen(n_elements(levels)) MOD contstride) eq 0)] |
---|
219 | ; Is unlabsur activated? Does C_LABEL passed via _EXTRA? |
---|
220 | if keyword_set(unlabsur) THEN IF chkstru(ex, 'C_LABELS') THEN $ |
---|
221 | ex.C_LABELS = 1-((indgen(n_elements(ex.C_LABELS)) MOD unlabsur) < 1) |
---|
222 | ; |
---|
223 | ; Not to fill when cell_fill is imposed... |
---|
224 | IF chkstru(ex, 'CELL_FILL') THEN ex.CELL_FILL = 0 |
---|
225 | ; |
---|
226 | CASE 1 OF |
---|
227 | keyword_set(color_c):c_colors = colors |
---|
228 | keyword_set(i_colors):c_colors = i_colors |
---|
229 | ELSE: |
---|
230 | ENDCASE |
---|
231 | ; |
---|
232 | IF usetri EQ 2 THEN BEGIN |
---|
233 | IF size(x, /n_dimensions) EQ 1 THEN x = x#replicate(1, (size(z2d))[2]) |
---|
234 | IF size(y, /n_dimensions) EQ 1 THEN y = replicate(1, (size(z2d))[1])#y |
---|
235 | contour, [z2d[*], fltarr(more)], [x[*], fltarr(more)] $ |
---|
236 | , [y[*], fltarr(more)], levels = levels $ |
---|
237 | , overplot = 1-keyword_set(nofill), noerase = keyword_set(nofill) $ |
---|
238 | , c_colors = c_colors, TRIANGULATION = trichamp, _extra = ex |
---|
239 | ENDIF ELSE BEGIN |
---|
240 | IF size(x, /n_dimensions) EQ 2 THEN x = x[*, 0] |
---|
241 | IF size(y, /n_dimensions) EQ 2 THEN y = reform(y[0, *]) |
---|
242 | contour, z2d, x, y, levels = levels $ |
---|
243 | , overplot = 1-keyword_set(nofill), noerase = keyword_set(nofill) $ |
---|
244 | , c_colors = c_colors, _extra = ex |
---|
245 | ENDELSE |
---|
246 | ENDIF |
---|
247 | ;---------------------------------------------------------------------- |
---|
248 | ; III) Filling continents with color |
---|
249 | ;---------------------------------------------------------------------- |
---|
250 | IF chkstru(ex, 'CELL_FILL') THEN ex.CELL_FILL = cell_fill < 1 |
---|
251 | IF chkstru(ex, 'LEVELS') THEN ex = extractstru(ex, 'LEVELS') |
---|
252 | IF chkstru(ex, 'NODATA') THEN ex = extractstru(ex, 'NODATA') |
---|
253 | IF NOT keyword_set(cont_color) THEN cont_color = (!d.n_colors-1) < 255 |
---|
254 | ; |
---|
255 | ; If there is points at NaN |
---|
256 | ; We trace points in white at NaN before drawing coasts with a trait. |
---|
257 | ; |
---|
258 | if keyword_set(trinan) AND NOT keyword_set(nofill) THEN BEGIN |
---|
259 | IF size(x, /n_dimensions) EQ 1 THEN x = x#replicate(1, (size(masknan))[2]) |
---|
260 | IF size(y, /n_dimensions) EQ 1 THEN y = replicate(1, (size(masknan))[1])#y |
---|
261 | contour, [1b-masknan[*], fltarr(more)], [x[*], fltarr(more)] $ |
---|
262 | , [y[*], fltarr(more)], levels = 0.5, /overplot, /fill $ |
---|
263 | , c_colors = cont_color, TRIANGULATION = trinan, _extra = ex |
---|
264 | IF keyword_set(forplt) THEN $ |
---|
265 | completecointerre, COINMONTE = coinmontenan $ |
---|
266 | , COINDESCEND = coindescendnan, INDICEZOOM = indicezoomnan $ |
---|
267 | , CONT_COLOR = cont_color, _EXTRA = ex $ |
---|
268 | ELSE fillcornermask, x[*, 0], y[0, *], COINMONTE = coinmontenan $ |
---|
269 | , COINDESCEND = coindescendnan, CONT_COLOR = cont_color, _extra = ex |
---|
270 | ENDIF |
---|
271 | ; |
---|
272 | ; Filling continents |
---|
273 | ; |
---|
274 | if keyword_set(realcont) then if realcont EQ 1 then mask = 1b |
---|
275 | if n_elements(mask) NE 1 then BEGIN ; If mask=1 we gap it. |
---|
276 | ; |
---|
277 | if NOT keyword_set(cont_nofill) then BEGIN |
---|
278 | ; |
---|
279 | ; mask filling |
---|
280 | ; |
---|
281 | case 1 of |
---|
282 | keyword_set(realsection):drawsectionbottom, mask, xm, ym $ |
---|
283 | , CONT_NOFILL = cont_nofill, CONT_COLOR = cont_color, _EXTRA = ex |
---|
284 | usetri GE 1:BEGIN |
---|
285 | if n_elements(trimsk) eq 0 then trimsk = trichamp |
---|
286 | IF size(xm, /N_DIMENSIONS) EQ 1 THEN xm = xm#replicate(1, (size(mask))[2]) |
---|
287 | IF size(ym, /N_DIMENSIONS) EQ 1 THEN ym = replicate(1, (size(mask))[1])#ym |
---|
288 | contour, [1b-mask[*], fltarr(more)], [xm[*], fltarr(more)] $ |
---|
289 | , [ym[*], fltarr(more)], LEVELS = 0.5, /OVERPLOT, /FILL $ |
---|
290 | , C_COLORS = cont_color, TRIANGULATION = trimsk, _extra = ex |
---|
291 | IF keyword_set(forplt) THEN $ |
---|
292 | completecointerre, COINMONTE = coinmontemask $ |
---|
293 | , COINDESCEND = coindescendmask, INDICEZOOM = indicezoommask $ |
---|
294 | , CONT_COLOR = cont_color, _EXTRA = ex $ |
---|
295 | ELSE fillcornermask, xm[*, 0], ym[0, *], COINMONTE = coinmontemask $ |
---|
296 | , COINDESCEND = coindescendmask, CONT_COLOR = cont_color, _extra = ex |
---|
297 | END |
---|
298 | ELSE:BEGIN |
---|
299 | IF size(xm, /n_dimensions) EQ 2 THEN xm = xm[*, 0] |
---|
300 | IF size(ym, /n_dimensions) EQ 2 THEN ym = reform(ym[0, *]) |
---|
301 | contour, 1b-mask, xm, ym, LEVELS = 0.5, /OVERPLOT $ |
---|
302 | , /FILL, C_COLORS = cont_color, _EXTRA = ex |
---|
303 | END |
---|
304 | ENDCASE |
---|
305 | ENDIF ; NOT keyword_set(cont_nofill) |
---|
306 | ;------------------------------------------------------------ |
---|
307 | ; IV) Trace coast with line |
---|
308 | ;------------------------------------------------------------ |
---|
309 | case 1 of |
---|
310 | keyword_set(realsection) AND NOT keyword_set(cont_nofill): |
---|
311 | keyword_set(realsection) AND keyword_set(cont_nofill): $ |
---|
312 | drawsectionbottom, mask, xm, ym $ |
---|
313 | , CONT_NOFILL = cont_nofill, _extra = ex |
---|
314 | (keyword_set(forplt) AND (!map.projection GT 0 OR key_irregular)) $ |
---|
315 | OR keyword_set(nan):tracecote, _extra = ex |
---|
316 | ELSE:tracemask, mask, xm, ym, _extra = ex |
---|
317 | endcase ; |
---|
318 | ENDIF ; n_elements(mask) NE 1 |
---|
319 | ENDIF |
---|
320 | ;------------------------------------------------------------ |
---|
321 | ; draw the triangulations |
---|
322 | ;------------------------------------------------------------ |
---|
323 | if keyword_set(desstrichamp) then $ |
---|
324 | dessinetri, trichamp, x, y, color = colortrichamp, thick = th_trichamp |
---|
325 | if keyword_set(desstrimask) then $ |
---|
326 | dessinetri, trimsk, xm, ym, color = colortrimask, thick = th_trimask |
---|
327 | if keyword_set(desstrinan) then $ |
---|
328 | dessinetri, trinan, x, y, color = colortrinan |
---|
329 | if keyword_set(drawpoints) then $ |
---|
330 | tracegrille, x, y, color = colorpoints |
---|
331 | ;------------------------------------------------------------ |
---|
332 | ; |
---|
333 | fini: |
---|
334 | IF keyword_set(key_performance) THEN print, 'temps pltbase', systime(1)-tempsun |
---|
335 | |
---|
336 | return |
---|
337 | end |
---|