source: trunk/ToBeReviewed/GRILLE/tracegrille.pro @ 13

Last change on this file since 13 was 13, checked in by pinsard, 18 years ago

upgrade of GRILLE/Utilities according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/ : files

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 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@cm_4mesh
62@cm_4data
63  IF NOT keyword_set(key_forgetold) THEN BEGIN
64@updatenew
65  ENDIF
66;---------------------------------------------------------
67  tempsun = systime(1)          ; pour key_performance
68; to avoid warning message
69  oldexcept = !except
70  !except = 0
71  if n_elements(key_gridtype) EQ 0 then key_gridtype = 'c'
72;
73  if n_elements(glamin) * n_elements(gphiin) EQ 0 then BEGIN
74    grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz
75    IF keyword_set(ocean) AND key_gridtype EQ 'c' THEN BEGIN
76; we reduce the mask to take into account the point located ON the coastline.
77      CASE vargrid OF
78        'U':BEGIN
79          mask = tmask[firstx:lastx, firsty:lasty]
80          IF NOT keyword_set(key_periodic) OR nx NE jpi $
81            THEN tmpx = mask[nx-1, *]
82          mask = (mask+shift(mask, -1, 0)) < 1
83          IF NOT keyword_set(key_periodic) OR nx NE jpi $
84            THEN mask[nx-1, *] = temporary(tmpx)
85        END
86        'V':BEGIN
87          mask = tmask[firstx:lastx, firsty:lasty]
88          tmpy = mask[*, ny-1]
89          mask = (mask+shift(mask, 0, -1)) < 1
90          mask[*, ny-1] = temporary(tmpy)
91        END
92        'F':BEGIN
93          mask = tmask[firstx:lastx, firsty:lasty]
94          IF NOT keyword_set(key_periodic) OR nx NE jpi $
95            THEN tmpx = mask[nx-1, *]
96          tmpy = mask[*, ny-1]
97          mask = (mask+shift(mask, -1, 0)+shift(mask, 0, -1)+shift(mask, -1, -1)) < 1
98          mask[*, ny-1] = temporary(tmpy)
99          IF NOT keyword_set(key_periodic) OR nx NE jpi $
100            THEN mask[nx-1, *] = temporary(tmpx)
101        END
102        ELSE:
103      ENDCASE
104    ENDIF
105  ENDIF ELSE BEGIN
106    glam = glamin
107    gphi = gphiin
108    IF (size(glam))[0] EQ 1 AND (size(gphi))[0] EQ 1 THEN BEGIN
109      nx = n_elements(glam)
110      ny = n_elements(gphi)
111      glam = glam#replicate(1, ny)
112      gphi = replicate(1, nx)#gphi
113    ENDIF ELSE BEGIN
114      nx = (size(glam))[1]
115      ny = (size(glam))[2]
116    ENDELSE
117  ENDELSE
118  if n_elements(mask) EQ 0 then mask = replicate(1b, nx, ny)
119  if (size(mask))[0] EQ 3 then mask = mask[*, *, 0]
120;
121  IF keyword_set(RMOUT) THEN BEGIN
122    out = where(glam GT max(!x.range) OR glam LT min(!x.range) $
123                OR gphi GT max(!y.range) OR gphi LT min(!y.range))
124    IF out[0] NE -1 THEN BEGIN
125      glam[out] = !values.f_nan
126      gphi[out] = !values.f_nan
127    ENDIF
128  ENDIF
129;
130  IF keyword_set(ocean) then BEGIN
131    earth = where(mask EQ 0)
132    if earth[0] NE -1 then begin
133      glam[earth] = !values.f_nan
134      gphi[earth] = !values.f_nan
135    ENDIF
136    earth = 0
137  ENDIF
138;
139  IF keyword_set(earth) THEN BEGIN
140    ocean = where(mask EQ 1)
141    if ocean[0] NE -1 then begin
142      glam[ocean] = !values.f_nan
143      gphi[ocean] = !values.f_nan
144    ENDIF
145    ocean = 0
146  ENDIF
147;
148  if NOT keyword_set(xstride) then xstride = 1
149  if NOT keyword_set(ystride) then ystride = 1
150  case key_gridtype of
151    'c':BEGIN
152      for i = 0, ny-1, ystride do begin
153        plots,  glam[*, i], gphi[*, i], _extra = extra
154      endfor
155      for i = 0, nx-1, xstride do begin
156        plots,  glam[i, *], gphi[i, *], _extra = extra
157      endfor
158    END
159    'e':BEGIN
160      shifted = glam[0, 0] LT glam[0, 1]
161      glam2 = glam+(glam[1]-glam[0])/2.
162      if shifted then begin
163        for i = 0, ny-2 do BEGIN
164          xx = (transpose([[glam[*, i]], [glam2[*, i]]]))[*]
165          yy = (transpose([[gphi[*, i]], [gphi[*, i+1]]]))[*]
166          plots, xx[0:2*nx-2], yy[0:2*nx-2], _extra = extra
167        ENDFOR
168      ENDIF ELSE BEGIN
169        for i = 1, ny-1 do BEGIN
170          xx = (transpose([[glam[*, i]], [glam2[*, i]]]))[*]
171          yy = (transpose([[gphi[*, i]], [gphi[*, i-1]]]))[*]
172          plots, xx[0:2*nx-2], yy[0:2*nx-2], _extra = extra
173        ENDFOR
174      ENDELSE
175      for i = 1, (ny-1)/2 do $
176        plots, [glam[0, 2*i-1], glam[0, 2*i]] $
177        , [gphi[0, 2*i-1], gphi[0, 2*i]], _extra = extra
178      for i = 0, (ny-2)/2 do $
179        plots, [glam[nx-1, 2*i], glam[nx-1, 2*i+1]] $
180        , [gphi[nx-1, 2*i], gphi[nx-1, 2*i+1]], _extra = extra
181    END
182  endcase
183
184  if keyword_set(key_performance) THEN print, 'temps trace grille', systime(1)-tempsun
185  !except = oldexcept
186
187  return
188end
Note: See TracBrowser for help on using the repository browser.