1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; |
---|
6 | ; @file_comments |
---|
7 | ; Similar to grille. Here, when vargrid is not 'T' or 'W', we have to |
---|
8 | ; recuperate Tmask, glamt, gphit and the array of triangulation on the |
---|
9 | ; considerated subdomain for the drawing. The specificity of decoupeterre |
---|
10 | ; in comparaison with grille, is that we take, if possible, a subdomain |
---|
11 | ; just a little bit bigger than the one defined by domdef in order to be |
---|
12 | ; sure that the mask we draw will cover over all the drawing. |
---|
13 | ; |
---|
14 | ; @categories |
---|
15 | ; utilities |
---|
16 | ; |
---|
17 | ; @keyword TRI |
---|
18 | ; This keyword serve to obtain, thanks to grille, the triangulation which |
---|
19 | ; refer to the grid but only on the part of the zoom. This of triangulation |
---|
20 | ; is passed in the variable we have equate at TRI. |
---|
21 | ; For example: grille,...,tri=triangulation_reduite. |
---|
22 | ; This keyword is used in plt.pro |
---|
23 | ; |
---|
24 | ; @keyword WDEPTH |
---|
25 | ; To specify that the field is at W depth instad of T |
---|
26 | ; depth (automatically activated if vargrid eq 'W') |
---|
27 | ; |
---|
28 | ; @uses |
---|
29 | ; common.pro |
---|
30 | ; |
---|
31 | ; @history |
---|
32 | ; Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
33 | ; 24/2/99 |
---|
34 | ; |
---|
35 | ; @version |
---|
36 | ; $Id$ |
---|
37 | ; |
---|
38 | ; @todo seb : manque tous les param et plein de keywords. |
---|
39 | ; |
---|
40 | ; |
---|
41 | ; |
---|
42 | ; |
---|
43 | ;- |
---|
44 | ;------------------------------------------------------------ |
---|
45 | ;------------------------------------------------------------ |
---|
46 | ;------------------------------------------------------------ |
---|
47 | PRO decoupeterre, mask, glam, gphi, gdep, TYPE = type, TRI = tri, INDICEZOOM = indicezoom, COINMONTE = coinmonte, COINDESCEND = coindescend, WDEPTH = wdepth, REALSECTION = realsection, USETRI = usetri, _extra = ex |
---|
48 | ;--------------------------------------------------------- |
---|
49 | ; |
---|
50 | compile_opt idl2, strictarrsubs |
---|
51 | ; |
---|
52 | @cm_4mesh |
---|
53 | @cm_4data |
---|
54 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
55 | @updatenew |
---|
56 | ENDIF |
---|
57 | ;--------------------------------------------------------- |
---|
58 | tempsun = systime(1) ; For key_performance |
---|
59 | ;------------------------------------------------------------ |
---|
60 | if vargrid EQ 'W' then wdepth = 1 |
---|
61 | ;------------------------------------------------------------ |
---|
62 | ;------------------------------------------------------------ |
---|
63 | ; horizontal parameters |
---|
64 | ;------------------------------------------------------------ |
---|
65 | ; if possible extent the domain according to the grid type |
---|
66 | ; default case |
---|
67 | case vargrid of |
---|
68 | 'U':BEGIN |
---|
69 | firstx = 0 > (min([firstxt, firstxu])-1) |
---|
70 | lastx = (max([lastxt, lastxu])+1) < (jpi-1) |
---|
71 | firsty = 0 > (min([firstyt, firstyu])-1) |
---|
72 | lasty = (max([lastyt, lastyu])+1) < (jpj-1) |
---|
73 | end |
---|
74 | 'V':BEGIN |
---|
75 | firstx = 0 > (min([firstxt, firstxv])-1) |
---|
76 | lastx = (max([lastxt, lastxv])+1) < (jpi-1) |
---|
77 | firsty = 0 > (min([firstyt, firstyv])-1) |
---|
78 | lasty = (max([lastyt, lastyv])+1) < (jpj-1) |
---|
79 | end |
---|
80 | 'F':BEGIN |
---|
81 | firstx = 0 > (min([firstxt, firstxf])-1) |
---|
82 | lastx = (max([lastxt, lastxf])+1) < (jpi-1) |
---|
83 | firsty = 0 > (min([firstyt, firstyf])-1) |
---|
84 | lasty = (max([lastyt, lastyf])+1) < (jpj-1) |
---|
85 | END |
---|
86 | ELSE:BEGIN |
---|
87 | firstx = firstxt |
---|
88 | lastx = lastxt |
---|
89 | firsty = firstyt |
---|
90 | lasty = lastyt |
---|
91 | END |
---|
92 | ENDCASE |
---|
93 | ; however for the vertical section we don''t whant to extent the domain |
---|
94 | ; in the direction perpendicular to the vertical section |
---|
95 | if type EQ 'xz' then begin |
---|
96 | case vargrid of |
---|
97 | 'U':BEGIN |
---|
98 | firsty = firstyu |
---|
99 | lasty = lastyu |
---|
100 | END |
---|
101 | 'V':BEGIN |
---|
102 | firsty = firstyv |
---|
103 | lasty = lastyv |
---|
104 | END |
---|
105 | 'F':BEGIN |
---|
106 | firsty = firstyf |
---|
107 | lasty = lastyf |
---|
108 | END |
---|
109 | ELSE: |
---|
110 | ENDCASE |
---|
111 | endif |
---|
112 | ; |
---|
113 | if type EQ 'yz' then begin |
---|
114 | case vargrid of |
---|
115 | 'U':BEGIN |
---|
116 | firstx = firstxu |
---|
117 | lastx = lastxu |
---|
118 | END |
---|
119 | 'V':BEGIN |
---|
120 | firstx = firstxv |
---|
121 | lastx = lastxv |
---|
122 | END |
---|
123 | 'F':BEGIN |
---|
124 | firstx = firstxf |
---|
125 | lastx = lastxf |
---|
126 | END |
---|
127 | ELSE: |
---|
128 | ENDCASE |
---|
129 | endif |
---|
130 | ; |
---|
131 | nx = lastx-firstx+1 |
---|
132 | ny = lasty-firsty+1 |
---|
133 | ;------------------------------------------------------------ |
---|
134 | ; horizontal grid |
---|
135 | ;------------------------------------------------------------ |
---|
136 | ; default case |
---|
137 | glam = glamt[firstx:lastx, firsty:lasty] |
---|
138 | gphi = gphit[firstx:lastx, firsty:lasty] |
---|
139 | ; for the vertical section, 2 cases: |
---|
140 | ; 1) keyword_set(realsection) eq 1: then we use drawsectionbottom.pro |
---|
141 | ; that directly draw the bottom using polyfill and plot. In this case, |
---|
142 | ; the position of the mask must given by the edge of the mask |
---|
143 | ; cells. As we are considering the edges of the mask cells, glam or |
---|
144 | ; gphi as one more point than the mask (if it is possible) |
---|
145 | ; 2) keyword_set(realsection) eq 0: then we draw the mask by contouring |
---|
146 | ; the mask with contour (contouring the level=.5). In this case, the |
---|
147 | ; mask position must be given by the middle on the mask cells. |
---|
148 | CASE type OF |
---|
149 | 'xz':BEGIN |
---|
150 | if keyword_set(realsection) EQ 0 then begin |
---|
151 | if vargrid EQ 'V' OR vargrid EQ 'F' then $ |
---|
152 | glam = glamv[firstx:lastx, firsty:lasty] |
---|
153 | ENDIF ELSE BEGIN ; to drawsectionbottom |
---|
154 | if vargrid EQ 'V' OR vargrid EQ 'F' OR finite(glamu[0]) EQ 0 then $ |
---|
155 | glam = glamf[0 > (firstx-1):lastx, firsty:lasty] $ |
---|
156 | ELSE glam = glamu[0 > (firstx-1):lastx, firsty:lasty] |
---|
157 | ENDELSE |
---|
158 | END |
---|
159 | 'yz':BEGIN |
---|
160 | if keyword_set(realsection) EQ 0 then begin |
---|
161 | if vargrid EQ 'U' OR vargrid EQ 'F' then $ |
---|
162 | gphi = gphiu[firstx:lastx, firsty:lasty] |
---|
163 | ENDIF ELSE BEGIN ; to drawsectionbottom |
---|
164 | if vargrid EQ 'U' OR vargrid EQ 'F' OR finite(gphiv[0]) EQ 0 then $ |
---|
165 | gphi = gphif[firstx:lastx, 0 > (firsty-1):lasty] $ |
---|
166 | ELSE gphi = gphiv[firstx:lastx, 0 > (firsty-1):lasty] |
---|
167 | ENDELSE |
---|
168 | END |
---|
169 | ELSE: |
---|
170 | ENDCASE |
---|
171 | ;------------------------------------------------------------ |
---|
172 | ; vertical boundaries |
---|
173 | ;------------------------------------------------------------ |
---|
174 | if keyword_set(wdepth) then begin |
---|
175 | firstz = 0 > (min([firstzt, firstzw])-1) |
---|
176 | lastz = (max([lastzt, lastzw])+1) < (jpk-1) |
---|
177 | ENDIF ELSE BEGIN |
---|
178 | firstz = firstzt |
---|
179 | lastz = lastzt |
---|
180 | ENDELSE |
---|
181 | nz = lastz-firstz+1 |
---|
182 | ;------------------------------------------------------------ |
---|
183 | ; mask |
---|
184 | ;------------------------------------------------------------ |
---|
185 | case type of |
---|
186 | 'xy':BEGIN |
---|
187 | mask = tmask[firstx:lastx, firsty:lasty, firstz] |
---|
188 | profond = firstz NE 0 |
---|
189 | END |
---|
190 | ; for the verical section, we have to choose the right mask according |
---|
191 | ; to the grid point and to the direction of the section |
---|
192 | 'xz':BEGIN |
---|
193 | if vargrid EQ 'V' OR vargrid EQ 'F' then begin |
---|
194 | mask = (vmask())[firstx:lastx, firstyv:lastyv, firstz:lastz] |
---|
195 | ENDIF ELSE mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
196 | END |
---|
197 | 'yz':BEGIN |
---|
198 | if vargrid EQ 'U' OR vargrid EQ 'F' then begin |
---|
199 | mask = (umask())[firstxu:lastxu, firsty:lasty, firstz:lastz] |
---|
200 | ENDIF ELSE mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
201 | END |
---|
202 | ELSE:mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
203 | endcase |
---|
204 | ;------------------------------------------------------------ |
---|
205 | ; vertical axis |
---|
206 | ;------------------------------------------------------------ |
---|
207 | ; when we do a real section we directly plot the gdepw |
---|
208 | ; (in drawsectionbottom.pro) instead of contouring the mask at 0.5 at |
---|
209 | ; gdept |
---|
210 | IF keyword_set(realsection) EQ 0 then gdep = gdept[firstz:lastz] $ |
---|
211 | ELSE BEGIN |
---|
212 | ; if lastz EQ jpk-1 then $ |
---|
213 | ; we add some fictive very deep level that will not be used but that is |
---|
214 | ; necessary to avoid array size bugs in draw bottom section |
---|
215 | ; gdep = [gdepw[firstz+1:lastz], 2*gdept[jpk-1]] $ |
---|
216 | ; ELSE gdep = gdepw[firstz+1:lastz+1] |
---|
217 | gdep = gdepw[firstz:lastz] |
---|
218 | ; special case when we are using the partial steps in the vertical |
---|
219 | ; section that are only 1 point wide. |
---|
220 | ; in that case, the z axis is a 2d array and we modify the depth of |
---|
221 | ; the last level ocean with hdepw that is the real depth of the bottom. |
---|
222 | CASE 1 OF |
---|
223 | keyword_set(key_partialstep) and type EQ 'xz' $ |
---|
224 | AND ny EQ 1 AND keyword_set(realsection):BEGIN |
---|
225 | bottom = total(mask, 3) |
---|
226 | good = where(bottom NE 0 AND bottom NE nz+1) |
---|
227 | bottom = lindgen(nx)+(bottom)*nx |
---|
228 | IF good[0] NE -1 THEN BEGIN |
---|
229 | bottom = bottom[good] |
---|
230 | gdep = replicate(1, nx)#gdep |
---|
231 | truegdep = hdepw[firstx:lastx, firsty:lasty] |
---|
232 | gdep[bottom] = truegdep[good] |
---|
233 | ENDIF |
---|
234 | END |
---|
235 | keyword_set(key_partialstep) and type EQ 'yz' $ |
---|
236 | AND nx EQ 1 AND keyword_set(realsection):BEGIN |
---|
237 | bottom = total(mask, 3) |
---|
238 | good = where(bottom NE 0 AND bottom NE nz+1) |
---|
239 | bottom = lindgen(ny)+(bottom)*ny |
---|
240 | IF good[0] NE -1 THEN BEGIN |
---|
241 | bottom = bottom[good] |
---|
242 | gdep = replicate(1, ny)#gdep |
---|
243 | truegdep = hdepw[firstx:lastx, firsty:lasty] |
---|
244 | gdep[bottom] = truegdep[good] |
---|
245 | ENDIF |
---|
246 | END |
---|
247 | ELSE: |
---|
248 | ENDCASE |
---|
249 | ENDELSE |
---|
250 | ;------------------------------------------------------------ |
---|
251 | ; Triangulation vector when TRI is activated. |
---|
252 | ;------------------------------------------------------------ |
---|
253 | IF arg_present(TRI) then $ |
---|
254 | if triangles_list[0] EQ -1 OR usetri LT 1 then tri = -1 ELSE BEGIN |
---|
255 | ; If we are tracing a deep level, we redo the triangulation |
---|
256 | if keyword_set(profond) then begin |
---|
257 | tri = triangule(mask, coinmonte = coinmonte, coindescend = coindescend, _extra = ex) |
---|
258 | indicezoom = (lindgen(jpi, jpj))[firstx:lastx, firsty:lasty] |
---|
259 | ENDIF ELSE BEGIN |
---|
260 | ; Otherwise, we recuperate the part of triangulation that interest us and we number them well!! |
---|
261 | if nx EQ jpi AND ny EQ jpj then tri = triangles_list ELSE BEGIN |
---|
262 | msk = bytarr(jpi, jpj) |
---|
263 | msk[firstx:lastx, firsty:lasty] = 1 |
---|
264 | ind = where( msk[triangles_list[0, *]] EQ 1 $ |
---|
265 | AND msk[triangles_list[1, *]] EQ 1 $ |
---|
266 | AND msk[triangles_list[2, *]] EQ 1 ) |
---|
267 | tri = triangles_list[*, ind]-(firstx+firsty*jpi) |
---|
268 | y = tri/jpi |
---|
269 | x = tri-y*jpi |
---|
270 | tri = x+y*nx |
---|
271 | ENDELSE |
---|
272 | ENDELSE |
---|
273 | ENDELSE |
---|
274 | ;------------------------------------------------------------------- |
---|
275 | if keyword_set(key_performance) THEN print, 'temps decoupeterre', systime(1)-tempsun |
---|
276 | ;------------------------------------------------------------ |
---|
277 | return |
---|
278 | end |
---|
279 | |
---|