source: trunk/SRC/ToBeReviewed/TRIANGULATION/drawsectionbottom.pro @ 76

Last change on this file since 76 was 67, checked in by pinsard, 18 years ago

miscellaneous modifications according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/

  • Property svn:executable set to *
File size: 5.9 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:drawsectionbottom
6;
7; PURPOSE:fill and draw the bottom continents for a real section.
8;
9; CATEGORY:
10;
11; CALLING SEQUENCE:
12;
13; INPUTS:
14;
15; KEYWORD PARAMETERS:
16;
17;        COAST_COLOR: the color of the coastline.
18;                     defaut value is 0 => black
19;
20;        COAST_THICK: the thickness of the coastline.
21;                     defaut value is 1
22;
23;        CONT_COLOR: the color of the continent. defaut value is
24;        (!d.n_colors - 1) < 255 => white
25;
26; OUTPUTS:
27;
28; COMMON BLOCKS:common.pro
29;
30; SIDE EFFECTS:
31;
32; RESTRICTIONS:simple way to fill continents for a section (using the
33; fact that continents are wider at the bottom than at the top).
34;
35; EXAMPLE:
36;
37; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
38;                      June 14, 2002
39;-
40;------------------------------------------------------------
41;------------------------------------------------------------
42;------------------------------------------------------------
43PRO drawsectionbottom, maskin, xxaxisin, depthsin $
44                       , COAST_COLOR = coast_color, COAST_THICK = coast_thick $
45                       , CONT_COLOR = cont_color, CONT_NOFILL = cont_nofill $
46                       , OVERPLOT = overplot, _extra = ex
47;---------------------------------------------------------
48@cm_general
49  IF NOT keyword_set(key_forgetold) THEN BEGIN
50@updatekwd
51  ENDIF
52;---------------------------------------------------------
53  if keyword_set(overplot) then return
54;
55; mask is from bottom to top
56;----------
57; boundaries conditions:
58  nx = (size(maskin))[1]
59  nz = (size(maskin))[2]+1
60;
61  IF size(xxaxisin, /n_dimensions) EQ 1 THEN $
62    xxaxisin = temporary(xxaxisin)#replicate(1, nz)
63  IF size(depthsin, /n_dimensions) EQ 1 THEN $
64    depthsin = replicate(1, nx)#temporary(depthsin)
65; for the mask : we add ocean at the top then it is always possible to
66; find one ocean point on each water column.
67  mask = [[maskin], [replicate(1, nx)]]
68; for x axis we also add one level
69;  xxaxis = [[xxaxisin], [xxaxisin[*, 0]]]
70; x axis must cover nx+1 points because we will draw the edge of the
71; mask.
72; if it was mot possible in decoupeterre.pro to extend the xxaxis we
73; do it now by hand
74  xxaxis = xxaxisin[*, 0]
75;  if (size(xxaxis))[1] EQ nx then begin
76  if n_elements(xxaxis) EQ nx then begin
77    deltax = abs(!x.range[1]-!x.range[0])/10.
78    xxaxis = [xxaxis[0]-deltax, xxaxis ]
79;    x0 = xxaxis[0]-deltax
80;    xxaxis = [replicate(x0, 1, nz), xxaxis ]
81  ENDIF
82; for the depth,
83  usepartial = total(depthsin, 2)
84  usepartial = total(usepartial NE usepartial[0]) GE 1
85  depths = depthsin[0:nx-1,*]
86; we add one level according to the ocean level we had to the mask.
87  deltaz = abs(!y.range[1]-!y.range[0])/10.
88  zmax = max(depthsin)+deltaz
89;   depths = [[depths], [replicate(zmax, nx+1)]]
90  depths = [[depths], [replicate(zmax, nx)]]
91; if min(depths) gt -1 then we must add one line at the bottom (this
92; appens when the bottom limit is defined between T[k] and W[k]
93; points)
94  IF min(depthsin) GT -1 THEN BEGIN
95    zmin = min(!y.range)-deltaz
96    depths = [[replicate(zmin, nx)], [depths]]
97    mask = [[replicate(0, nx)], [mask]]
98    nz = nz+1
99  ENDIF
100;
101;----------
102  xleft = xxaxis[0:nx-1]
103  xright = xxaxis[1:nx]
104; looking for the position of the bottom of the ocean.
105  pos = nz-1-total(mask, 2)
106  depths = depths[lindgen(nx)+nx*pos]
107;
108  xx = transpose([[xleft], [xright]])
109  xx = !x.range[0] > xx[*] < !x.range[1]
110  zz = transpose([[depths], [depths]])
111  out = where(zz GE max(depthsin) OR zz LT min(!y.range), countout)
112  zz = min(!y.range) > zz[*] < max(!y.range)
113;----------
114  xx = float(xx)
115  zz = float(zz)
116;----------
117; filling of the continents
118  IF NOT keyword_set(cont_color) THEN cont_color = (!d.n_colors - 1) < 255
119;   if NOT keyword_set(cont_nofill) then $
120;     polyfill, [min(xx,  max = maxx), xx[*], maxx] $
121;               , [min(zz,  max = mazz), zz[*], mazz] $
122;               , color = cont_color
123   if NOT keyword_set(cont_nofill) then $
124     polyfill, [min(xx, max = maxx), xx[*], maxx] $
125               , [!y.range[0], zz[*], !y.range[0]], color = cont_color
126;----------
127; drawing of the coast (bottom) line...
128; we could have plot directly xx and yy but if countout ne 0, doing
129; this will draw an non-existing bottom line along !y.range values
130; which is not so good...
131; we thus do this ugly for/if loops to make sure that we don't draw
132; these lines but we keep all vertical lines...
133   IF countout NE 0 THEN BEGIN
134     FOR i = 0, countout -1 DO BEGIN
135       CASE 1 OF
136         out[i] EQ 0:BEGIN
137; if we start with a out point
138           xxx = !values.f_nan
139           zzz = !values.f_nan           
140         END
141         i EQ 0:BEGIN
142; i eq 0 but out[i] ne 0
143           xxx = [xx[0:out[i]], !values.f_nan]
144           zzz = [zz[0:out[i]], !values.f_nan]
145         END
146         ELSE:BEGIN
147; two consecutive out values at the same depth: we just keep
148; !values.f_nan values until the next change of depth
149           IF (out[i-1] EQ out[i]-1) AND (zz[out[i-1]] EQ zz[out[i]]) THEN BEGIN
150             xxx = [xxx, !values.f_nan]
151             zzz = [zzz, !values.f_nan]             
152           ENDIF ELSE BEGIN
153; we keep everything inbetween the out values (including themselves
154; for the vertical lines) but we had !values.f_nan to remove the horizontal lines
155             xxx = [xxx, xx[out[i-1]:out[i]], !values.f_nan]
156             zzz = [zzz, zz[out[i-1]:out[i]], !values.f_nan]             
157           ENDELSE
158         END
159       ENDCASE
160       IF i EQ countout-1 AND out[i] NE n_elements(xx)-1 THEN BEGIN
161         xxx = [xxx, xx[out[i]:*]]
162         zzz = [zzz, zz[out[i]:*]]             
163       ENDIF
164     ENDFOR
165     plots, xxx, zzz, color = coast_color, thick = coast_thick, _extra = ex
166   ENDIF ELSE plots, xx, zz, color = coast_color, thick = coast_thick, _extra = ex
167;
168  return
169end
170
Note: See TracBrowser for help on using the repository browser.