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