1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; interpolate condmag.nc file (sediment and magnetic fields) on ORCA grid |
---|
5 | ; and produce cond_sed_<orcares>.nc and Br_<orcares>.nc |
---|
6 | ; |
---|
7 | ; @categories |
---|
8 | ; interpolation, orca grid |
---|
9 | ; |
---|
10 | ; @param orcares {in}{required}{type=string} |
---|
11 | ; code of ORCA grid to use for output results |
---|
12 | ; must be 'ORCA2' or 'ORCA025' |
---|
13 | ; |
---|
14 | ; @param method {in}{required}{type=string} |
---|
15 | ; code for interpolation method |
---|
16 | ; must be 'bilinear' or 'imoms3' |
---|
17 | ; in fact bilinear is used in this geomag project |
---|
18 | ; ++ est-ce que ce sera tjs vrai ? |
---|
19 | ; |
---|
20 | ; @param gridtype {in}{required}{type=string} |
---|
21 | ; to specify on which grid we do the interpolation T, U, V |
---|
22 | ; must belong to T, U or V |
---|
23 | ; |
---|
24 | ; @keyword DRAKKAR_EXP {type=string} |
---|
25 | ; code for Drakkar experiment |
---|
26 | ; only used when orcares = ORC025 |
---|
27 | ; must be G42 ++ G70 |
---|
28 | ; |
---|
29 | ; @restrictions |
---|
30 | ; - Requires SAXO tools |
---|
31 | ; - must have condmag.nc in ${GEOMAG_ID}/ |
---|
32 | ; - must have meshmask for ORCA2 or ORCA025 in ${GEOMAG_ID}/ |
---|
33 | ; - must not have cond_sed_*.nc in ${GEOMAG_OD}/ |
---|
34 | ; - must not have Br_*.nc in ${GEOMAG_OD}/ |
---|
35 | ; |
---|
36 | ; @todo |
---|
37 | ; provide tools to plot output files |
---|
38 | ; produce a NetCDF GDT or CF compliant |
---|
39 | ; |
---|
40 | ; @pre |
---|
41 | ; be sure to have datafile condmag.nc in the directory defined in |
---|
42 | ; ${GEOMAG_ID}/ see geomag_env.sh |
---|
43 | ; be sure to have meshmask of ORCA grid you choose in the directory defined in |
---|
44 | ; ${GEOMAG_ID}/ |
---|
45 | ; for ORCA2 filename is meshmask_bab.nc |
---|
46 | ; ++ au pif entre mesh_hgr, mesh_zgr et mask |
---|
47 | ; for ORCA0252 filename is ORCA025-G42_mesh_hgr.nc |
---|
48 | ; |
---|
49 | ; @post |
---|
50 | ; cond_sed_<I>orcasres</I>.nc is now present in ${GEOMAG_OD}/ |
---|
51 | ; Br_<I>orcasres</I>.nc is now present in ${GEOMAG_OD}/ |
---|
52 | ; see geomag_env.sh |
---|
53 | ; |
---|
54 | ; @examples |
---|
55 | ; IDL> .run condmag_on_orca |
---|
56 | ; IDL> condmag_on_orca, 'ORCA2', 'bilinear','T' |
---|
57 | ; |
---|
58 | ; @history |
---|
59 | ; reee522 2006-12-13T13:50:32Z rhodes (IRIX64) |
---|
60 | ; add optional keyword drakkar_exp |
---|
61 | ; reee522 2006-12-13T12:09:05Z rhodes (IRIX64) |
---|
62 | ; externalisation of netcdf writing |
---|
63 | ; reee522 2006-11-23T13:34:31Z rhodes (IRIX64) |
---|
64 | ; add ORCA025 (beginning) |
---|
65 | ; reee522 2006-11-23T13:28:07Z rhodes (IRIX64) |
---|
66 | ; information about the opening of meshmask file was missing ... because |
---|
67 | ; the open is hidden in the call of get_gridparam |
---|
68 | ; fplod 2006-11-23T08:57:10Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
69 | ; rename to condmag_on_orca.pro |
---|
70 | ; fplod 2006-11-22T15:10:31Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
71 | ; add creation of Br_<I>orcasres</I>.nc |
---|
72 | ; ++ not very beautifuly implemented |
---|
73 | ; fplod 2006-11-22T10:38:51Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
74 | ; always use msg = 'iii : ...' or msg = 'eee : ...' |
---|
75 | ; information on open io |
---|
76 | ; fplod 2006-11-20T10:32:02Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
77 | ; cleaning before introduction into svn repository |
---|
78 | ; fplod 2006-03-23T13:05:39Z aedon.lodyc.jussieu.fr (Darwin) |
---|
79 | ; cond_sed_ORCA2 presque ok manque attributes min/max de cond_sed |
---|
80 | ; fplod 2006-03-22T09:35:42Z aedon.lodyc.jussieu.fr (Darwin) |
---|
81 | ; created from |
---|
82 | ; /Users/fplod/incas/seb/DORAEMON/wind/idl/quikscat_to_orca_scalar.pro written |
---|
83 | ; by Sebastien Masson |
---|
84 | ; to reproduce /usr/work/sur/fvi/OPA/geomag/cond_sed_ORCA2.nc |
---|
85 | ; main differences : no yyyy parameter, no time loop , no mask and no missing |
---|
86 | ; values (++ to be checked ) in data input (condmag.nc), no scale factor, |
---|
87 | ; no OFFSET, no save of weight and addresses |
---|
88 | ; |
---|
89 | ; @version |
---|
90 | ; $Id$ |
---|
91 | ; |
---|
92 | ;- |
---|
93 | PRO condmag_on_orca, orcares, method, gridtype, DRAKKAR_EXP = drakkar_exp |
---|
94 | ; |
---|
95 | compile_opt idl2, strictarrsubs |
---|
96 | ; |
---|
97 | ;---- |
---|
98 | ; check input parameters |
---|
99 | ;---- |
---|
100 | ; |
---|
101 | ; check orcares definition |
---|
102 | ; |
---|
103 | CASE orcares OF |
---|
104 | 'ORCA2': BEGIN |
---|
105 | msg = 'iii : valid orcares parameter = ' + orcares |
---|
106 | PRINT, msg |
---|
107 | filename_oce = 'meshmask_bab.nc' |
---|
108 | IF keyword_set(DRAKKAR_EXP) THEN BEGIN |
---|
109 | msg = 'www : unused DRAKKAR_EXP keyword = ' + drakkar_exp |
---|
110 | PRINT, msg |
---|
111 | END |
---|
112 | END |
---|
113 | 'ORCA025': BEGIN |
---|
114 | msg = 'iii : valid orcares parameter = ' + orcares |
---|
115 | PRINT, msg |
---|
116 | IF keyword_set(DRAKKAR_EXP) THEN BEGIN |
---|
117 | msg = 'iii : DRAKKAR_EXP keyword set' |
---|
118 | PRINT, msg |
---|
119 | msg = 'iii : DRAKKAR_EXP = ' + drakkar_exp |
---|
120 | PRINT, msg |
---|
121 | CASE drakkar_exp OF |
---|
122 | 'G42' : BEGIN |
---|
123 | msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp |
---|
124 | PRINT, msg |
---|
125 | END |
---|
126 | 'G70' : BEGIN |
---|
127 | msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp |
---|
128 | PRINT, msg |
---|
129 | END |
---|
130 | ELSE : BEGIN |
---|
131 | msg = 'eee : invalid DRAKKAR_EXP keyword = ' + drakkar_exp |
---|
132 | PRINT, msg |
---|
133 | RETURN |
---|
134 | END |
---|
135 | ENDCASE |
---|
136 | filename_oce = orcares + '-' + drakkar_exp + '_mesh_hgr.nc' |
---|
137 | END |
---|
138 | END |
---|
139 | ELSE : BEGIN |
---|
140 | msg = 'eee : invalid orcares parameter = ' + orcares |
---|
141 | PRINT, msg |
---|
142 | msg = 'eee : orcares must be ORCA2 or ORCA025' |
---|
143 | PRINT, msg |
---|
144 | RETURN |
---|
145 | END |
---|
146 | ENDCASE |
---|
147 | ; |
---|
148 | ; check method definition |
---|
149 | CASE method OF |
---|
150 | 'bilinear': BEGIN |
---|
151 | msg = 'iii : valid method parameter = ' + method |
---|
152 | PRINT, msg |
---|
153 | END |
---|
154 | 'imoms3' : BEGIN |
---|
155 | msg = 'iii : valid method parameter = ' + method |
---|
156 | PRINT, msg |
---|
157 | END |
---|
158 | ELSE : BEGIN |
---|
159 | msg = 'eee : invalid method parameter = ' + method |
---|
160 | PRINT, msg |
---|
161 | msg = 'eee : method must be bilinear or imoms3' |
---|
162 | PRINT, msg |
---|
163 | RETURN |
---|
164 | END |
---|
165 | ENDCASE |
---|
166 | ; |
---|
167 | ; check gridtype definition |
---|
168 | gridtype = strupcase(gridtype) |
---|
169 | CASE gridtype OF |
---|
170 | 'T' : BEGIN |
---|
171 | msg = 'iii : valid gridtype parameter = ' + gridtype |
---|
172 | PRINT, msg |
---|
173 | END |
---|
174 | 'U' : BEGIN |
---|
175 | msg = 'iii : valid gridtype parameter = ' + gridtype |
---|
176 | PRINT, msg |
---|
177 | END |
---|
178 | 'V' : BEGIN |
---|
179 | msg = 'iii : valid gridtype parameter = ' + gridtype |
---|
180 | PRINT, msg |
---|
181 | END |
---|
182 | ELSE: BEGIN |
---|
183 | msg = 'eee : invalid gridtype parameter = ' + gridtype |
---|
184 | PRINT, msg |
---|
185 | msg = 'eee : gridtype must be T, U or V' |
---|
186 | PRINT, msg |
---|
187 | RETURN |
---|
188 | END |
---|
189 | ENDCASE |
---|
190 | ; |
---|
191 | ; check for input files |
---|
192 | ; |
---|
193 | ; test if ${GEOMAG_ID} defined |
---|
194 | geomag_id_env=GETENV('GEOMAG_ID') |
---|
195 | CASE geomag_id_env OF |
---|
196 | '' : BEGIN |
---|
197 | msg = 'eee : ${GEOMAG_ID} is not defined' |
---|
198 | PRINT, msg |
---|
199 | RETURN |
---|
200 | END |
---|
201 | ELSE: BEGIN |
---|
202 | msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env |
---|
203 | PRINT, msg |
---|
204 | END |
---|
205 | ENDCASE |
---|
206 | ; |
---|
207 | iodirin = isadirectory(geomag_id_env) |
---|
208 | ; |
---|
209 | ; existence and protection of ${GEOMAG_ID} |
---|
210 | IF (FILE_TEST(iodirin, /DIRECTORY,/EXECUTABLE , /READ) EQ 0) THEN BEGIN |
---|
211 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
212 | PRINT, msg |
---|
213 | RETURN |
---|
214 | ENDIF |
---|
215 | ; |
---|
216 | ; conductivity and magnetic field |
---|
217 | filename_condmag = 'condmag.nc' |
---|
218 | ; |
---|
219 | ; check if this file exists |
---|
220 | fullfilename_condmag = isafile(iodirin + filename_condmag, NEW=0,/MUST_EXIST) |
---|
221 | IF fullfilename_condmag[0] EQ '' THEN BEGIN |
---|
222 | msg = 'eee : the file ' + fullfilename_condmag + ' was not found.' |
---|
223 | PRINT, msg |
---|
224 | RETURN |
---|
225 | ENDIF |
---|
226 | ; |
---|
227 | ; protection |
---|
228 | IF (FILE_TEST(fullfilename_condmag[0], /READ) EQ 0) THEN BEGIN |
---|
229 | msg = 'eee : the file ' + fullfilename_condmag[0] + ' is not readable.' |
---|
230 | PRINT, msg |
---|
231 | RETURN |
---|
232 | ENDIF |
---|
233 | ; |
---|
234 | ; mesh mask |
---|
235 | ; check if this file exists |
---|
236 | fullfilename_oce = isafile(iodirin + filename_oce, NEW=0, /MUST_EXIST, $ |
---|
237 | RECURSIVE=0) |
---|
238 | IF fullfilename_oce[0] EQ '' THEN BEGIN |
---|
239 | msg = 'eee : the file ' + fullfilename_oce + ' was not found.' |
---|
240 | PRINT, msg |
---|
241 | RETURN |
---|
242 | ENDIF |
---|
243 | ; |
---|
244 | ; protection |
---|
245 | IF (FILE_TEST(fullfilename_oce[0], /READ) EQ 0) THEN BEGIN |
---|
246 | msg = 'eee : the file ' + fullfileoce_condmag[0] + ' is not readable.' |
---|
247 | PRINT, msg |
---|
248 | RETURN |
---|
249 | ENDIF |
---|
250 | ; |
---|
251 | ; test if ${GEOMAG_OD} defined |
---|
252 | geomag_od_env=GETENV('GEOMAG_OD') |
---|
253 | CASE geomag_od_env OF |
---|
254 | '' : BEGIN |
---|
255 | msg = 'eee : ${GEOMAG_OD} is not defined' |
---|
256 | PRINT, msg |
---|
257 | RETURN |
---|
258 | END |
---|
259 | ELSE: BEGIN |
---|
260 | msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env |
---|
261 | PRINT, msg |
---|
262 | END |
---|
263 | ENDCASE |
---|
264 | ; |
---|
265 | ; check if output data will be possible |
---|
266 | iodirout = isadirectory(geomag_od_env) |
---|
267 | ; |
---|
268 | ; existence and protection |
---|
269 | IF (FILE_TEST(iodirout, /DIRECTORY,/WRITE) EQ 0) THEN BEGIN |
---|
270 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
271 | PRINT, msg |
---|
272 | RETURN |
---|
273 | ENDIF |
---|
274 | ; |
---|
275 | ; d'après ncdump -h /usr/work/sur/fvi/OPA/geomag/condmag.nc |
---|
276 | condmaglonname = 'lo' |
---|
277 | condmaglatname = 'la' |
---|
278 | ; |
---|
279 | ;---- |
---|
280 | ; conductivity and magnetic field grid parameters |
---|
281 | ;---- |
---|
282 | ; |
---|
283 | get_gridparams, fullfilename_condmag[0], $ |
---|
284 | condmaglonname, condmaglatname, $ |
---|
285 | condmaglon, condmaglat, jpia, jpja, 1,/DOUBLE |
---|
286 | ; |
---|
287 | ;---- |
---|
288 | ; Oceanic grid parameters |
---|
289 | ;---- |
---|
290 | ; |
---|
291 | olonname = 'glam' + STRLOWCASE(gridtype) |
---|
292 | olatname = 'gphi' + STRLOWCASE(gridtype) |
---|
293 | get_gridparams, fullfilename_oce[0], $ |
---|
294 | olonname, olatname, $ |
---|
295 | olon, olat, jpio, jpjo, 2,/DOUBLE |
---|
296 | msg = 'iii : ' + fullfilename_oce[0] + ' opened for read' |
---|
297 | PRINT, msg |
---|
298 | ; |
---|
299 | ;--------------- |
---|
300 | ; Compute weight and address |
---|
301 | ;--------------- |
---|
302 | ; |
---|
303 | CASE method OF |
---|
304 | 'bilinear': compute_fromreg_bilinear_weigaddr, $ |
---|
305 | condmaglon, condmaglat, olon, olat, weig, addr |
---|
306 | 'imoms3' : compute_fromreg_imoms3_weigaddr, $ |
---|
307 | condmaglon, condmaglat, olon, olat, weig, addr |
---|
308 | ENDCASE |
---|
309 | ; |
---|
310 | ; reading condmag file |
---|
311 | netcdf_id_condmag = NCDF_OPEN(fullfilename_condmag[0], /NOWRITE) |
---|
312 | msg = 'iii : ' + fullfilename_condmag[0] + ' opened for read' |
---|
313 | PRINT, msg |
---|
314 | ; |
---|
315 | varname_cond_sed = 'cond_sed' |
---|
316 | varname_br = 'Br' |
---|
317 | ; |
---|
318 | varinq_cond_sed = NCDF_VARINQ(netcdf_id_condmag, varname_cond_sed) |
---|
319 | NCDF_VARGET, netcdf_id_condmag, varname_cond_sed, varin_cond_sed |
---|
320 | ; |
---|
321 | varinq_br = NCDF_VARINQ(netcdf_id_condmag, varname_br) |
---|
322 | NCDF_VARGET, netcdf_id_condmag, varname_br, varin_br |
---|
323 | ; |
---|
324 | NCDF_CLOSE, netcdf_id_condmag |
---|
325 | ; |
---|
326 | ;--------------------------- |
---|
327 | ; do the interpolation |
---|
328 | varin_cond_sed = TOTAL(weig*varin_cond_sed[addr], 1) |
---|
329 | varin_cond_sed = REFORM(varin_cond_sed, jpio, jpjo, /OVER) |
---|
330 | varin_br = TOTAL(weig*varin_br[addr], 1) |
---|
331 | varin_br = REFORM(varin_br, jpio, jpjo, /OVER) |
---|
332 | ; |
---|
333 | varout_cond_sed = TEMPORARY(varin_cond_sed) |
---|
334 | varout_br = TEMPORARY(varin_br) |
---|
335 | ; |
---|
336 | ; put back the masked value |
---|
337 | ;++ IF bad[0] NE -1 THEN varout_cond_sed[TEMPORARY(bad)] = 32767 |
---|
338 | ;++ IF bad[0] NE -1 THEN varout_br[TEMPORARY(bad)] = 32767 |
---|
339 | ; |
---|
340 | ; |
---|
341 | ; produce outputs |
---|
342 | condmag_output, orcares, $ |
---|
343 | varinq_cond_sed, 'Conductance', 'Conductance', 'siemens', $ |
---|
344 | jpio, jpjo, olon, olat, $ |
---|
345 | varout_cond_sed |
---|
346 | condmag_output, orcares, $ |
---|
347 | varinq_br, 'Magnetic field', 'magnetic field', 'tesla', $ |
---|
348 | jpio, jpjo, olon, olat, $ |
---|
349 | varout_br |
---|
350 | ; |
---|
351 | END |
---|