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 = ORCA025 |
---|
27 | ; must be G42 ++ G70 |
---|
28 | ; |
---|
29 | ; @restrictions |
---|
30 | ; - Requires SAXO tools |
---|
31 | ; |
---|
32 | ; @todo |
---|
33 | ; provide tools to plot output files |
---|
34 | ; produce a NetCDF GDT or CF compliant |
---|
35 | ; use <pro>fromreg</pro> |
---|
36 | ; |
---|
37 | ; @pre |
---|
38 | ; see geomag_profile.sh |
---|
39 | ; be sure to have condmag.nc in the directory defined in |
---|
40 | ; ${GEOMAG_ID}/ |
---|
41 | ; be sure to have meshmask of ORCA grid you choose in the directory defined in |
---|
42 | ; ${GEOMAG_ID}/ |
---|
43 | ; for ORCA2 filename is meshmask_bab.nc |
---|
44 | ; ++ au pif entre mesh_hgr, mesh_zgr et mask |
---|
45 | ; for ORCA025 filename is ORCA025-G42_mesh_hgr.nc |
---|
46 | ; |
---|
47 | ; @post |
---|
48 | ; see geomag_profile.sh |
---|
49 | ; cond_sed_<I>orcasres</I>.nc is now present in ${GEOMAG_OD}/ |
---|
50 | ; Br_<I>orcasres</I>.nc is now present in ${GEOMAG_OD}/ |
---|
51 | ; |
---|
52 | ; @examples |
---|
53 | ; IDL> .run condmag_on_orca |
---|
54 | ; IDL> condmag_on_orca, 'ORCA2', 'bilinear','T' |
---|
55 | ; |
---|
56 | ; @history |
---|
57 | ; reee522 2007-06-06T14:57:39Z rhodes (IRIX64) |
---|
58 | ; correction for DRAKKAR_EXP usage |
---|
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 | ras = report(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 | ras = report(msg) |
---|
111 | END |
---|
112 | END |
---|
113 | 'ORCA025': BEGIN |
---|
114 | msg = 'iii : valid orcares parameter = ' + orcares |
---|
115 | ras = report(msg) |
---|
116 | IF keyword_set(DRAKKAR_EXP) THEN BEGIN |
---|
117 | msg = 'iii : DRAKKAR_EXP keyword set' |
---|
118 | ras = report(msg) |
---|
119 | msg = 'iii : DRAKKAR_EXP = ' + drakkar_exp |
---|
120 | ras = report(msg) |
---|
121 | CASE drakkar_exp OF |
---|
122 | 'G42' : BEGIN |
---|
123 | msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp |
---|
124 | ras = report(msg) |
---|
125 | END |
---|
126 | 'G70' : BEGIN |
---|
127 | msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp |
---|
128 | ras = report(msg) |
---|
129 | END |
---|
130 | ELSE : BEGIN |
---|
131 | msg = 'eee : invalid DRAKKAR_EXP keyword = ' + drakkar_exp |
---|
132 | ras = report(msg) |
---|
133 | RETURN |
---|
134 | END |
---|
135 | ENDCASE |
---|
136 | filename_oce = orcares + '-' + drakkar_exp + '_mesh_hgr.nc' |
---|
137 | ENDIF ELSE BEGIN |
---|
138 | msg = 'eee : unset DRAKKAR_EXP keyword' |
---|
139 | ras = report(msg) |
---|
140 | msg = 'eee : orcares must be G42 or G70' |
---|
141 | ras = report(msg) |
---|
142 | RETURN |
---|
143 | ENDELSE |
---|
144 | END |
---|
145 | ELSE : BEGIN |
---|
146 | msg = 'eee : invalid orcares parameter = ' + orcares |
---|
147 | ras = report(msg) |
---|
148 | msg = 'eee : orcares must be ORCA2 or ORCA025' |
---|
149 | ras = report(msg) |
---|
150 | RETURN |
---|
151 | END |
---|
152 | ENDCASE |
---|
153 | ; |
---|
154 | ; check method definition |
---|
155 | CASE method OF |
---|
156 | 'bilinear': BEGIN |
---|
157 | msg = 'iii : valid method parameter = ' + method |
---|
158 | ras = report(msg) |
---|
159 | END |
---|
160 | 'imoms3' : BEGIN |
---|
161 | msg = 'iii : valid method parameter = ' + method |
---|
162 | ras = report(msg) |
---|
163 | END |
---|
164 | ELSE : BEGIN |
---|
165 | msg = 'eee : invalid method parameter = ' + method |
---|
166 | ras = report(msg) |
---|
167 | msg = 'eee : method must be bilinear or imoms3' |
---|
168 | ras = report(msg) |
---|
169 | RETURN |
---|
170 | END |
---|
171 | ENDCASE |
---|
172 | ; |
---|
173 | ; check gridtype definition |
---|
174 | gridtype = strupcase(gridtype) |
---|
175 | CASE gridtype OF |
---|
176 | 'T' : BEGIN |
---|
177 | msg = 'iii : valid gridtype parameter = ' + gridtype |
---|
178 | ras = report(msg) |
---|
179 | END |
---|
180 | 'U' : BEGIN |
---|
181 | msg = 'iii : valid gridtype parameter = ' + gridtype |
---|
182 | ras = report(msg) |
---|
183 | END |
---|
184 | 'V' : BEGIN |
---|
185 | msg = 'iii : valid gridtype parameter = ' + gridtype |
---|
186 | ras = report(msg) |
---|
187 | END |
---|
188 | ELSE: BEGIN |
---|
189 | msg = 'eee : invalid gridtype parameter = ' + gridtype |
---|
190 | ras = report(msg) |
---|
191 | msg = 'eee : gridtype must be T, U or V' |
---|
192 | ras = report(msg) |
---|
193 | RETURN |
---|
194 | END |
---|
195 | ENDCASE |
---|
196 | ; |
---|
197 | ; check for input files |
---|
198 | ; |
---|
199 | ; test if ${GEOMAG_ID} defined |
---|
200 | geomag_id_env=GETENV('GEOMAG_ID') |
---|
201 | CASE geomag_id_env OF |
---|
202 | '' : BEGIN |
---|
203 | msg = 'eee : ${GEOMAG_ID} is not defined' |
---|
204 | ras = report(msg) |
---|
205 | RETURN |
---|
206 | END |
---|
207 | ELSE: BEGIN |
---|
208 | msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env |
---|
209 | ras = report(msg) |
---|
210 | END |
---|
211 | ENDCASE |
---|
212 | ; |
---|
213 | iodirin = isadirectory(geomag_id_env) |
---|
214 | ; |
---|
215 | ; existence and protection of ${GEOMAG_ID} |
---|
216 | IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
217 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
218 | ras = report(msg) |
---|
219 | RETURN |
---|
220 | ENDIF |
---|
221 | ; |
---|
222 | ; conductivity and magnetic field |
---|
223 | filename_condmag = 'condmag.nc' |
---|
224 | ; |
---|
225 | ; check if this file exists |
---|
226 | fullfilename_condmag = isafile(iodirin + filename_condmag, NEW=0, /MUST_EXIST) |
---|
227 | IF fullfilename_condmag[0] EQ '' THEN BEGIN |
---|
228 | msg = 'eee : the file ' + fullfilename_condmag + ' was not found.' |
---|
229 | ras = report(msg) |
---|
230 | RETURN |
---|
231 | ENDIF |
---|
232 | ; |
---|
233 | ; protection |
---|
234 | IF (FILE_TEST(fullfilename_condmag[0], /READ) EQ 0) THEN BEGIN |
---|
235 | msg = 'eee : the file ' + fullfilename_condmag[0] + ' is not readable.' |
---|
236 | ras = report(msg) |
---|
237 | RETURN |
---|
238 | ENDIF |
---|
239 | ; |
---|
240 | ; mesh mask |
---|
241 | ; check if this file exists |
---|
242 | fullfilename_oce = isafile(iodirin + filename_oce, NEW=0, /MUST_EXIST, $ |
---|
243 | RECURSIVE=0) |
---|
244 | IF fullfilename_oce[0] EQ '' THEN BEGIN |
---|
245 | msg = 'eee : the file ' + fullfilename_oce + ' was not found.' |
---|
246 | ras = report(msg) |
---|
247 | RETURN |
---|
248 | ENDIF |
---|
249 | ; |
---|
250 | ; protection |
---|
251 | IF (FILE_TEST(fullfilename_oce[0], /READ) EQ 0) THEN BEGIN |
---|
252 | msg = 'eee : the file ' + fullfilename_oce[0] + ' is not readable.' |
---|
253 | ras = report(msg) |
---|
254 | RETURN |
---|
255 | ENDIF |
---|
256 | ; |
---|
257 | ; test if ${GEOMAG_OD} defined |
---|
258 | geomag_od_env=GETENV('GEOMAG_OD') |
---|
259 | CASE geomag_od_env OF |
---|
260 | '' : BEGIN |
---|
261 | msg = 'eee : ${GEOMAG_OD} is not defined' |
---|
262 | ras = report(msg) |
---|
263 | RETURN |
---|
264 | END |
---|
265 | ELSE: BEGIN |
---|
266 | msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env |
---|
267 | ras = report(msg) |
---|
268 | END |
---|
269 | ENDCASE |
---|
270 | ; |
---|
271 | ; check if output data will be possible |
---|
272 | iodirout = isadirectory(geomag_od_env) |
---|
273 | ; |
---|
274 | ; existence and protection |
---|
275 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
276 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
277 | ras = report(msg) |
---|
278 | RETURN |
---|
279 | ENDIF |
---|
280 | ; |
---|
281 | ; d'après ncdump -h /usr/work/sur/fvi/OPA/geomag/condmag.nc |
---|
282 | condmaglonname = 'lo' |
---|
283 | condmaglatname = 'la' |
---|
284 | ; |
---|
285 | ;---- |
---|
286 | ; conductivity and magnetic field grid parameters |
---|
287 | ;---- |
---|
288 | ; |
---|
289 | get_gridparams, fullfilename_condmag[0], $ |
---|
290 | condmaglonname, condmaglatname, $ |
---|
291 | condmaglon, condmaglat, jpia, jpja, 1, /DOUBLE |
---|
292 | ; |
---|
293 | ;---- |
---|
294 | ; Oceanic grid parameters |
---|
295 | ;---- |
---|
296 | ; |
---|
297 | olonname = 'glam' + STRLOWCASE(gridtype) |
---|
298 | olatname = 'gphi' + STRLOWCASE(gridtype) |
---|
299 | get_gridparams, fullfilename_oce[0], $ |
---|
300 | olonname, olatname, $ |
---|
301 | olon, olat, jpio, jpjo, 2, /DOUBLE |
---|
302 | msg = 'iii : ' + fullfilename_oce[0] + ' opened for read' |
---|
303 | ras = report(msg) |
---|
304 | ; |
---|
305 | ;--------------- |
---|
306 | ; Compute weight and address |
---|
307 | ;--------------- |
---|
308 | ; |
---|
309 | CASE method OF |
---|
310 | 'bilinear': compute_fromreg_bilinear_weigaddr, $ |
---|
311 | condmaglon, condmaglat, olon, olat, weig, addr |
---|
312 | 'imoms3' : compute_fromreg_imoms3_weigaddr, $ |
---|
313 | condmaglon, condmaglat, olon, olat, weig, addr |
---|
314 | ENDCASE |
---|
315 | ; |
---|
316 | ; reading condmag file |
---|
317 | netcdf_id_condmag = NCDF_OPEN(fullfilename_condmag[0], /NOWRITE) |
---|
318 | msg = 'iii : ' + fullfilename_condmag[0] + ' opened for read' |
---|
319 | ras = report(msg) |
---|
320 | ; |
---|
321 | varname_cond_sed = 'cond_sed' |
---|
322 | varname_br = 'Br' |
---|
323 | ; |
---|
324 | varinq_cond_sed = NCDF_VARINQ(netcdf_id_condmag, varname_cond_sed) |
---|
325 | NCDF_VARGET, netcdf_id_condmag, varname_cond_sed, varin_cond_sed |
---|
326 | ; |
---|
327 | varinq_br = NCDF_VARINQ(netcdf_id_condmag, varname_br) |
---|
328 | NCDF_VARGET, netcdf_id_condmag, varname_br, varin_br |
---|
329 | ; |
---|
330 | NCDF_CLOSE, netcdf_id_condmag |
---|
331 | ; |
---|
332 | ;--------------------------- |
---|
333 | ; do the interpolation |
---|
334 | varin_cond_sed = TOTAL(weig*varin_cond_sed[addr], 1) |
---|
335 | varin_cond_sed = REFORM(varin_cond_sed, jpio, jpjo, /OVER) |
---|
336 | varin_br = TOTAL(weig*varin_br[addr], 1) |
---|
337 | varin_br = REFORM(varin_br, jpio, jpjo, /OVER) |
---|
338 | ; |
---|
339 | varout_cond_sed = TEMPORARY(varin_cond_sed) |
---|
340 | varout_br = TEMPORARY(varin_br) |
---|
341 | ; |
---|
342 | ; put back the masked value |
---|
343 | ;++ IF bad[0] NE -1 THEN varout_cond_sed[TEMPORARY(bad)] = 32767 |
---|
344 | ;++ IF bad[0] NE -1 THEN varout_br[TEMPORARY(bad)] = 32767 |
---|
345 | ; |
---|
346 | ; |
---|
347 | ; produce outputs |
---|
348 | condmag_output, orcares, $ |
---|
349 | varinq_cond_sed, 'Conductance', 'Conductance', 'siemens', $ |
---|
350 | jpio, jpjo, olon, olat, $ |
---|
351 | varout_cond_sed |
---|
352 | condmag_output, orcares, $ |
---|
353 | varinq_br, 'Magnetic field', 'magnetic field', 'tesla', $ |
---|
354 | jpio, jpjo, olon, olat, $ |
---|
355 | varout_br |
---|
356 | ; |
---|
357 | END |
---|