source: trunk/SRC/ToBeReviewed/GRILLE/tracegrille.pro @ 231

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

improvements/corrections of some *.pro headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
1;+
2;
3; @file_comments
4; Draw the grid
5;
6; @categories
7;
8; @param GLAMIN {in}{required}
9; The 1d or 2d array in longitude of points of the grid.If GLAM/GLAMIN
10; is not specified, it trace the grid specified by vargrid, on the
11; domain defined by domdef.
12;
13; @param GPHIIN {in}{required}
14; The 1d or 2d array in latitude of points of the grid.If GPHI/GPHIIN
15; is not specified, it trace the grid specified by vargrid, on the
16; domain defined by domdef.
17;
18; @keyword XSTRIDE {type=integer}
19; It specify that we want to trace only one line of
20; constant i every xstride points
21;
22; @keyword YSTRIDE {type=integer}
23; It specify that we want to trace only one line of
24; constant j every xstride points
25;
26; @keyword OCEAN
27; To trace the grid only on ocean points.
28;
29; @keyword EARTH
30; To trace the grid only on land points.
31;
32; @keyword RMOUT
33; Select to remove all cell having one corner out of the
34; plot boundaries (!x.range, !y.range)
35;
36; @keyword _EXTRA
37; Used to pass keywords
38;
39; @uses
40; common.pro
41;
42; @examples
43;
44;     IDL> plt,indgen(jpi,jpj),/nocontour,/nofill
45;     IDL> vargrid='T'
46;     IDL> tracegrille,/ocean,color=20
47;     IDL> tracegrille,/earth,color=80
48;
49;
50; @history
51; Sebastien Masson (smasson\@lodyc.jussieu.fr)
52;
53; @version
54; $Id$
55;
56;-
57;
58PRO tracegrille, glamin, gphiin, OCEAN = ocean, EARTH = earth $
59                 , XSTRIDE = xstride, YSTRIDE = ystride, RMOUT = rmout $
60                 , _extra = extra
61;
62  compile_opt idl2, strictarrsubs
63;
64@cm_4mesh
65@cm_4data
66  IF NOT keyword_set(key_forgetold) THEN BEGIN
67@updatenew
68  ENDIF
69;---------------------------------------------------------
70  tempsun = systime(1)          ; For key_performance
71; to avoid warning message
72  oldexcept = !except
73  !except = 0
74  if n_elements(key_gridtype) EQ 0 then key_gridtype = 'c'
75;
76  if n_elements(glamin) * n_elements(gphiin) EQ 0 then BEGIN
77    grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz
78    IF keyword_set(ocean) AND strmid(key_gridtype, 0, 1) EQ 'c' THEN BEGIN
79; we reduce the mask to take into account the point located ON the coastline.
80      CASE vargrid OF
81        'U':BEGIN
82          mask = tmask[firstx:lastx, firsty:lasty]
83          IF NOT keyword_set(key_periodic) OR nx NE jpi $
84            THEN tmpx = mask[nx-1, *]
85          mask = (mask+shift(mask, -1, 0)) < 1
86          IF NOT keyword_set(key_periodic) OR nx NE jpi $
87            THEN mask[nx-1, *] = temporary(tmpx)
88        END
89        'V':BEGIN
90          mask = tmask[firstx:lastx, firsty:lasty]
91          tmpy = mask[*, ny-1]
92          mask = (mask+shift(mask, 0, -1)) < 1
93          mask[*, ny-1] = temporary(tmpy)
94        END
95        'F':BEGIN
96          mask = tmask[firstx:lastx, firsty:lasty]
97          IF NOT keyword_set(key_periodic) OR nx NE jpi $
98            THEN tmpx = mask[nx-1, *]
99          tmpy = mask[*, ny-1]
100          mask = (mask+shift(mask, -1, 0)+shift(mask, 0, -1)+shift(mask, -1, -1)) < 1
101          mask[*, ny-1] = temporary(tmpy)
102          IF NOT keyword_set(key_periodic) OR nx NE jpi $
103            THEN mask[nx-1, *] = temporary(tmpx)
104        END
105        ELSE:
106      ENDCASE
107    ENDIF
108  ENDIF ELSE BEGIN
109    glam = glamin
110    gphi = gphiin
111    IF (size(glam))[0] EQ 1 AND (size(gphi))[0] EQ 1 THEN BEGIN
112      nx = n_elements(glam)
113      ny = n_elements(gphi)
114      glam = glam#replicate(1, ny)
115      gphi = replicate(1, nx)#gphi
116    ENDIF ELSE BEGIN
117      nx = (size(glam))[1]
118      ny = (size(glam))[2]
119    ENDELSE
120  ENDELSE
121  if n_elements(mask) EQ 0 then mask = replicate(1b, nx, ny)
122  if (size(mask))[0] EQ 3 then mask = mask[*, *, 0]
123;
124  IF keyword_set(RMOUT) THEN BEGIN
125    out = where(glam GT max(!x.range) OR glam LT min(!x.range) $
126                OR gphi GT max(!y.range) OR gphi LT min(!y.range))
127    IF out[0] NE -1 THEN BEGIN
128      glam[out] = !values.f_nan
129      gphi[out] = !values.f_nan
130    ENDIF
131  ENDIF
132;
133  IF keyword_set(ocean) then BEGIN
134    earth = where(mask EQ 0)
135    if earth[0] NE -1 then begin
136      glam[earth] = !values.f_nan
137      gphi[earth] = !values.f_nan
138    ENDIF
139    earth = 0
140  ENDIF
141;
142  IF keyword_set(earth) THEN BEGIN
143    ocean = where(mask EQ 1)
144    if ocean[0] NE -1 then begin
145      glam[ocean] = !values.f_nan
146      gphi[ocean] = !values.f_nan
147    ENDIF
148    ocean = 0
149  ENDIF
150;
151  if NOT keyword_set(xstride) then xstride = 1
152  if NOT keyword_set(ystride) then ystride = 1
153  case strmid(key_gridtype, 0, 1) of
154    'c':BEGIN
155      for i = 0, ny-1, ystride do begin
156        plots,  glam[*, i], gphi[*, i], _extra = extra
157      endfor
158      for i = 0, nx-1, xstride do begin
159        plots,  glam[i, *], gphi[i, *], _extra = extra
160      endfor
161    END
162    'e':BEGIN
163      shifted = glam[0, 0] LT glam[0, 1]
164      glam2 = glam+(glam[1]-glam[0])/2.
165      if shifted then begin
166        for i = 0, ny-2 do BEGIN
167          xx = (transpose([[glam[*, i]], [glam2[*, i]]]))[*]
168          yy = (transpose([[gphi[*, i]], [gphi[*, i+1]]]))[*]
169          plots, xx[0:2*nx-2], yy[0:2*nx-2], _extra = extra
170        ENDFOR
171      ENDIF ELSE BEGIN
172        for i = 1, ny-1 do BEGIN
173          xx = (transpose([[glam[*, i]], [glam2[*, i]]]))[*]
174          yy = (transpose([[gphi[*, i]], [gphi[*, i-1]]]))[*]
175          plots, xx[0:2*nx-2], yy[0:2*nx-2], _extra = extra
176        ENDFOR
177      ENDELSE
178      for i = 1, (ny-1)/2 do $
179        plots, [glam[0, 2*i-1], glam[0, 2*i]] $
180        , [gphi[0, 2*i-1], gphi[0, 2*i]], _extra = extra
181      for i = 0, (ny-2)/2 do $
182        plots, [glam[nx-1, 2*i], glam[nx-1, 2*i+1]] $
183        , [gphi[nx-1, 2*i], gphi[nx-1, 2*i+1]], _extra = extra
184    END
185  endcase
186
187  if keyword_set(key_performance) THEN print, 'temps trace grille', systime(1)-tempsun
188  !except = oldexcept
189
190  return
191end
Note: See TracBrowser for help on using the repository browser.