source: trunk/SRC/ToBeReviewed/GRILLE/decoupeterre.pro @ 388

Last change on this file since 388 was 388, checked in by smasson, 16 years ago

introduce meridional and barotropic stream functions, see ticket:59

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