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

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

typo

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