[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[231] | 3 | ; @file_comments |
---|
[264] | 4 | ; Draw horizontal graph (map) with <proidl>CONTOUR</proidl> procedure |
---|
[2] | 5 | ; |
---|
[231] | 6 | ; @categories |
---|
[157] | 7 | ; Graphics |
---|
[2] | 8 | ; |
---|
[231] | 9 | ; @param TAB1 {in}{required} |
---|
[152] | 10 | ; The field whose we want to make the horizontal map can be: |
---|
[67] | 11 | ; 1) an array. if needed, its mean along the z and t direction |
---|
| 12 | ; will be automatically performed. |
---|
[142] | 13 | ; 2) a structure respecting all criterions specified by |
---|
[378] | 14 | ; <pro>litchamp</pro> |
---|
[231] | 15 | ; |
---|
| 16 | ; @param PARAM2 {in}{optional}{default=min of tab1 (on ocean points)} |
---|
[142] | 17 | ; Min value we want to consider in the contour's drawing. |
---|
| 18 | ; Note: Could also be the type of plot that can be only 'xy' for plt |
---|
[2] | 19 | ; |
---|
[231] | 20 | ; @param PARAM3 {in}{optional}{default=max of tab1 (on ocean points)} |
---|
[142] | 21 | ; Max value we want to consider in the contour's drawing. |
---|
| 22 | ; Note: if param2 is defined as 'xy' then param3 is used to define the min (see param2) |
---|
[2] | 23 | ; |
---|
[231] | 24 | ; @param PARAM4 {in}{optional}{default='xy'} |
---|
[142] | 25 | ; Type of plot (can be only 'xy' for plt). |
---|
| 26 | ; Note: if param2 is defined as 'xy' then param4 is used to define the max (see param3) |
---|
[2] | 27 | ; |
---|
[163] | 28 | ; @keyword BOXZOOM {type=vector} |
---|
[231] | 29 | ; Vector indicating the geographic zone on which we want to cut the map. |
---|
[142] | 30 | ; If BOXZOOM has : |
---|
| 31 | ; 1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]] |
---|
| 32 | ; 2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]] |
---|
| 33 | ; 4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])] |
---|
| 34 | ; 5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]] |
---|
| 35 | ; 6 elements: The extraction is made on Boxzoom |
---|
[2] | 36 | ; |
---|
[264] | 37 | ; Where lon1, lon2, lat1, lat2 are global variables defined at the last |
---|
[254] | 38 | ; <pro>domdef</pro> ! |
---|
[2] | 39 | ; |
---|
[231] | 40 | ; @keyword REALCONT |
---|
[264] | 41 | ; Allow to draw continents defined in IDL. REALCONT can have 2 forms: |
---|
[163] | 42 | ; /REALCONT: we draw continents in place of the mask |
---|
[231] | 43 | ; REALCONT=2 we draw continent's contour over the mask (this allows |
---|
[142] | 44 | ; to see if the mask correspond at real continents). |
---|
[2] | 45 | ; |
---|
[231] | 46 | ; @keyword CONTINTERVALLE |
---|
| 47 | ; When CONTOUR is activated, it is the value between 2 isolines |
---|
| 48 | ; traced by a trait. So it can be different from the one specified by INTERVALLE which, |
---|
| 49 | ; in this case, does not control colored isolines in color anymore. If there is noone |
---|
| 50 | ; specified min, we choose a contour min which goes well with the specified interval! |
---|
| 51 | ; If this keyword is not specified, we trace 20 isolines from the min to the max. |
---|
[2] | 52 | ; |
---|
[163] | 53 | ; @keyword CONTLABEL {type=integer} |
---|
| 54 | ; It is an integer n. When CONTOUR is activated, if n |
---|
[231] | 55 | ; is different of 0, choose the label type corresponding to n cases for |
---|
| 56 | ; the traced by a traitisolines. To specify the type of label of the |
---|
[142] | 57 | ; colored contour, use LABEL |
---|
[2] | 58 | ; |
---|
[163] | 59 | ; @keyword CONTMAX {default=The max of the array passed in the keyword CONTOUR (on ocean points)} |
---|
[231] | 60 | ; When CONTOUR is activated, max value we want to consider in the isoline |
---|
[163] | 61 | ; traced by a trait's line |
---|
[2] | 62 | ; |
---|
[163] | 63 | ; @keyword CONTMIN {default=The min of the array passed in the keyword CONTOUR (on ocean points)} |
---|
[231] | 64 | ; When CONTOUR is activated, min value we want to consider in the isoline |
---|
[163] | 65 | ; traced by a trait's line. |
---|
[2] | 66 | ; |
---|
[163] | 67 | ; @keyword CONTNLEVEL {default=20} |
---|
[264] | 68 | ; When CONTOUR is activated, it is the number of contours |
---|
[142] | 69 | ; traced by a trait for drawing (active if |
---|
[163] | 70 | ; CONTLABEL=0) |
---|
[67] | 71 | ; |
---|
[231] | 72 | ; @keyword CONTOUR |
---|
| 73 | ; If we want to trace contours of a different field than the one |
---|
| 74 | ; whose we have the colored drawing (by example E-P in color and QSR in contours). |
---|
[264] | 75 | ; It must be a field respecting same characteristics than the argument number one of <pro>plt</pro>. |
---|
[67] | 76 | ; |
---|
[264] | 77 | ; @keyword GRIDTYPE |
---|
| 78 | ; 'U','T','V','W' or 'F' |
---|
| 79 | ; to specify possibly the grid on which the field is joined. |
---|
[142] | 80 | ; Comment: In this case, we should use a structure like field. |
---|
[2] | 81 | ; |
---|
[231] | 82 | ; @keyword INTERVALLE |
---|
[264] | 83 | ; Value of an interval between to isoline. If there is none specified min, |
---|
| 84 | ; we choose a min contour which goes well with the specified interval! |
---|
| 85 | ; If this keyword is not specified, we trace 20 isolines from the min |
---|
| 86 | ; to the max. |
---|
| 87 | ; Comment: When CONTOUR is activated, INTERVALLE only specify the interval |
---|
| 88 | ; between 2 colored isolines. To specify the interval |
---|
[142] | 89 | ; between 2 isolines traced by a trait, use CONTINTERVALLE. |
---|
[67] | 90 | ; |
---|
[231] | 91 | ; @keyword INV |
---|
| 92 | ; Invert the color vector used to color the graph |
---|
[142] | 93 | ; (without use the black, the white and the used palette) |
---|
[231] | 94 | ; |
---|
[163] | 95 | ; @keyword LABEL {type=integer} |
---|
[231] | 96 | ; It is an integer n. If n different of 0, it choose the label's type |
---|
| 97 | ; corresponding to cases n. cf <pro>label</pro> |
---|
| 98 | ; Comment: When CONTOUR is activated, it only specify the label's type for colored isolines. |
---|
[367] | 99 | ; For these ones traced by a trait, use CONTLABEL. |
---|
[2] | 100 | ; |
---|
[163] | 101 | ; @keyword MAP {default=Cylindrical projection} |
---|
[142] | 102 | ; We use it when we want to do a projection. |
---|
| 103 | ; This keyword can be of two types: |
---|
[378] | 104 | ; MAP=[P0lat,P0lon,Rot]. For the description of these 3 values (see the online help of <proidl>MAP_SET</proidl>). |
---|
[231] | 105 | ; /MAP: In this case, map is automatically calculated have the value: |
---|
[2] | 106 | ; map = [0, (lon1+lon2)/2., 0] |
---|
[142] | 107 | ; Comment: A good way to choose the type of the projection we want to do is to have a look at IDL demo: |
---|
[371] | 108 | ; IDL> demo |
---|
[367] | 109 | ; Then choose "Mapping" and "Global Mapping Demo" |
---|
[264] | 110 | ; Comment2: By default it is a cylindrical projection which is done (with or without the keyword map). |
---|
[142] | 111 | ; If we want an other projection, MAP must be activated and we have to add the keyword: /nom_projection. |
---|
| 112 | ; For example, for a polar projection centered on the south pole: |
---|
[371] | 113 | ; IDL> domdef,-180,180,-90,-45 |
---|
| 114 | ; IDL> plt, tab, /stereo,map=[-90,0,0] |
---|
[2] | 115 | ; |
---|
[163] | 116 | ; @keyword LABMAP {default=labmap=1} |
---|
[378] | 117 | ; Corresponds to LABEL keyword of <proidl>MAP_SET</proidl>. |
---|
[67] | 118 | ; |
---|
[231] | 119 | ; @keyword MAXIN |
---|
[152] | 120 | ; to specify the max value we want to plot with a keyword instead of with the |
---|
| 121 | ; input parameter max. If max is defined by both, parameter and keyword, the |
---|
| 122 | ; keyword is retained. |
---|
[2] | 123 | ; |
---|
[231] | 124 | ; @keyword MININ |
---|
[152] | 125 | ; to specify the min value we want to plot with a keyword instead of with the |
---|
| 126 | ; input parameter min. If min is defined by both, parameter and keyword, the |
---|
| 127 | ; keyword is retained. |
---|
[2] | 128 | ; |
---|
[163] | 129 | ; @keyword NLEVEL {default=20} |
---|
[264] | 130 | ; Number of contour to draw. Active if LABEL=0 or is not specified. |
---|
[2] | 131 | ; |
---|
[246] | 132 | ; @keyword NOFILL |
---|
| 133 | ; To make just isolines with no filling |
---|
| 134 | ; |
---|
[231] | 135 | ; @keyword NOTRI |
---|
| 136 | ; To force not to use the triangulation. Beware, in this case, the |
---|
| 137 | ; drawing only works if the grid is undeformed (It means that each point of a longitude |
---|
| 138 | ; give one latitude and each point of a latitude give one longitude) except if we use |
---|
| 139 | ; the keyword CELL_FILL=2. |
---|
[142] | 140 | ; Comment: if the field contain points !values.f_nan, then we even do a triangulation. |
---|
[2] | 141 | ; |
---|
[231] | 142 | ; @keyword OVERPLOT |
---|
| 143 | ; To make a plot over an other one. |
---|
| 144 | ; Comment: Contrarily to the use of CONTOUR or VECTEUR, the use of this keyword |
---|
[142] | 145 | ; does not the caption and/or the color bar. |
---|
[2] | 146 | ; |
---|
[231] | 147 | ; @keyword STRICTFILL |
---|
| 148 | ; Activate this keyword to that the filling of contours be |
---|
[326] | 149 | ; precisely done between the min and the max specified. Values inferior/superior at the |
---|
| 150 | ; specified min/max are not filled. Note that max values a considered |
---|
| 151 | ; as missing values so cells containing one or more corners with |
---|
| 152 | ; values above max will have no contours drawn through them. |
---|
[2] | 153 | ; |
---|
[163] | 154 | ; @keyword STYLE {default=style=0} |
---|
[299] | 155 | ; Contour's style to adopt to draw isolines. See <pro>style</pro> for more informations |
---|
[2] | 156 | ; |
---|
[163] | 157 | ; @keyword VECTEUR {type=struct} |
---|
[142] | 158 | ; It is a structure composed by 2 elements containing the 2 fields U |
---|
[264] | 159 | ; and V of values of the zonal and meridian components of the vector of the fields |
---|
[142] | 160 | ; to draw. These fields can be an array or a structure. |
---|
| 161 | ; For example: vecteur={matriceu:lec('unsurface'),matricev:lec('vnsurface')} |
---|
[163] | 162 | ; Comment: name of elements of vectors are inconsequential. |
---|
[142] | 163 | ; vecteur={u:lec('unsurface'),v:lec('vnsurface')} is also appropriated. |
---|
[2] | 164 | ; |
---|
[142] | 165 | ; @keyword _EXTRA |
---|
[231] | 166 | ; Used to pass keywords |
---|
| 167 | ; |
---|
| 168 | ; @keyword CONT_NOFILL |
---|
| 169 | ; Activate it not to fill the point mask to let them transparent! |
---|
[142] | 170 | ; Comment: Nevertheless, we trace mask's contour. |
---|
[231] | 171 | ; |
---|
[142] | 172 | ; @keyword USETRI |
---|
| 173 | ; To force using triangulation. |
---|
[231] | 174 | ; |
---|
| 175 | ; @keyword MASKFILL |
---|
| 176 | ; |
---|
[142] | 177 | ; @keyword DUPLICATE |
---|
[2] | 178 | ; |
---|
[142] | 179 | ; @keyword DECIMATETRI |
---|
[2] | 180 | ; |
---|
[142] | 181 | ; @uses |
---|
[370] | 182 | ; <pro>common</pro> |
---|
[2] | 183 | ; |
---|
[231] | 184 | ; @history |
---|
[157] | 185 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[142] | 186 | ; 7/1999 |
---|
| 187 | ; Sebastien Masson 08/02/2000 checkfield and |
---|
| 188 | ; notri keyword (or triangule = -1) . |
---|
[231] | 189 | ; |
---|
[142] | 190 | ; @version |
---|
| 191 | ; $Id$ |
---|
[231] | 192 | ; |
---|
| 193 | ; @todo seb |
---|
[142] | 194 | ; Changer param "tab1",keyword "REMPLI", "UNLABSUR", "UNSUR2", |
---|
| 195 | ; "UNVECTSUR"+ quelques trucs dans la routine. |
---|
[2] | 196 | ;- |
---|
[327] | 197 | PRO plt, tab1, param2, param3, param4, REALCONT=realcont, CONTOUR=contour $ |
---|
| 198 | , INTERVALLE=intervalle, INV=inv, GRIDTYPE=gridtype, BOXZOOM=boxzoom $ |
---|
| 199 | , CONTINTERVALLE=contintervalle, LABEL=label, CONTLABEL=contlabel $ |
---|
| 200 | , STYLE=style, CONTMAX=contmax, CONTMIN=contmin, NLEVEL=nlevel $ |
---|
| 201 | , CONTNLEVEL=contnlevel $ |
---|
| 202 | , VECTEUR=vecteur, MAP=map, MININ=minin, MAXIN=maxin $ |
---|
| 203 | , NOFILL=nofill, CONT_NOFILL=cont_nofill $ |
---|
| 204 | , USETRI=usetri, NOTRI=notri, MASKFILL=maskfill $ |
---|
| 205 | , DUPLICATE=duplicate, STRICTFILL=strictfill, OVERPLOT=overplot $ |
---|
| 206 | , DECIMATETRI=decimatetri, LABMAP=labmap, _EXTRA=ex |
---|
[114] | 207 | ; |
---|
| 208 | compile_opt idl2, strictarrsubs |
---|
| 209 | ; |
---|
[67] | 210 | @cm_4mesh |
---|
| 211 | @cm_4data |
---|
| 212 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 213 | @updatenew |
---|
| 214 | @updatekwd |
---|
| 215 | ENDIF |
---|
[2] | 216 | ;-------------------------------------------------------------- |
---|
[142] | 217 | tempsun = systime(1) ; To key_performance |
---|
[2] | 218 | ;-------------------------------------------------------------- |
---|
| 219 | ;-------------------------------------------------------------- |
---|
[142] | 220 | ; I) preparation of the graphic environment and small verifications. |
---|
[2] | 221 | ;-------------------------------------------------------------- |
---|
| 222 | ;-------------------------------------------------------------- |
---|
[142] | 223 | ; I1) verification of the grid's type associated to tab1. |
---|
[2] | 224 | ;-------------------------------------------------------------- |
---|
[67] | 225 | if keyword_set(gridtype) then vargrid = gridtype |
---|
| 226 | if keyword_set(vecteur) AND (NOT keyword_set(gridtype)) then BEGIN |
---|
| 227 | vargrid = litchamp(tab1, /grid) |
---|
| 228 | if vargrid eq '' then BEGIN |
---|
| 229 | vargrid = xquestion('What is the grid associated to the data to contour?', 'T', /chkwidget) |
---|
| 230 | vargrid = strupcase(vargrid) |
---|
| 231 | endif |
---|
| 232 | ENDIF |
---|
[2] | 233 | ;-------------------------------------------------------------- |
---|
[142] | 234 | ; I2) Reading of the field and checkup. |
---|
[2] | 235 | ;-------------------------------------------------------------- |
---|
[67] | 236 | if keyword_set(boxzoom) AND n_elements(contour) ne 4 then BEGIN |
---|
| 237 | savedbox = 1b |
---|
| 238 | saveboxparam, 'boxparam4plt.dat' |
---|
| 239 | END |
---|
[142] | 240 | if n_elements(param2) NE 0 then type = param2 |
---|
| 241 | if n_elements(param3) NE 0 then min = param3 |
---|
| 242 | if n_elements(param4) NE 0 then max = param4 |
---|
[231] | 243 | if n_elements(minin) NE 0 then min = minin |
---|
[67] | 244 | if n_elements(maxin) NE 0 then max = maxin |
---|
| 245 | checktypeminmax, 'plt', TYPE = type, MIN = min, MAX = max, _extra = ex |
---|
[231] | 246 | z2d = checkfield(tab1, 'plt', TYPE = type, BOXZOOM = boxzoom, DIREC = direc, VECTEUR = vecteur, _extra = ex) |
---|
[251] | 247 | if n_elements(z2d) EQ 1 AND z2d[0] EQ -1 then BEGIN |
---|
[67] | 248 | IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt.dat' |
---|
| 249 | return |
---|
| 250 | ENDIF |
---|
| 251 | IF n_elements(usetri) EQ 0 THEN BEGIN |
---|
| 252 | ; do we have holes in the triangulation? |
---|
[231] | 253 | holeintri = n_elements(triangles_list)/3 LT (jpi-1+keyword_set(key_periodic))*(jpj-1)*2 ; -> the triangulation must be used to draw the field |
---|
[67] | 254 | ; do we have a triangulation? |
---|
| 255 | wehavetri = triangles_list[0] NE -1 ; -> the triangulation must be used to draw the continents |
---|
| 256 | ; if we make a map, are we periodic and nx=jpi ? |
---|
| 257 | CASE strupcase(vargrid) OF |
---|
| 258 | 'T':nx = nxt |
---|
| 259 | 'W':nx = nxt |
---|
| 260 | 'U':nx = nxu |
---|
| 261 | 'V':nx = nxv |
---|
| 262 | 'F':nx = nxf |
---|
| 263 | ENDCASE |
---|
[231] | 264 | mapperio = keyword_set(map)*keyword_set(key_periodic)*(nx eq jpi) |
---|
[67] | 265 | usetri = (wehavetri*(wehavetri+holeintri+mapperio+keyword_set(key_irregular))) < 2 |
---|
| 266 | IF n_elements(notri) NE 0 THEN usetri = 0 > (2-notri) |
---|
| 267 | ENDIF |
---|
[2] | 268 | ;-------------------------------------------------------------- |
---|
[142] | 269 | ; I3) reinitialization. !p.,!x.,!y. |
---|
[295] | 270 | ; Comment: We do not reinitialize when we call bck plt in loop to use contour. |
---|
[2] | 271 | ;-------------------------------------------------------------- |
---|
[67] | 272 | if n_elements(contour) ne 4 AND NOT keyword_set(overplot) then reinitplt, /z, /invert |
---|
[2] | 273 | ;--------------------------------------------------------------- |
---|
[142] | 274 | ; I4) attribution of the mask and of longitude and latitude arrays. |
---|
[2] | 275 | ;--------------------------------------------------------------- |
---|
[67] | 276 | IF strupcase(vargrid) EQ 'W' THEN profond = firstzw NE 0 $ |
---|
[231] | 277 | ELSE profond = firstzt NE 0 |
---|
[264] | 278 | ; do we need to extract now the triangulation that will be used for |
---|
[142] | 279 | ; contouring the field? |
---|
[67] | 280 | if keyword_set(profond) $ |
---|
| 281 | OR (usetri EQ 0 AND (vargrid EQ 'T' OR vargrid EQ 'W')) $ |
---|
| 282 | OR (usetri NE 2 AND (vargrid NE 'T' AND vargrid NE 'W')) THEN BEGIN |
---|
| 283 | grille, mask, glam, gphi, gdep, nx, ny, nz $ |
---|
| 284 | , firstx, firsty, firstz, lastx $ |
---|
| 285 | , lasty, lastz, /forplt, _extra = ex |
---|
| 286 | ENDIF ELSE BEGIN |
---|
| 287 | grille, mask, glam, gphi, gdep, nx, ny, nz $ |
---|
| 288 | , firstx, firsty, firstz, lastx, lasty $ |
---|
| 289 | , lastz, TRI = trifield, /forplt, _extra = ex |
---|
| 290 | ENDELSE |
---|
[2] | 291 | ;---------------------------------------------------------------------------- |
---|
[231] | 292 | ; I5 determination of the mi:min and of the ma:max of z2d in the same way |
---|
[142] | 293 | ; as max: max and min: min for the drawing. |
---|
[2] | 294 | ;----------------------------------------------------------------------------- |
---|
[67] | 295 | masknan = finite(z2d) |
---|
[231] | 296 | nan = total(masknan) NE n_elements(z2d) |
---|
[142] | 297 | ; Do we need to do an autoscale ??? |
---|
[67] | 298 | autoscale = testvar(var = min) EQ testvar(var = max) AND NOT keyword_set(intervalle) |
---|
| 299 | determineminmax, z2d, mask, mi, ma, glam, gphi, MININ = min, MAXIN = max $ |
---|
| 300 | , nan = nan, INTERVALLE = intervalle, usetri = usetri, _extra = ex |
---|
[251] | 301 | if n_elements(z2d) EQ 1 AND z2d[0] EQ -1 THEN GOTO, sortie |
---|
[142] | 302 | ; We do an autoscale if needed. |
---|
[67] | 303 | if autoscale then autoscale, min, max, intervalle |
---|
[2] | 304 | ;-------------------------------------------------------------- |
---|
| 305 | ;-------------------------------------------------------------- |
---|
[231] | 306 | ; II) We put the drawing in its place on the window or the page |
---|
[142] | 307 | ; and possible opening of the window or of the page. |
---|
[2] | 308 | ;-------------------------------------------------------------- |
---|
[67] | 309 | if n_elements(contour) NE 4 AND NOT keyword_set(overplot) THEN $ |
---|
| 310 | placedessin, 'plt', posfenetre, posbar $ |
---|
[2] | 311 | , CONTOUR = contour, VECTEUR = vecteur, MAP = map, DIREC = direc, _extra = ex |
---|
| 312 | ;-------------------------------------------------------------- |
---|
| 313 | ;-------------------------------------------------------------- |
---|
[142] | 314 | ; III) Covering of the drawing (labels,style,axis) |
---|
[2] | 315 | ;------------------------------------------------------------ |
---|
| 316 | ;-------------------------------------------------------------- |
---|
| 317 | ; |
---|
| 318 | ;-------------------------------------------------------------- |
---|
[142] | 319 | ; III1) Choice of labels |
---|
[2] | 320 | ;----------------------------------------------------------- |
---|
[67] | 321 | if keyword_set(intervalle) AND NOT keyword_set(label) then label = 1 |
---|
| 322 | if keyword_set(label) eq 0 then cas = 0 else cas = label |
---|
| 323 | label, cas, min, max, ncontour, level_z2d, colnumb, NLEVEL = nlevel $ |
---|
| 324 | , INTERVALLE = intervalle, strictfill = strictfill |
---|
[2] | 325 | ;-------------------------------------------------------------- |
---|
[142] | 326 | ; III2) Choice of style |
---|
[2] | 327 | ;----------------------------------------------------------- |
---|
[67] | 328 | if not keyword_set(style) then style = 0 |
---|
| 329 | style, style, level_z2d, linestyle, thick |
---|
| 330 | if keyword_set(inv) then colnumb = reverse(colnumb) |
---|
[2] | 331 | ;----------------------------------------------------------- |
---|
[142] | 332 | ; III3) Definition of axis |
---|
[2] | 333 | ;---------------------------------------------------------- |
---|
[67] | 334 | if NOT keyword_set(overplot) THEN axe, 'xy', _EXTRA = ex |
---|
[2] | 335 | ;-------------------------------------------------------------- |
---|
| 336 | ;-------------------------------------------------------------- |
---|
| 337 | ;------------------------------------------------------------ |
---|
[142] | 338 | ; IV) Drawing |
---|
[2] | 339 | ;-------------------------------------------------------------- |
---|
| 340 | ;-------------------------------------------------------------- |
---|
[67] | 341 | ;-------------------------------------------------------------- |
---|
[142] | 342 | ; extrapolation of field on lands and setup of min, max values |
---|
[67] | 343 | ;-------------------------------------------------------------- |
---|
[246] | 344 | IF keyword_set(nan) THEN BEGIN |
---|
| 345 | IF NOT keyword_set(nofill) THEN z2d[where(masknan EQ 0)] = max |
---|
[67] | 346 | ENDIF ELSE masknan = 1 |
---|
[326] | 347 | IF keyword_set(strictfill) THEN BEGIN |
---|
| 348 | tmp = z2d ge max |
---|
[328] | 349 | IF total(tmp GE 1) THEN BEGIN |
---|
| 350 | tmp = 1b - byte(extrapolate(tmp, tmp, 1, x_periodic = keyword_set(key_periodic)*(nx EQ jpi) )) |
---|
| 351 | trifield = triangule(temporary(tmp)*mask, coinmonte = coinmontemask $ |
---|
| 352 | , coindescend = coindescendmask, keep_cont = 0) |
---|
| 353 | indicezoommask = (lindgen(jpi, jpj))[firstx:lastx, firsty:lasty] |
---|
| 354 | ENDIF |
---|
[326] | 355 | ENDIF |
---|
[67] | 356 | ; filling the mask values |
---|
| 357 | ; we fill only masknan or we fill mask*masknan? |
---|
| 358 | IF keyword_set(nan) AND keyword_set(cont_nofill) THEN $ |
---|
| 359 | z2d = remplit(z2d, nite = 1+(vargrid NE 'T' AND vargrid NE 'W') $ |
---|
| 360 | , mask = masknan, _extra = ex) $ |
---|
| 361 | ELSE z2d = remplit(z2d, nite = (1 + (vargrid NE 'T' AND vargrid NE 'W') $ |
---|
| 362 | + keyword_set(nan)) $ |
---|
| 363 | *(1-keyword_set(cont_nofill)) $ |
---|
| 364 | *(1-(n_elements(maskfill) NE 0)) $ |
---|
| 365 | , mask = mask*masknan, _extra = ex) |
---|
| 366 | IF keyword_set(strictfill) EQ 0 AND n_elements(maskfill) EQ 0 then $ |
---|
| 367 | z2d = min > z2d < max |
---|
| 368 | if n_elements(maskfill) NE 0 then BEGIN |
---|
| 369 | z2d = temporary(z2d)*mask*masknan |
---|
| 370 | if maskfill NE 0 then z2d = temporary(z2d) + maskfill*(1-mask*masknan) |
---|
| 371 | ENDIF |
---|
| 372 | ;---------------------------------------------------------- |
---|
[171] | 373 | ; check mask and triangulation according to the grid type and NaN |
---|
[231] | 374 | ;---------------------------------------------------------- |
---|
| 375 | ; If we make a drawing at depth, we must redefine a triangulation |
---|
[171] | 376 | ; on the zoom because the land/sea mask at depth may differ from |
---|
| 377 | ; the one at the surface. |
---|
| 378 | ; As this triangulation will be used to draw the land/sea mask with |
---|
| 379 | ; the good shape, we use tmask to compute it even if the data are not |
---|
| 380 | ; located on the T grid |
---|
[67] | 381 | if (keyword_set(profond) OR keyword_set(cont_nofill)) $ |
---|
| 382 | AND ((usetri GE 1 AND (vargrid EQ 'T' OR vargrid EQ 'W')) $ |
---|
| 383 | OR (usetri EQ 2 AND (vargrid NE 'T' AND vargrid NE 'W'))) then BEGIN |
---|
| 384 | trifield = triangule(tmask[firstx:lastx, firsty:lasty, firstz] $ |
---|
| 385 | , coinmonte = coinmontemask $ |
---|
| 386 | , coindescend = coindescendmask $ |
---|
| 387 | , keep_cont = cont_nofill, _extra = ex) |
---|
| 388 | indicezoommask = (lindgen(jpi, jpj))[firstx:lastx, firsty:lasty] |
---|
| 389 | ENDIF |
---|
| 390 | ; triangulation for nan mask |
---|
| 391 | if keyword_set(nan) then BEGIN |
---|
[171] | 392 | trinan = triangule(masknan, /keep_cont, coinmonte = coinmontenan $ |
---|
[67] | 393 | , coindescend = coindescendnan) |
---|
| 394 | indicezoomnan = (lindgen(jpi, jpj))[firstx:lastx, firsty:lasty] |
---|
| 395 | ENDIF |
---|
| 396 | ; IF n_elements(twin_corners_up) EQ 0 THEN coinmontemask = -1 ELSE coinmontemask = twin_corners_up |
---|
| 397 | ; IF n_elements(twin_corners_dn) EQ 0 THEN coindescendmask = -1 ELSE coindescendmask = twin_corners_dn |
---|
[231] | 398 | if vargrid EQ 'T' OR vargrid EQ 'W' then BEGIN |
---|
[67] | 399 | glammsk = glam |
---|
| 400 | gphimsk = gphi |
---|
[171] | 401 | ENDIF ELSE begin |
---|
[231] | 402 | ; decoupe terre: To draw the coast in a clean way, we try to take additionally |
---|
[171] | 403 | ; points to draw the land. Like that, we do not see gap between T and U/V/F grid. |
---|
| 404 | ; It is what decoupeterre do. We also redefine trimsk. |
---|
| 405 | maskorg = mask |
---|
[67] | 406 | decoupeterre, mask, glammsk, gphimsk, type = 'xy'$ |
---|
| 407 | , TRI = trimsk, usetri = usetri, indicezoom = indicezoommask $ |
---|
| 408 | , coinmonte = coinmontemask, coindescend = coindescendmask $ |
---|
| 409 | , _EXTRA = ex |
---|
| 410 | ENDELSE |
---|
[2] | 411 | ;------------------------------------------------------------ |
---|
[142] | 412 | ; IV1) Choice of type of drawing. |
---|
[2] | 413 | ;------------------------------------------------------------ |
---|
[67] | 414 | typetrace = 'classique' |
---|
[231] | 415 | if keyword_set(map) AND key_onearth then BEGIN |
---|
[142] | 416 | ; Call of mapset when we want to do projections. |
---|
[67] | 417 | IF n_elements(map) NE 3 THEN map = [0, ((lon1+lon2)/2.) MOD 360, 0] |
---|
| 418 | typetrace = 'projection' |
---|
| 419 | map_lat = map[0] |
---|
| 420 | map_lon = map[1] |
---|
| 421 | map_rot = map[2] |
---|
| 422 | if chkstru(ex, 'TITLE') then begin |
---|
[231] | 423 | maptitre = ex.title |
---|
[67] | 424 | ex.title = '' |
---|
| 425 | endif |
---|
| 426 | map_set, map_lat, map_lon, map_rot, _extra = ex, position = posfenetre, /iso $ |
---|
| 427 | , limit = [lat1, lon1, lat2, lon2], /noborder |
---|
| 428 | if n_elements(maptitre) ne 0 then ex.title = maptitre |
---|
| 429 | if n_elements(trifield) GE 2 then trifield = ciseauxtri(trifield, glam, gphi, _EXTRA = ex) |
---|
| 430 | if n_elements(trimsk) GE 2 then trimsk = ciseauxtri(trimsk, glammsk, gphimsk, _EXTRA = ex) |
---|
[231] | 431 | if n_elements(trinan) GE 2 then BEGIN |
---|
[67] | 432 | trinan = ciseauxtri(trinan, glam, gphi, _EXTRA = ex) |
---|
| 433 | if trinan[0] EQ -1 then undefine, trinan |
---|
| 434 | endif |
---|
[231] | 435 | ENDIF ELSE BEGIN |
---|
[493] | 436 | ;To axes of coordinates be considerate. |
---|
[67] | 437 | if !x.type EQ 0 AND n_elements(contour) LE 4 then $ |
---|
[231] | 438 | plot, [0], [0], /nodata, xstyle = 5, ystyle = 5, title = '', subtitle = '', /noerase |
---|
[67] | 439 | if keyword_set(key_periodic) then BEGIN |
---|
[231] | 440 | ; In this case, triangulation is closed in x and cover all the sphere. |
---|
[142] | 441 | ; We have to cut it at the level where we cut the sphere to make the drawing. |
---|
[67] | 442 | if n_elements(trifield) GE 2 then trifield = ciseauxtri(trifield, glam, gphi, _EXTRA = ex) |
---|
| 443 | if n_elements(trimsk) GE 2 then trimsk = ciseauxtri(trimsk, glammsk, gphimsk, _EXTRA = ex) |
---|
| 444 | if n_elements(trinan) GE 2 then trinan = ciseauxtri(trinan, glam, gphi, _EXTRA = ex) |
---|
| 445 | ENDIF |
---|
| 446 | endelse |
---|
[2] | 447 | ;------------------------------------------------------------ |
---|
[142] | 448 | ; IV2) Contours and coloring |
---|
[2] | 449 | ;------------------------------------------------------------ |
---|
[67] | 450 | if keyword_set(duplicate) then BEGIN |
---|
[2] | 451 | ; pour marina uniquement ATTENTION C'EST TRES MAL CODE |
---|
[67] | 452 | lon = glam[*, 0] |
---|
| 453 | decalage = max(lon)-min(lon)+(lon-shift(lon, 1))[n_elements(lon)-1] |
---|
| 454 | !x.range[1] = !x.range[1]+(duplicate-1)*decalage |
---|
| 455 | for i = 1, duplicate-1 do BEGIN |
---|
| 456 | z2d = [z2d, z2d] |
---|
| 457 | gphi = [gphi, gphi] |
---|
| 458 | mask = [mask, mask] |
---|
| 459 | gphimsk = [gphimsk, gphimsk] |
---|
| 460 | glam = [glam, glam+i*decalage] |
---|
| 461 | glammsk = [glammsk, glammsk] |
---|
| 462 | ENDFOR |
---|
| 463 | endif |
---|
| 464 | ; save, glam, gphi, trifield, file = 'tri.dat' |
---|
| 465 | if keyword_set(decimatetri) then BEGIN |
---|
[142] | 466 | tempsdeux = systime(1) ; To key_performance |
---|
[67] | 467 | IF n_elements(trimsk) EQ 0 THEN trimsk = trifield |
---|
| 468 | Verts = transpose([[(temporary(glam))[*]], [(temporary(gphi))[*]] $ |
---|
| 469 | , [(temporary(z2d))[*]]]) |
---|
| 470 | Conn = [replicate(3, 1, n_elements(trifield)/3), trifield] |
---|
| 471 | Result = mesh_decimate(temporary(verts), (temporary(Conn))[*] $ |
---|
[292] | 472 | , connout, vertices = Vertsout $ |
---|
[67] | 473 | , percent_vertices = decimatetri) |
---|
[231] | 474 | connout = reform(connout, 4, n_elements(connout)/4, /over) |
---|
[67] | 475 | trifield = (temporary(connout))[1:3, *] |
---|
| 476 | glam = reform(Vertsout[0, *]) |
---|
| 477 | gphi = reform(Vertsout[1, *]) |
---|
| 478 | z2d = reform(Vertsout[2, *]) |
---|
| 479 | undefine, Vertsout |
---|
[231] | 480 | print, 'temps decimatetri', systime(1)-tempsdeux |
---|
[67] | 481 | ENDIF |
---|
| 482 | pltbase, z2d, glam, gphi $ |
---|
| 483 | , mask, glammsk, gphimsk, trichamp = trifield, trimsk = trimsk, /forplt $ |
---|
| 484 | , level_z2d, colnumb, contour = contour, usetri = usetri, realcont = realcont $ |
---|
[2] | 485 | , overplot = keyword_set(overplot)+keyword_set(map) $ |
---|
[67] | 486 | , c_linestyle = linestyle, c_labels = 1-(indgen(n_elements(level_z2d)) MOD 2) $ |
---|
[246] | 487 | , c_thick = thick, nofill = nofill, cont_nofill = cont_nofill, nan = nan $ |
---|
[2] | 488 | , coinmontemask = coinmontemask, coindescendmask = coindescendmask $ |
---|
| 489 | , coinmontenan = coinmontenan, coindescendnan = coindescendnan $ |
---|
| 490 | , indicezoommask = indicezoommask, indicezoomnan = indicezoomnan $ |
---|
[171] | 491 | , maskorg = maskorg, masknan = masknan, trinan = trinan, _extra = ex |
---|
[2] | 492 | ;------------------------------------------------------------ |
---|
[142] | 493 | ; IV3) Recall of plt in loop when contour is activated. |
---|
[2] | 494 | ;------------------------------------------------------------ |
---|
[67] | 495 | if n_elements(contour) eq 4 then BEGIN ; c''est la 2eme fois que je passe ds pltt |
---|
| 496 | contour = {mietma:[mi, ma], unit:varunit, inter:intervalle} ; je renvoie le min, le max et l''unite |
---|
| 497 | return |
---|
| 498 | endif |
---|
[231] | 499 | if keyword_set(contour) THEN BEGIN |
---|
[67] | 500 | pourlegende = [1, 1, 1, 1] |
---|
| 501 | oldattributs = saveatt() |
---|
| 502 | oldcolnumb = colnumb |
---|
| 503 | plt, contour, contmin, contmax, CONTOUR = pourlegende, /NOERASE $ |
---|
[390] | 504 | , USETRI = usetri, CONT_NOFILL = cont_nofill $ |
---|
[67] | 505 | , INTERVALLE = contintervalle, LABEL = contlabel, STYLE = style $ |
---|
| 506 | , NLEVEL = contnlevel, DUPLICATE = duplicate, STRICTFILL = strictfill $ |
---|
| 507 | , MASKFILL = maskfill, _extra = ex |
---|
| 508 | restoreatt, oldattributs |
---|
| 509 | colnumb = oldcolnumb |
---|
| 510 | ENDIF |
---|
[2] | 511 | ;------------------------------------------------------------ |
---|
| 512 | ;------------------------------------------------------------ |
---|
[142] | 513 | ; V) Small functions |
---|
[2] | 514 | ;------------------------------------------------------------ |
---|
| 515 | ;------------------------------------------------------------ |
---|
| 516 | ; |
---|
| 517 | ;------------------------------------------------------------ |
---|
[142] | 518 | ; V1) Possible add of vectors in double exposure. |
---|
[2] | 519 | ;------------------------------------------------------------ |
---|
[231] | 520 | if keyword_set(vecteur) then BEGIN |
---|
[67] | 521 | oldattributs = saveatt() |
---|
[490] | 522 | ajoutvect, vecteur, vectlegende, CONT_NOFILL=cont_nofill, _extra = ex |
---|
[67] | 523 | restoreatt, oldattributs |
---|
| 524 | ENDIF |
---|
[2] | 525 | ; |
---|
[67] | 526 | if keyword_set(overplot) then GOTO, fini |
---|
[2] | 527 | ;------------------------------------------------------------ |
---|
[493] | 528 | ; V2) Trace the line of change of date, the equator and the Greenwich meridian, ... |
---|
[2] | 529 | ;------------------------------------------------------------ |
---|
[67] | 530 | if NOT keyword_set(map) AND key_onearth then meridienparallele, 'xy' |
---|
[2] | 531 | ;------------------------------------------------------------ |
---|
[142] | 532 | ; V3) To trace IDL's continents |
---|
[2] | 533 | ;------------------------------------------------------------ |
---|
[67] | 534 | if keyword_set(realcont) then BEGIN |
---|
[493] | 535 | ; si noerase est passe de _extra, on s''assure qu''il est a 1 |
---|
[67] | 536 | if chkstru(ex, 'NOERASE') then begin |
---|
| 537 | oldnoerase = ex.noerase |
---|
| 538 | ex.noerase = 1 |
---|
| 539 | ENDIF |
---|
| 540 | if chkstru(ex, 'coast_thick') then mlinethick = ex.coast_thick ELSE mlinethick = 1 |
---|
| 541 | if chkstru(ex, 'coast_color') then mcolor = ex.coast_color ELSE mcolor = 0 |
---|
| 542 | IF NOT keyword_set(map) THEN $ |
---|
| 543 | map_set, 0, ((lon1+lon2)/2.) MOD 360, 0, position = posfenetre $ |
---|
| 544 | , limit = [lat1, lon1, lat2, lon2], /NOERASE, /noborder, color = 0 $ |
---|
| 545 | , _extra = ex |
---|
| 546 | if realcont NE 2 AND NOT keyword_set(cont_nofill) then BEGIN |
---|
| 547 | if chkstru(ex, 'cont_color') then cntcol = ex.coast_color $ |
---|
| 548 | ELSE cntcol = (!d.n_colors - 1) < 255 |
---|
| 549 | map_continents, /fill_continents, color = cntcol, _extra = ex, /noerase |
---|
| 550 | ENDIF |
---|
| 551 | map_continents, /continents, color = mcolor, MLINETHICK = mlinethick, /noerase, _extra = ex |
---|
| 552 | if chkstru(ex, 'NOERASE') THEN ex.noerase = oldnoerase |
---|
| 553 | ENDIF |
---|
[2] | 554 | ;------------------------------------------------------------ |
---|
[142] | 555 | ; V4) caption + display of these. |
---|
[2] | 556 | ;------------------------------------------------------------ |
---|
[67] | 557 | legende, mi, ma, 'xy', CONTOUR = pourlegende, VECTLEGENDE = vectlegende, INTERVALLE = intervalle, DIREC = direc, _EXTRA = ex |
---|
[231] | 558 | if n_elements(ex) NE 0 then BEGIN |
---|
[142] | 559 | ; To keep frame's axes in black |
---|
[67] | 560 | if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = coast_color |
---|
| 561 | endif |
---|
[2] | 562 | ; |
---|
[67] | 563 | case typetrace of |
---|
| 564 | 'classique': $ |
---|
| 565 | plot, [0], [0], /nodata, /noerase, color = 0, xstyle = 1, ystyle = 1, _extra = ex |
---|
[231] | 566 | 'projection': BEGIN |
---|
[67] | 567 | if chkstru(ex, 'NOERASE') then begin |
---|
| 568 | oldnoerase = ex.noerase |
---|
| 569 | ex.noerase = 1 |
---|
| 570 | endif |
---|
| 571 | if chkstru(ex, 'SUBTITLE') then !p.subtitle = ex.SUBTITLE |
---|
| 572 | if n_elements(maptitre) ne 0 then ex.title = maptitre |
---|
| 573 | map_set, map_lat, map_lon, map_rot, _extra = ex, /iso, limit = [lat1, lon1, lat2, lon2]$ |
---|
| 574 | , /NOERASE, /noborder, title = !p.title, color = 0 |
---|
[2] | 575 | ; map_proj_info, numproj, /current |
---|
| 576 | ; map_proj_info, numproj, name = nomproj |
---|
| 577 | ; if nomproj EQ 'Mercator' OR nomproj EQ 'Cylindrical' OR nomproj EQ 'LambertConic'$ |
---|
| 578 | ; OR nomproj EQ 'Gnomic' OR nomproj EQ 'AlbersEqualAreaConic' $ |
---|
| 579 | ; OR nomproj EQ 'TransverseMercator' OR nomproj EQ 'MillerCylindrical' $ |
---|
| 580 | ; OR nomproj EQ 'LambertConicEllipsoid' then map_grid, box_axes=1,latdel=10,londel=10 $ |
---|
[67] | 581 | ; ELSE map_grid, charsize = 0.75, /label,latalign = 1,lonalign |
---|
| 582 | ; = 1,latdel = 10,londel = 30 |
---|
| 583 | IF n_elements(labmap) EQ 0 THEN labmap = 1 |
---|
| 584 | map_grid, charsize = 0.75, label = labmap, latalign = 1, lonalign = 1, latdel = 10, londel = 30, color = 0, _extra = ex |
---|
| 585 | if chkstru(ex, 'NOERASE') THEN ex.noerase = oldnoerase |
---|
| 586 | end |
---|
| 587 | endcase |
---|
[2] | 588 | ;------------------------------------------------------------ |
---|
[142] | 589 | ; V5) Colorbar. |
---|
[2] | 590 | ;------------------------------------------------------------ |
---|
[67] | 591 | colnumb = colnumb[0:ncontour-1-keyword_set(strictfill)] |
---|
| 592 | barrecouleur, colnumb, min, max, (ncontour-keyword_set(strictfill))/2 $ |
---|
| 593 | , position = posbar, _extra = ex |
---|
[2] | 594 | ;------------------------------------------------------------ |
---|
| 595 | ;------------------------------------------------------------ |
---|
[142] | 596 | ; VI) Possible print. |
---|
[2] | 597 | ;------------------------------------------------------------ |
---|
| 598 | ;------------------------------------------------------------ |
---|
| 599 | fini: |
---|
[67] | 600 | terminedessin, _extra = ex |
---|
[2] | 601 | ;------------------------------------------------------------ |
---|
| 602 | ;------------------------------------------------------------ |
---|
| 603 | sortie: |
---|
[67] | 604 | if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt.dat' |
---|
[231] | 605 | if keyword_set(key_performance) NE 0 THEN print, 'temps plt', systime(1)-tempsun |
---|
[2] | 606 | ;------------------------------------------------------------ |
---|
| 607 | ;------------------------------------------------------------ |
---|
[67] | 608 | return |
---|
[2] | 609 | end |
---|