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