source: trunk/condmag_on_orca.pro @ 39

Last change on this file since 39 was 23, checked in by pinsard, 17 years ago

replace call of initorca2_bab by call of initocemesh

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