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

Last change on this file since 248 was 232, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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