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

Last change on this file since 134 was 134, checked in by navarro, 18 years ago

change *.pro file properties (del eof-style, del executable, set keywords Id

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:tracegrille
6;
7; PURPOSE:dessine la grille
8;
9; CATEGORY:
10;
11; CALLING SEQUENCE:tracegrille
12;
13; INPUTS:glam et gphi, les tableaux 1d ou 2d des position en
14; longitude/latitude des points de la grille. Si glam et gphi ne sont
15; pas specifies, trace la grille specifiee par vargrid, sur le domaine
16; definit par le dernier domdef.
17;
18; KEYWORD PARAMETERS:
19;
20;        XSTRIDE un entier pour specifier qu''on ne veut tracer
21;        qu''une ligne de i constant tout les xstride points
22;
23;        YSTRIDE un entier pour specifier qu''on ne veut tracer
24;        qu''une ligne de j constant tout les ystride points
25;
26;        /OCEAN: pour ne tracer la grille que sur les points oceans
27;
28;        /EARTH: pour ne tracer la grille que sur les points terre
29;
30;        /RMOUT:select to remove all cell having one corner out of the
31;        plot boundaries (!x.range, !y.range)
32;
33;        + tous les mots clefs de la procedure PLOTS
34;
35; OUTPUTS:none
36;
37; COMMON BLOCKS:common.pro
38;
39; SIDE EFFECTS:
40;
41; RESTRICTIONS:
42;
43; EXAMPLE:
44;
45;     IDL> plt,indgen(jpi,jpj),/nocontour,/nofill
46;     IDL> vargrid='T'
47;     IDL> tracegrille,/ocean,color=20
48;     IDL> tracegrille,/earth,color=80
49;
50;
51; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
52;                     
53;-
54;------------------------------------------------------------
55;------------------------------------------------------------
56;------------------------------------------------------------
57PRO tracegrille, glamin, gphiin, OCEAN = ocean, EARTH = earth $
58                 , XSTRIDE = xstride, YSTRIDE = ystride, RMOUT = rmout $
59                 , _extra = extra
60;---------------------------------------------------------
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)          ; pour 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 key_gridtype 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 key_gridtype 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.