Changeset 967 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 28, 2016, 7:47:51 PM (8 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var.py
r965 r967 180 180 ncvar.get_namelist_vars(opts.values, opts.ncfile) 181 181 elif oper == 'get_Variables': 182 ncvar.get_Variables(opts.values, opts.ncfile )182 ncvar.get_Variables(opts.values, opts.ncfile, opts.varname) 183 183 elif oper == 'getvalues_lonlat': 184 184 ncvar.getvalues_lonlat(opts.values, opts.ncfile) -
trunk/tools/nc_var_tools.py
r966 r967 16342 16342 return 16343 16343 16344 def get_Variables(values, ncfile ):16344 def get_Variables(values, ncfile, variables): 16345 16345 """ Function to get a list of variables from an existing file 16346 values = ',' separated list of names of variables to get 16346 novar= behaviour when no variable is found 16347 'error': an error messages arise and program stops 16348 'warn': a warning messages arise and program continues 16347 16349 ncfile= WRF file to use 16350 variables = ',' separated list of names of variables to get 16348 16351 """ 16349 16352 fname = 'get_Variables' … … 16354 16357 quit() 16355 16358 16356 variables = values.split(',') 16359 novar = values 16360 variables = variables.split(',') 16357 16361 16358 16362 ofile = 'get_Variables.nc' … … 16365 16369 for var in variables: 16366 16370 if not gen.searchInlist(filevars, var): 16367 print errormsg 16368 print ' ' + fname + ": file '" + ncfile + "' does not have variable '" +\ 16369 var + "' !!" 16370 print ' variables in file:', filevars 16371 quit(-1) 16371 if novar == 'error': 16372 print errormsg 16373 print ' ' + fname + ": file '" + ncfile + "' does not have " + \ 16374 "variable '" + var + "' !!" 16375 print ' variables in file:', filevars 16376 quit(-1) 16377 elif novar == 'warn': 16378 print warnmsg 16379 print ' ' + fname + ": file '" + ncfile + "' does not have " + \ 16380 "variable '" + var + "' !!" 16381 print ' variables in file:', filevars 16382 continue 16383 else: 16384 print errormsg 16385 print ' ' + fname + ": novar '" + novar + "' not ready !!" 16386 quit(-1) 16372 16387 16373 16388 print ' ' + fname + ": getting variable '" + var + "'..." … … 16391 16406 else: 16392 16407 newvar = onewnc.createVariable(var, nctype(varinf.dtype), tuple(vardims)) 16393 16408 newvar[:] = ovar[:] 16394 16409 for attrn in varinf.attributes: 16395 16410 attrv = ovar.getncattr(attrn)
Note: See TracChangeset
for help on using the changeset viewer.