1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME:decoupeterre |
---|
6 | ; |
---|
7 | ; PURPOSE:tres semblable a grille. Ici qd vargrid ne 'T' ou 'W' alors |
---|
8 | ; pour le trace il faut recuperer Tmask, glamt, gphit et le tableau de |
---|
9 | ; triangulation sur le sous domaine considere. La specificite de |
---|
10 | ; decoupeterre par rapport a grille, c''est que l''on prend ds la |
---|
11 | ; mesure du possible un sous domaine juste un peu plus grand que celui |
---|
12 | ; definit par domdef de facon a etre sur que le masque que l''on trace |
---|
13 | ; recouvrira bien tout le dessin. |
---|
14 | ; |
---|
15 | ; CATEGORY:pour plt |
---|
16 | ; |
---|
17 | ; CALLING SEQUENCE:decoupeterre, mask, glam, gphi, z, nx, ny, nz, TRI = tri |
---|
18 | ; |
---|
19 | ; INPUTS: |
---|
20 | ; |
---|
21 | ; KEYWORD PARAMETERS: |
---|
22 | ; TRI si ce mot clef sert a obtenir grace a grille la |
---|
23 | ; triangulation qui se rapporte a la grille mais uniquement |
---|
24 | ; sur la partie du zoom. ce tableau de triangulation reduit |
---|
25 | ; est passe ds la variable que l''on a egalee a tri.par ex: |
---|
26 | ; grille,...,tri=triangulation_reduite. ne mot clef est |
---|
27 | ; utilise dans plt.pro |
---|
28 | ; |
---|
29 | ; /WDEPTH: to specify that the field is at W depth instad of T |
---|
30 | ; depth (automatically activated if vargrid eq 'W') |
---|
31 | ; |
---|
32 | ; |
---|
33 | ; OUTPUTS:le masque et ses coordonnees |
---|
34 | ; |
---|
35 | ; COMMON BLOCKS: |
---|
36 | ; common.pro |
---|
37 | ; |
---|
38 | ; SIDE EFFECTS: |
---|
39 | ; |
---|
40 | ; RESTRICTIONS: |
---|
41 | ; |
---|
42 | ; EXAMPLE: |
---|
43 | ; |
---|
44 | ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
45 | ; 24/2/99 |
---|
46 | ;- |
---|
47 | ;------------------------------------------------------------ |
---|
48 | ;------------------------------------------------------------ |
---|
49 | ;------------------------------------------------------------ |
---|
50 | PRO decoupeterre, mask, glam, gphi, gdep, TYPE = type, TRI = tri, INDICEZOOM = indicezoom, COINMONTE = coinmonte, COINDESCEND = coindescend, WDEPTH = wdepth, REALSECTION = realsection, USETRI = usetri, _extra = ex |
---|
51 | ;--------------------------------------------------------- |
---|
52 | ; |
---|
53 | compile_opt idl2, strictarrsubs |
---|
54 | ; |
---|
55 | @cm_4mesh |
---|
56 | @cm_4data |
---|
57 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
58 | @updatenew |
---|
59 | ENDIF |
---|
60 | ;--------------------------------------------------------- |
---|
61 | tempsun = systime(1) ; pour key_performance |
---|
62 | ;------------------------------------------------------------ |
---|
63 | if vargrid EQ 'W' then wdepth = 1 |
---|
64 | ;------------------------------------------------------------ |
---|
65 | ;------------------------------------------------------------ |
---|
66 | ; horizontal parameters |
---|
67 | ;------------------------------------------------------------ |
---|
68 | ; if possible extent the domain according to the grid type |
---|
69 | ; default case |
---|
70 | case vargrid of |
---|
71 | 'U':BEGIN |
---|
72 | firstx = 0 > (min([firstxt, firstxu])-1) |
---|
73 | lastx = (max([lastxt, lastxu])+1) < (jpi-1) |
---|
74 | firsty = 0 > (min([firstyt, firstyu])-1) |
---|
75 | lasty = (max([lastyt, lastyu])+1) < (jpj-1) |
---|
76 | end |
---|
77 | 'V':BEGIN |
---|
78 | firstx = 0 > (min([firstxt, firstxv])-1) |
---|
79 | lastx = (max([lastxt, lastxv])+1) < (jpi-1) |
---|
80 | firsty = 0 > (min([firstyt, firstyv])-1) |
---|
81 | lasty = (max([lastyt, lastyv])+1) < (jpj-1) |
---|
82 | end |
---|
83 | 'F':BEGIN |
---|
84 | firstx = 0 > (min([firstxt, firstxf])-1) |
---|
85 | lastx = (max([lastxt, lastxf])+1) < (jpi-1) |
---|
86 | firsty = 0 > (min([firstyt, firstyf])-1) |
---|
87 | lasty = (max([lastyt, lastyf])+1) < (jpj-1) |
---|
88 | END |
---|
89 | ELSE:BEGIN |
---|
90 | firstx = firstxt |
---|
91 | lastx = lastxt |
---|
92 | firsty = firstyt |
---|
93 | lasty = lastyt |
---|
94 | END |
---|
95 | ENDCASE |
---|
96 | ; however for the vertical section we don''t whant to extent the domain |
---|
97 | ; in the direction perpendicular to the vertical section |
---|
98 | if type EQ 'xz' then begin |
---|
99 | case vargrid of |
---|
100 | 'U':BEGIN |
---|
101 | firsty = firstyu |
---|
102 | lasty = lastyu |
---|
103 | END |
---|
104 | 'V':BEGIN |
---|
105 | firsty = firstyv |
---|
106 | lasty = lastyv |
---|
107 | END |
---|
108 | 'F':BEGIN |
---|
109 | firsty = firstyf |
---|
110 | lasty = lastyf |
---|
111 | END |
---|
112 | ELSE: |
---|
113 | ENDCASE |
---|
114 | endif |
---|
115 | ; |
---|
116 | if type EQ 'yz' then begin |
---|
117 | case vargrid of |
---|
118 | 'U':BEGIN |
---|
119 | firstx = firstxu |
---|
120 | lastx = lastxu |
---|
121 | END |
---|
122 | 'V':BEGIN |
---|
123 | firstx = firstxv |
---|
124 | lastx = lastxv |
---|
125 | END |
---|
126 | 'F':BEGIN |
---|
127 | firstx = firstxf |
---|
128 | lastx = lastxf |
---|
129 | END |
---|
130 | ELSE: |
---|
131 | ENDCASE |
---|
132 | endif |
---|
133 | ; |
---|
134 | nx = lastx-firstx+1 |
---|
135 | ny = lasty-firsty+1 |
---|
136 | ;------------------------------------------------------------ |
---|
137 | ; horizontal grid |
---|
138 | ;------------------------------------------------------------ |
---|
139 | ; default case |
---|
140 | glam = glamt[firstx:lastx, firsty:lasty] |
---|
141 | gphi = gphit[firstx:lastx, firsty:lasty] |
---|
142 | ; for the vertical section, 2 cases: |
---|
143 | ; 1) keyword_set(realsection) eq 1: then we use drawsectionbottom.pro |
---|
144 | ; that directly draw the bottom using polyfill and plot. In this case, |
---|
145 | ; the position of the mask must given by the edge of the mask |
---|
146 | ; cells. As we are considering the edges of the mask cells, glam or |
---|
147 | ; gphi as one more point than the mask (if it is possible) |
---|
148 | ; 2) keyword_set(realsection) eq 0: then we draw the mask by contouring |
---|
149 | ; the mask with contour (contouring the level=.5). In this case, the |
---|
150 | ; mask position must be given by the middle on the mask cells. |
---|
151 | CASE type OF |
---|
152 | 'xz':BEGIN |
---|
153 | if keyword_set(realsection) EQ 0 then begin |
---|
154 | if vargrid EQ 'V' OR vargrid EQ 'F' then $ |
---|
155 | glam = glamv[firstx:lastx, firsty:lasty] |
---|
156 | ENDIF ELSE BEGIN ; to drawsectionbottom |
---|
157 | if vargrid EQ 'V' OR vargrid EQ 'F' OR finite(glamu[0]) EQ 0 then $ |
---|
158 | glam = glamf[0 > (firstx-1):lastx, firsty:lasty] $ |
---|
159 | ELSE glam = glamu[0 > (firstx-1):lastx, firsty:lasty] |
---|
160 | ENDELSE |
---|
161 | END |
---|
162 | 'yz':BEGIN |
---|
163 | if keyword_set(realsection) EQ 0 then begin |
---|
164 | if vargrid EQ 'U' OR vargrid EQ 'F' then $ |
---|
165 | gphi = gphiu[firstx:lastx, firsty:lasty] |
---|
166 | ENDIF ELSE BEGIN ; to drawsectionbottom |
---|
167 | if vargrid EQ 'U' OR vargrid EQ 'F' OR finite(gphiv[0]) EQ 0 then $ |
---|
168 | gphi = gphif[firstx:lastx, 0 > (firsty-1):lasty] $ |
---|
169 | ELSE gphi = gphiv[firstx:lastx, 0 > (firsty-1):lasty] |
---|
170 | ENDELSE |
---|
171 | END |
---|
172 | ELSE: |
---|
173 | ENDCASE |
---|
174 | ;------------------------------------------------------------ |
---|
175 | ; vertical boundaries |
---|
176 | ;------------------------------------------------------------ |
---|
177 | if keyword_set(wdepth) then begin |
---|
178 | firstz = 0 > (min([firstzt, firstzw])-1) |
---|
179 | lastz = (max([lastzt, lastzw])+1) < (jpk-1) |
---|
180 | ENDIF ELSE BEGIN |
---|
181 | firstz = firstzt |
---|
182 | lastz = lastzt |
---|
183 | ENDELSE |
---|
184 | nz = lastz-firstz+1 |
---|
185 | ;------------------------------------------------------------ |
---|
186 | ; mask |
---|
187 | ;------------------------------------------------------------ |
---|
188 | case type of |
---|
189 | 'xy':BEGIN |
---|
190 | mask = tmask[firstx:lastx, firsty:lasty, firstz] |
---|
191 | profond = firstz NE 0 |
---|
192 | END |
---|
193 | ; for the verical section, we have to choose the right mask according |
---|
194 | ; to the grid point and to the direction of the section |
---|
195 | 'xz':BEGIN |
---|
196 | if vargrid EQ 'V' OR vargrid EQ 'F' then begin |
---|
197 | mask = (vmask())[firstx:lastx, firstyv:lastyv, firstz:lastz] |
---|
198 | ENDIF ELSE mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
199 | END |
---|
200 | 'yz':BEGIN |
---|
201 | if vargrid EQ 'U' OR vargrid EQ 'F' then begin |
---|
202 | mask = (umask())[firstxu:lastxu, firsty:lasty, firstz:lastz] |
---|
203 | ENDIF ELSE mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
204 | END |
---|
205 | ELSE:mask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] |
---|
206 | endcase |
---|
207 | ;------------------------------------------------------------ |
---|
208 | ; vertical axis |
---|
209 | ;------------------------------------------------------------ |
---|
210 | ; when we do a real section we directly plot the gdepw |
---|
211 | ; (in drawsectionbottom.pro) instead of contouring the mask at 0.5 at |
---|
212 | ; gdept |
---|
213 | IF keyword_set(realsection) EQ 0 then gdep = gdept[firstz:lastz] $ |
---|
214 | ELSE BEGIN |
---|
215 | ; if lastz EQ jpk-1 then $ |
---|
216 | ; we add some fictive very deep level that will not be used but that is |
---|
217 | ; necessary to avoid array size bugs in draw bottom section |
---|
218 | ; gdep = [gdepw[firstz+1:lastz], 2*gdept[jpk-1]] $ |
---|
219 | ; ELSE gdep = gdepw[firstz+1:lastz+1] |
---|
220 | gdep = gdepw[firstz:lastz] |
---|
221 | ; special case when we are using the partial steps in the vertical |
---|
222 | ; section that are only 1 point wide. |
---|
223 | ; in that case, the z axis is a 2d array and we modify the depth of |
---|
224 | ; the last level ocean with hdepw that is the real depth of the bottom. |
---|
225 | CASE 1 OF |
---|
226 | keyword_set(key_partialstep) and type EQ 'xz' $ |
---|
227 | AND ny EQ 1 AND keyword_set(realsection):BEGIN |
---|
228 | bottom = total(mask, 3) |
---|
229 | good = where(bottom NE 0 AND bottom NE nz+1) |
---|
230 | bottom = lindgen(nx)+(bottom)*nx |
---|
231 | IF good[0] NE -1 THEN BEGIN |
---|
232 | bottom = bottom[good] |
---|
233 | gdep = replicate(1, nx)#gdep |
---|
234 | truegdep = hdepw[firstx:lastx, firsty:lasty] |
---|
235 | gdep[bottom] = truegdep[good] |
---|
236 | ENDIF |
---|
237 | END |
---|
238 | keyword_set(key_partialstep) and type EQ 'yz' $ |
---|
239 | AND nx EQ 1 AND keyword_set(realsection):BEGIN |
---|
240 | bottom = total(mask, 3) |
---|
241 | good = where(bottom NE 0 AND bottom NE nz+1) |
---|
242 | bottom = lindgen(ny)+(bottom)*ny |
---|
243 | IF good[0] NE -1 THEN BEGIN |
---|
244 | bottom = bottom[good] |
---|
245 | gdep = replicate(1, ny)#gdep |
---|
246 | truegdep = hdepw[firstx:lastx, firsty:lasty] |
---|
247 | gdep[bottom] = truegdep[good] |
---|
248 | ENDIF |
---|
249 | END |
---|
250 | ELSE: |
---|
251 | ENDCASE |
---|
252 | ENDELSE |
---|
253 | ;------------------------------------------------------------ |
---|
254 | ; vecteur triangulation Qd TRI est active |
---|
255 | ;------------------------------------------------------------ |
---|
256 | IF arg_present(TRI) then $ |
---|
257 | if triangles_list[0] EQ -1 OR usetri LT 1 then tri = -1 ELSE BEGIN |
---|
258 | ; si on est en train de tracer un niveau profond on refait la |
---|
259 | ; triangulation |
---|
260 | if keyword_set(profond) then begin |
---|
261 | tri = triangule(mask, coinmonte = coinmonte, coindescend = coindescend, _extra = ex) |
---|
262 | indicezoom = (lindgen(jpi, jpj))[firstx:lastx, firsty:lasty] |
---|
263 | ENDIF ELSE BEGIN |
---|
264 | ; sinon on recupere la partie de triangulation qui nous interesse et |
---|
265 | ; on la numerote convenablement! |
---|
266 | if nx EQ jpi AND ny EQ jpj then tri = triangles_list ELSE BEGIN |
---|
267 | msk = bytarr(jpi, jpj) |
---|
268 | msk[firstx:lastx, firsty:lasty] = 1 |
---|
269 | ind = where( msk[triangles_list[0, *]] EQ 1 $ |
---|
270 | AND msk[triangles_list[1, *]] EQ 1 $ |
---|
271 | AND msk[triangles_list[2, *]] EQ 1 ) |
---|
272 | tri = triangles_list[*, ind]-(firstx+firsty*jpi) |
---|
273 | y = tri/jpi |
---|
274 | x = tri-y*jpi |
---|
275 | tri = x+y*nx |
---|
276 | ENDELSE |
---|
277 | ENDELSE |
---|
278 | ENDELSE |
---|
279 | ;------------------------------------------------------------------- |
---|
280 | if keyword_set(key_performance) THEN print, 'temps decoupeterre', systime(1)-tempsun |
---|
281 | ;------------------------------------------------------------ |
---|
282 | return |
---|
283 | end |
---|
284 | |
---|