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