source: trunk/SRC/ToBeReviewed/PLOTS/DESSINE/pltbase.pro @ 236

Last change on this file since 236 was 231, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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