[4] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; @file_comments |
---|
| 4 | ; interpolate condmag.nc file (sediment and magnetic fields) on ORCA grid |
---|
[6] | 5 | ; and produce cond_sed_<orcares>.nc and Br_<orcares>.nc |
---|
[4] | 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' |
---|
| 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,V |
---|
| 23 | ; |
---|
| 24 | ; @restrictions |
---|
| 25 | ; - Requires SAXO tools |
---|
| 26 | ; - must have condmag.nc in ${GEOMAG_ID}/ |
---|
| 27 | ; - must have meshmask in ${GEOMAG_ID}/ |
---|
| 28 | ; - must not have cond_sed_*.nc in ${GEOMAG_OD}/ |
---|
[6] | 29 | ; - must not have Br_*.nc in ${GEOMAG_OD}/ |
---|
[4] | 30 | ; |
---|
| 31 | ; @todo |
---|
| 32 | ; add ORCA025 |
---|
| 33 | ; provide tools to plot output file |
---|
| 34 | ; produce a NetCDF GDT or CF compliant |
---|
| 35 | ; |
---|
| 36 | ; @pre |
---|
| 37 | ; be sure to have datafile condmag.nc in the directory defined in |
---|
| 38 | ; ${GEOMAG_ID}/ see geomag_env.sh |
---|
| 39 | ; be sure to have meshmask of ORCA grid you choos in the directory defined in |
---|
| 40 | ; ${GEOMAG_ID}/ |
---|
| 41 | ; for ORCA2 filename is meshmask_bab.nc |
---|
| 42 | ; |
---|
| 43 | ; @post |
---|
| 44 | ; cond_sed_<I>orcasres</I>.nc is now present in ${GEOMAG_OD}/ |
---|
[6] | 45 | ; Br_<I>orcasres</I>.nc is now present in ${GEOMAG_OD}/ |
---|
[4] | 46 | ; see geomag_env.sh |
---|
| 47 | ; |
---|
| 48 | ; @examples |
---|
[6] | 49 | ; IDL> .run condmag_on_orca |
---|
| 50 | ; IDL> condmag_on_orca, 'ORCA2', 'bilinear','T' |
---|
[4] | 51 | ; |
---|
| 52 | ; @history |
---|
[6] | 53 | ; fplod 2006-11-23T08:57:10Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 54 | ; rename to condmag_on_orca.pro |
---|
| 55 | ; fplod 2006-11-22T15:10:31Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 56 | ; add creation of Br_<I>orcasres</I>.nc |
---|
| 57 | ; ++ not very beautifuly implemented |
---|
| 58 | ; fplod 2006-11-22T10:38:51Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 59 | ; always use msg = 'iii : ...' or msg = 'eee : ...' |
---|
| 60 | ; information on open io |
---|
[4] | 61 | ; fplod 2006-11-20T10:32:02Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 62 | ; cleaning before introduction into svn repository |
---|
| 63 | ; fplod 2006-03-23T13:05:39Z aedon.lodyc.jussieu.fr (Darwin) |
---|
| 64 | ; cond_sed_ORCA2 presque ok manque attributes min/max de cond_sed |
---|
| 65 | ; fplod 2006-03-22T09:35:42Z aedon.lodyc.jussieu.fr (Darwin) |
---|
| 66 | ; created from |
---|
| 67 | ; /Users/fplod/incas/seb/DORAEMON/wind/idl/quikscat_to_orca_scalar.pro written |
---|
| 68 | ; by Sebastien Masson |
---|
| 69 | ; to reproduce /usr/work/sur/fvi/OPA/geomag/cond_sed_ORCA2.nc |
---|
| 70 | ; main differences : no yyyy parameter, no time loop , no mask and no missing |
---|
| 71 | ; values (++ to be checked ) in data input (condmag.nc), no scale factor, |
---|
| 72 | ; no OFFSET, no save of weight and addresses |
---|
| 73 | ; |
---|
| 74 | ; @version |
---|
| 75 | ; $Id$ |
---|
| 76 | ; |
---|
| 77 | ;- |
---|
[6] | 78 | PRO condmag_on_orca, orcares, method, gridtype |
---|
[4] | 79 | ; |
---|
| 80 | compile_opt idl2, strictarrsubs |
---|
| 81 | ; |
---|
| 82 | ;---- |
---|
| 83 | ; check input parameters |
---|
| 84 | ;---- |
---|
| 85 | ; |
---|
| 86 | ; check orcares definition |
---|
| 87 | ; |
---|
| 88 | CASE orcares OF |
---|
| 89 | 'ORCA2': BEGIN |
---|
[6] | 90 | msg = 'iii : valid orcares parameter = ' + orcares |
---|
| 91 | PRINT, msg |
---|
[4] | 92 | filename_oce = 'meshmask_bab.nc' |
---|
| 93 | END |
---|
| 94 | ELSE : BEGIN |
---|
[6] | 95 | msg = 'eee : invalid orcares parameter = ' + orcares |
---|
[4] | 96 | PRINT, msg |
---|
[6] | 97 | msg = 'eee : orcares must be ORCA2' |
---|
| 98 | PRINT, msg |
---|
[4] | 99 | RETURN |
---|
| 100 | END |
---|
| 101 | ENDCASE |
---|
| 102 | ; |
---|
| 103 | ; check method definition |
---|
| 104 | CASE method OF |
---|
| 105 | 'bilinear': BEGIN |
---|
[6] | 106 | msg = 'iii : valid method parameter = ' + method |
---|
| 107 | PRINT, msg |
---|
[4] | 108 | END |
---|
| 109 | 'imoms3' : BEGIN |
---|
[6] | 110 | msg = 'iii : valid method parameter = ' + method |
---|
| 111 | PRINT, msg |
---|
[4] | 112 | END |
---|
| 113 | ELSE : BEGIN |
---|
[6] | 114 | msg = 'eee : invalid method parameter = ' + method |
---|
[4] | 115 | PRINT, msg |
---|
[6] | 116 | msg = 'eee : method must be bilinear or imoms3' |
---|
| 117 | PRINT, msg |
---|
[4] | 118 | RETURN |
---|
| 119 | END |
---|
| 120 | ENDCASE |
---|
| 121 | ; |
---|
| 122 | ; check gridtype definition |
---|
| 123 | gridtype = strupcase(gridtype) |
---|
| 124 | CASE gridtype OF |
---|
| 125 | 'T' : BEGIN |
---|
[6] | 126 | msg = 'iii : valid gridtype parameter = ' + gridtype |
---|
| 127 | PRINT, msg |
---|
[4] | 128 | END |
---|
| 129 | 'U' : BEGIN |
---|
[6] | 130 | msg = 'iii : valid gridtype parameter = ' + gridtype |
---|
| 131 | PRINT, msg |
---|
[4] | 132 | END |
---|
| 133 | 'V' : BEGIN |
---|
[6] | 134 | msg = 'iii : valid gridtype parameter = ' + gridtype |
---|
| 135 | PRINT, msg |
---|
[4] | 136 | END |
---|
| 137 | ELSE: BEGIN |
---|
[6] | 138 | msg = 'eee : invalid gridtype parameter = ' + gridtype |
---|
[4] | 139 | PRINT, msg |
---|
[6] | 140 | msg = 'eee : gridtype must be T, U or V' |
---|
| 141 | PRINT, msg |
---|
[4] | 142 | RETURN |
---|
| 143 | END |
---|
| 144 | ENDCASE |
---|
| 145 | ; |
---|
| 146 | ; check for input files |
---|
| 147 | ; |
---|
| 148 | ; test if ${GEOMAG_ID} defined |
---|
| 149 | geomag_id_env=GETENV('GEOMAG_ID') |
---|
| 150 | CASE geomag_id_env OF |
---|
| 151 | '' : BEGIN |
---|
[6] | 152 | msg = 'eee : ${GEOMAG_ID} is not defined' |
---|
[4] | 153 | PRINT, msg |
---|
| 154 | RETURN |
---|
| 155 | END |
---|
| 156 | ELSE: BEGIN |
---|
[6] | 157 | msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env |
---|
[4] | 158 | PRINT, msg |
---|
| 159 | END |
---|
| 160 | ENDCASE |
---|
| 161 | ; |
---|
| 162 | iodirin = isadirectory(geomag_id_env) |
---|
| 163 | ; |
---|
| 164 | ; existence and protection of ${GEOMAG_ID} |
---|
| 165 | IF (FILE_TEST(iodirin, /DIRECTORY,/EXECUTABLE , /READ) EQ 0) THEN BEGIN |
---|
[6] | 166 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
[4] | 167 | PRINT, msg |
---|
| 168 | RETURN |
---|
| 169 | ENDIF |
---|
| 170 | ; |
---|
| 171 | ; conductivity and magnetic field |
---|
| 172 | filename_condmag = 'condmag.nc' |
---|
| 173 | ; |
---|
| 174 | ; check if this file exists |
---|
[6] | 175 | fullfilename_condmag = isafile(iodirin + filename_condmag, NEW=0,/MUST_EXIST) |
---|
[4] | 176 | IF fullfilename_condmag[0] EQ '' THEN BEGIN |
---|
[6] | 177 | msg = 'eee : the file ' + fullfilename_condmag + ' was not found.' |
---|
[4] | 178 | PRINT, msg |
---|
| 179 | RETURN |
---|
| 180 | ENDIF |
---|
| 181 | ; |
---|
| 182 | ; protection |
---|
| 183 | IF (FILE_TEST(fullfilename_condmag[0], /READ) EQ 0) THEN BEGIN |
---|
[6] | 184 | msg = 'eee : the file ' + fullfilename_condmag[0] + ' is not readable.' |
---|
[4] | 185 | PRINT, msg |
---|
| 186 | RETURN |
---|
| 187 | ENDIF |
---|
| 188 | ; |
---|
| 189 | ; mesh mask |
---|
| 190 | ; check if this file exists |
---|
[6] | 191 | fullfilename_oce = isafile(iodirin + filename_oce, NEW=0,/MUST_EXIST, RECURSIVE=0) |
---|
[4] | 192 | IF fullfilename_oce[0] EQ '' THEN BEGIN |
---|
[6] | 193 | msg = 'eee : the file ' + fullfilename_oce + ' was not found.' |
---|
[4] | 194 | PRINT, msg |
---|
| 195 | RETURN |
---|
| 196 | ENDIF |
---|
| 197 | ; |
---|
| 198 | ; protection |
---|
| 199 | IF (FILE_TEST(fullfilename_oce[0], /READ) EQ 0) THEN BEGIN |
---|
[6] | 200 | msg = 'eee : the file ' + fullfileoce_condmag[0] + ' is not readable.' |
---|
[4] | 201 | PRINT, msg |
---|
| 202 | RETURN |
---|
| 203 | ENDIF |
---|
| 204 | ; |
---|
| 205 | ; test if ${GEOMAG_OD} defined |
---|
| 206 | geomag_od_env=GETENV('GEOMAG_OD') |
---|
| 207 | CASE geomag_od_env OF |
---|
| 208 | '' : BEGIN |
---|
[6] | 209 | msg = 'eee : ${GEOMAG_OD} is not defined' |
---|
[4] | 210 | PRINT, msg |
---|
| 211 | RETURN |
---|
| 212 | END |
---|
| 213 | ELSE: BEGIN |
---|
[6] | 214 | msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env |
---|
[4] | 215 | PRINT, msg |
---|
| 216 | END |
---|
| 217 | ENDCASE |
---|
| 218 | ; |
---|
| 219 | ; check if output data will be possible |
---|
| 220 | iodirout = isadirectory(geomag_od_env) |
---|
| 221 | ; |
---|
| 222 | ; existence and protection |
---|
| 223 | IF (FILE_TEST(iodirout, /DIRECTORY,/WRITE) EQ 0) THEN BEGIN |
---|
[6] | 224 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
[4] | 225 | PRINT, msg |
---|
| 226 | RETURN |
---|
| 227 | ENDIF |
---|
| 228 | ; |
---|
[6] | 229 | ; build output filenames |
---|
[4] | 230 | filename_cond_sed = 'cond_sed' + '_' + orcares +'.nc' |
---|
| 231 | fullfilename_cond_sed = iodirout + filename_cond_sed |
---|
| 232 | ; |
---|
| 233 | ; in order to avoid unexpected overwritten |
---|
| 234 | IF (FILE_TEST(fullfilename_cond_sed) EQ 1) THEN BEGIN |
---|
[6] | 235 | msg = 'eee : the file ' + fullfilename_cond_sed + ' already exists.' |
---|
[4] | 236 | PRINT, msg |
---|
| 237 | RETURN |
---|
| 238 | ENDIF |
---|
| 239 | ; |
---|
[6] | 240 | filename_br = 'Br' + '_' + orcares +'.nc' |
---|
| 241 | fullfilename_br = iodirout + filename_br |
---|
| 242 | ; |
---|
| 243 | ; in order to avoid unexpected overwritten |
---|
| 244 | IF (FILE_TEST(fullfilename_br) EQ 1) THEN BEGIN |
---|
| 245 | msg = 'eee : the file ' + fullfilename_br + ' already exists.' |
---|
| 246 | PRINT, msg |
---|
| 247 | RETURN |
---|
| 248 | ENDIF |
---|
| 249 | ; |
---|
[4] | 250 | ; d'après ncdump -h /usr/work/sur/fvi/OPA/geomag/condmag.nc |
---|
| 251 | condmaglonname = 'lo' |
---|
| 252 | condmaglatname = 'la' |
---|
| 253 | varname_cond_sed = 'cond_sed' |
---|
[6] | 254 | varname_br = 'Br' |
---|
[4] | 255 | ; |
---|
| 256 | ;---- |
---|
| 257 | ; conductivity and magnetic field grid parameters |
---|
| 258 | ;---- |
---|
| 259 | ; |
---|
| 260 | get_gridparams, fullfilename_condmag[0], $ |
---|
| 261 | condmaglonname, condmaglatname, $ |
---|
| 262 | condmaglon, condmaglat, jpia, jpja, 1,/DOUBLE |
---|
| 263 | ; |
---|
| 264 | ;---- |
---|
| 265 | ; Oceanic grid parameters |
---|
| 266 | ;---- |
---|
| 267 | ; |
---|
| 268 | olonname = 'glam' + STRLOWCASE(gridtype) |
---|
| 269 | olatname = 'gphi' + STRLOWCASE(gridtype) |
---|
| 270 | get_gridparams, fullfilename_oce[0], $ |
---|
| 271 | olonname, olatname, $ |
---|
| 272 | olon, olat, jpio, jpjo, 2,/DOUBLE |
---|
| 273 | ; |
---|
| 274 | ;--------------- |
---|
| 275 | ; Compute weight and address |
---|
| 276 | ;--------------- |
---|
| 277 | ; |
---|
| 278 | CASE method OF |
---|
| 279 | 'bilinear': compute_fromreg_bilinear_weigaddr, $ |
---|
| 280 | condmaglon, condmaglat, olon, olat, weig, addr |
---|
| 281 | 'imoms3' : compute_fromreg_imoms3_weigaddr, $ |
---|
| 282 | condmaglon, condmaglat, olon, olat, weig, addr |
---|
| 283 | ENDCASE |
---|
| 284 | ; |
---|
| 285 | ; reading condmag file |
---|
[6] | 286 | netcdf_id_condmag = NCDF_OPEN(fullfilename_condmag[0], /NOWRITE) |
---|
| 287 | msg = 'iii : ' + fullfilename_condmag[0] + ' opened for read' |
---|
| 288 | PRINT, msg |
---|
| 289 | |
---|
[4] | 290 | varinq_cond_sed = NCDF_VARINQ(netcdf_id_condmag, varname_cond_sed) |
---|
[6] | 291 | varinq_br = NCDF_VARINQ(netcdf_id_condmag, varname_br) |
---|
[4] | 292 | ; |
---|
| 293 | ;--------------------------- |
---|
[6] | 294 | ; Creation of the NetCdf file for cond_sed and Br |
---|
[4] | 295 | ;--------------------------- |
---|
| 296 | ; |
---|
| 297 | netcdf_id_cond_sed = NCDF_CREATE(fullfilename_cond_sed, /clobber) |
---|
| 298 | NCDF_CONTROL, netcdf_id_cond_sed, /NOFILL |
---|
[6] | 299 | netcdf_id_br = NCDF_CREATE(fullfilename_br, /clobber) |
---|
| 300 | NCDF_CONTROL, netcdf_id_br, /NOFILL |
---|
| 301 | ; |
---|
[4] | 302 | ; dimension |
---|
| 303 | dimidx = NCDF_DIMDEF(netcdf_id_cond_sed, 'x' , jpio) |
---|
| 304 | dimidy = NCDF_DIMDEF(netcdf_id_cond_sed, 'y' , jpjo) |
---|
| 305 | dimidt = NCDF_DIMDEF(netcdf_id_cond_sed, 'lo', /UNLIMITED) |
---|
[6] | 306 | dimidx = NCDF_DIMDEF(netcdf_id_br, 'x' , jpio) |
---|
| 307 | dimidy = NCDF_DIMDEF(netcdf_id_br, 'y' , jpjo) |
---|
| 308 | dimidt = NCDF_DIMDEF(netcdf_id_br, 'lo', /UNLIMITED) |
---|
[4] | 309 | ; |
---|
| 310 | ; global attributes |
---|
[6] | 311 | NCDF_ATTPUT, netcdf_id_cond_sed, 'Conventions', 'GDT 1.2', /GLOBAL ; ++ conformité |
---|
[4] | 312 | NCDF_ATTPUT, netcdf_id_cond_sed, 'file_name' , filename_cond_sed, /GLOBAL |
---|
[6] | 313 | NCDF_ATTPUT, netcdf_id_cond_sed, 'Title' , 'Conductance', /GLOBAL |
---|
| 314 | NCDF_ATTPUT, netcdf_id_br, 'Conventions', 'GDT 1.2', /GLOBAL ; ++ conformité |
---|
| 315 | NCDF_ATTPUT, netcdf_id_br, 'file_name' , filename_Br, /GLOBAL |
---|
| 316 | NCDF_ATTPUT, netcdf_id_br, 'Title' , 'Magnetic field', /GLOBAL |
---|
[4] | 317 | ; |
---|
| 318 | ; declaration of variables |
---|
| 319 | ; 4 common variables for the two files to produce |
---|
| 320 | varid = lonarr(3) |
---|
| 321 | ; |
---|
| 322 | varid[0] = NCDF_VARDEF(netcdf_id_cond_sed, 'nav_lon' , [dimidx, dimidy], /FLOAT) |
---|
| 323 | NCDF_ATTPUT, netcdf_id_cond_sed, varid[0], 'units' , 'degrees_east' |
---|
| 324 | NCDF_ATTPUT, netcdf_id_cond_sed, varid[0], 'valid_min', min(olon, max = omax),/FLOAT |
---|
| 325 | NCDF_ATTPUT, netcdf_id_cond_sed, varid[0], 'valid_max', omax,/FLOAT |
---|
| 326 | NCDF_ATTPUT, netcdf_id_cond_sed, varid[0], 'long_name', 'Longitude at t-point' |
---|
[6] | 327 | varid[0] = NCDF_VARDEF(netcdf_id_br, 'nav_lon' , [dimidx, dimidy], /FLOAT) |
---|
| 328 | NCDF_ATTPUT, netcdf_id_br, varid[0], 'units' , 'degrees_east' |
---|
| 329 | NCDF_ATTPUT, netcdf_id_br, varid[0], 'valid_min', min(olon, max = omax),/FLOAT |
---|
| 330 | NCDF_ATTPUT, netcdf_id_br, varid[0], 'valid_max', omax,/FLOAT |
---|
| 331 | NCDF_ATTPUT, netcdf_id_br, varid[0], 'long_name', 'Longitude at t-point' |
---|
[4] | 332 | ; |
---|
| 333 | varid[1] = NCDF_VARDEF(netcdf_id_cond_sed, 'nav_lat' , [dimidx, dimidy], /FLOAT) |
---|
| 334 | NCDF_ATTPUT, netcdf_id_cond_sed, varid[1], 'units' , 'degrees_north' |
---|
| 335 | NCDF_ATTPUT, netcdf_id_cond_sed, varid[1], 'valid_min', min(olat, max = omax),/FLOAT |
---|
| 336 | NCDF_ATTPUT, netcdf_id_cond_sed, varid[1], 'valid_max', omax,/FLOAT |
---|
| 337 | NCDF_ATTPUT, netcdf_id_cond_sed, varid[1], 'long_name', 'Latitude at t-point' |
---|
[6] | 338 | varid[1] = NCDF_VARDEF(netcdf_id_br, 'nav_lat' , [dimidx, dimidy], /FLOAT) |
---|
| 339 | NCDF_ATTPUT, netcdf_id_br, varid[1], 'units' , 'degrees_north' |
---|
| 340 | NCDF_ATTPUT, netcdf_id_br, varid[1], 'valid_min', min(olat, max = omax),/FLOAT |
---|
| 341 | NCDF_ATTPUT, netcdf_id_br, varid[1], 'valid_max', omax,/FLOAT |
---|
| 342 | NCDF_ATTPUT, netcdf_id_br, varid[1], 'long_name', 'Latitude at t-point' |
---|
[4] | 343 | ; |
---|
| 344 | varid[2] = NCDF_VARDEF(netcdf_id_cond_sed, 'time' , [dimidt], /FLOAT) |
---|
[6] | 345 | varid[2] = NCDF_VARDEF(netcdf_id_br, 'time' , [dimidt], /FLOAT) |
---|
[4] | 346 | ; |
---|
[6] | 347 | ; each of the two files to produce contains a specific variable |
---|
| 348 | ; |
---|
[4] | 349 | varid_cond_sed = lonarr(1) |
---|
| 350 | varid_cond_sed[0] = NCDF_VARDEF(netcdf_id_cond_sed, varname_cond_sed, [dimidx, dimidy, dimidt], /FLOAT) |
---|
| 351 | ; |
---|
| 352 | ; variable 3 |
---|
[6] | 353 | NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'long_name', 'Conductance' ; ++ non cf |
---|
| 354 | NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'units', 'siemens' ; ++ récupérer l'unite de cond_sed dans condmag.nc |
---|
[4] | 355 | ; pour min et max, il faut avoir lu la variable ... cf. plus bas ++ |
---|
| 356 | ; donc pour l'instant on les met à valeur manquante |
---|
| 357 | NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_min', !VALUES.F_NAN ,/FLOAT |
---|
| 358 | NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_max', !VALUES.F_NAN ,/FLOAT |
---|
[6] | 359 | ; |
---|
| 360 | varid_br = lonarr(1) |
---|
| 361 | varid_br[0] = NCDF_VARDEF(netcdf_id_br, varname_br, [dimidx, dimidy, dimidt], /FLOAT) |
---|
| 362 | ; |
---|
| 363 | ; variable 3 |
---|
| 364 | NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'long_name', 'magnetic field' ; ++ non cf |
---|
| 365 | NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'units', 'tesla' ; ++ récupérer l'unité de Br dans condmag.nc |
---|
| 366 | ; pour min et max, il faut avoir lu la variable ... cf. plus bas ++ |
---|
| 367 | ; donc pour l'instant on les met à valeur manquante |
---|
| 368 | NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'valid_min', !VALUES.F_NAN ,/FLOAT |
---|
| 369 | NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_max', !VALUES.F_NAN ,/FLOAT |
---|
| 370 | ; |
---|
[4] | 371 | ;--------------------------- |
---|
[6] | 372 | ; end of header definition, writing of the NetCdf files |
---|
[4] | 373 | ;--------------------------- |
---|
| 374 | NCDF_CONTROL, netcdf_id_cond_sed, /ENDEF |
---|
[6] | 375 | NCDF_CONTROL, netcdf_id_br, /ENDEF |
---|
| 376 | NCDF_CLOSE, netcdf_id_condmag ; ++ si le close n'est pas ici ça merde mais je ne sais pas pourquoi |
---|
| 377 | ; |
---|
[4] | 378 | ; grid |
---|
[6] | 379 | NCDF_VARPUT, netcdf_id_cond_sed, 'nav_lon', olon |
---|
| 380 | NCDF_VARPUT, netcdf_id_cond_sed, 'nav_lat', olat |
---|
[4] | 381 | NCDF_VARPUT, netcdf_id_cond_sed, varid[2], FLOAT(0.5) ; ++ c'est quoi cette valeur |
---|
[6] | 382 | NCDF_VARPUT, netcdf_id_br, 'nav_lon', olon |
---|
| 383 | NCDF_VARPUT, netcdf_id_br, 'nav_lat', olat |
---|
| 384 | NCDF_VARPUT, netcdf_id_br, varid[2], FLOAT(0.5) ; ++ c'est quoi cette valeur |
---|
| 385 | |
---|
[4] | 386 | ;--------------------------- |
---|
| 387 | ; réouverture du fichier ... mais pourquoi on le relit !!++ |
---|
[6] | 388 | netcdf_id_condmag = NCDF_OPEN(fullfilename_condmag[0],/NOWRITE) |
---|
| 389 | msg = 'iii : ' + fullfilename_condmag[0] + ' reopened for read' |
---|
| 390 | PRINT, msg |
---|
[4] | 391 | ; |
---|
[6] | 392 | NCDF_VARGET, netcdf_id_condmag, varname_cond_sed, varin_cond_sed ; , COUNT = [jpia, jpja, 1], OFFSET = [0, 0, 0] |
---|
| 393 | NCDF_VARGET, netcdf_id_condmag, varname_br, varin_br ; , COUNT = [jpia, jpja, 1], OFFSET = [0, 0, 0] |
---|
[4] | 394 | ; |
---|
| 395 | ; do the interpolation |
---|
| 396 | varin_cond_sed = TOTAL(weig*varin_cond_sed[addr], 1) |
---|
| 397 | varin_cond_sed = REFORM(varin_cond_sed, jpio, jpjo, /OVER) |
---|
[6] | 398 | varin_br = TOTAL(weig*varin_br[addr], 1) |
---|
| 399 | varin_br = REFORM(varin_br, jpio, jpjo, /OVER) |
---|
[4] | 400 | ; |
---|
| 401 | NCDF_CLOSE, netcdf_id_condmag |
---|
| 402 | varout_cond_sed = TEMPORARY(varin_cond_sed) |
---|
[6] | 403 | varout_br = TEMPORARY(varin_br) |
---|
[4] | 404 | ; compute min max |
---|
[6] | 405 | minarr_cond_sed = min(varout_cond_sed, max = maxarr_cond_sed) |
---|
| 406 | minarr_br = min(varout_br, max = maxarr_br) |
---|
[4] | 407 | ; |
---|
| 408 | ; put back the masked value |
---|
| 409 | ;++ IF bad[0] NE -1 THEN varout_cond_sed[TEMPORARY(bad)] = 32767 |
---|
[6] | 410 | ;++ IF bad[0] NE -1 THEN varout_br[TEMPORARY(bad)] = 32767 |
---|
[4] | 411 | ; |
---|
| 412 | ; write the data |
---|
| 413 | NCDF_VARPUT, netcdf_id_cond_sed, varname_cond_sed, varout_cond_sed, COUNT = [jpio, jpjo, 1], OFFSET = [0, 0, 0] |
---|
[6] | 414 | NCDF_VARPUT, netcdf_id_br, varname_br, varout_br, COUNT = [jpio, jpjo, 1], OFFSET = [0, 0, 0] |
---|
[4] | 415 | ; |
---|
| 416 | ; update min max attributes |
---|
| 417 | NCDF_CONTROL, netcdf_id_cond_sed, /REDEF |
---|
[6] | 418 | NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_min', minarr_cond_sed,/FLOAT |
---|
| 419 | NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_max', maxarr_cond_sed,/FLOAT |
---|
[4] | 420 | NCDF_CONTROL, netcdf_id_cond_sed, /ENDEF |
---|
[6] | 421 | NCDF_CONTROL, netcdf_id_br, /REDEF |
---|
| 422 | NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'valid_min', minarr_br,/FLOAT |
---|
| 423 | NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'valid_max', maxarr_br,/FLOAT |
---|
| 424 | NCDF_CONTROL, netcdf_id_br, /ENDEF |
---|
[4] | 425 | ; |
---|
| 426 | ;--------------------------- |
---|
[6] | 427 | ; close the netcdf files |
---|
[4] | 428 | NCDF_CLOSE, netcdf_id_cond_sed |
---|
[6] | 429 | NCDF_CLOSE, netcdf_id_br |
---|
| 430 | ; |
---|
| 431 | msg = 'iii : ' + fullfilename_cond_sed + ' created' |
---|
[4] | 432 | PRINT, msg |
---|
[6] | 433 | msg = 'iii : ' + fullfilename_br + ' created' |
---|
| 434 | PRINT, msg |
---|
[4] | 435 | ; |
---|
| 436 | END |
---|