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