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