Changeset 847 in lmdz_wrf
- Timestamp:
- Jun 16, 2016, 6:59:39 PM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var.py
r845 r847 13 13 ## e.g. # nc_var.py -o subbasin -f routing.nc -S Caceres,-57.75,-16.25,left 14 14 ## e.g. # nc_var.py -o computevar_model -f ~/PY/wrfout_d01_2001-11-11_00:00:00 -S hurs 15 ## e.g. # nc_var.py -o model_characteristics -f ~/PY/wrfout_d01_2001-11-11_00:00:00 -S WRF 15 16 16 17 from optparse import OptionParser … … 37 38 'getvalues_lonlat', 'grattr', \ 38 39 'grmattr', 'igattrs', 'increaseDimvar', 'isgattrs', 'isvattrs', 'ivars', 'ivattrs',\ 39 'maskvar', 40 'maskvar', 'model_characteristics', \ 40 41 'ncreplace', 'ncstepdiff', 'netcdf_concatenation', 'netcdf_fold_concatenation', \ 41 42 'Partialmap_Entiremap', 'Partialmap_EntiremapFor', 'Partialmap_EntiremapForExact', \ … … 203 204 elif oper == 'maskvar': 204 205 ncvar.maskvar(opts.values, opts.ncfile, opts.varname) 206 elif oper == 'model_characteristics': 207 ncvar.model_characteristics(opts.values, opts.ncfile) 205 208 elif oper == 'ncreplace': 206 209 ncvar.ncreplace(opts.values, opts.ncfile, opts.varname) -
trunk/tools/nc_var_tools.py
r845 r847 66 66 # lonlatProj: Function to compute longitudes and latitudes for a given projection following subroutine calc_resolution_in from ORCHIDEE/src_global/module_InterpWeight 67 67 # maskvar: Function to mask a variable using a mask. It is assumed that mask[...,dimM,dimJ,dimK] and var[...,dimM,dimJ,dimK] share the last dimensions 68 # ModelCharacteristics: Class object to determine major characterisitcs of a given model output 68 69 # ncreplace: Function to replace something from a netCDF file 69 70 # ncstepdiff: Function to compute differencies between time-steps (deacumulate) a netCDF file … … 12647 12648 12648 12649 if varn == 'global': 12649 if not searchInlist(onc.ncattrs(), attrn):12650 if not gen.searchInlist(onc.ncattrs(), attrn): 12650 12651 print errormsg 12651 12652 print ' ' + fname + ": file '" + filen + "' does not have atribute '" + \ … … 12655 12656 attrv = onc.getncattr(attrn) 12656 12657 else: 12657 if not searchInlist(onc.variables, varn):12658 if not gen.searchInlist(onc.variables, varn): 12658 12659 print errormsg 12659 12660 print ' ' + fname + ": file '" + filen + "' does not have variable '" + \ … … 12662 12663 else: 12663 12664 ovar = onc.variables[varn] 12664 if not searchInlist(ovar.ncattrs(), attrn):12665 if not gen.searchInlist(ovar.ncattrs(), attrn): 12665 12666 print errormsg 12666 12667 print ' ' + fname + ": variable '" + varn + "' does not have " + \ … … 12673 12674 onc.close() 12674 12675 12675 print attrv 12676 12677 return 12676 return attrv 12678 12677 12679 12678 def DimsLoop(ovar,seldims): … … 15188 15187 return 15189 15188 15189 class ModelChar(object): 15190 """ Class object to determine major characterisitcs of a given model output 15191 model= name of the model 15192 ncfile= name of the file to use to check 15193 """ 15194 def __init__(self,model,ncfile): 15195 fname = 'ModelChar' 15196 models = ['WRF', 'LMDZ', 'WRF_LMDZ'] 15197 15198 if model == 'WRF' or model == 'WRF_LMDZ': 15199 if model == 'WRF': 15200 self.model = 'Weather Research and Forecasting' 15201 else: 15202 self.model= 'LMDZ physics coupled to Weather Research and Forecasting' 15203 15204 self.dimxn = 'west_east' 15205 self.dimyn = 'south_north' 15206 self.dimzn = 'bottom_top' 15207 self.dimtn = 'Time' 15208 self.vardxn = 'XLONG' 15209 self.vardyn = 'XLAT' 15210 self.vardzn = 'DN' 15211 self.vardtn = 'Times' 15212 if ncfile is not None and ncfile[0:2] == 'geo': 15213 self.vardxn = 'XLONG_M' 15214 self.vardyn = 'XLAT_M' 15215 15216 if ncfile is not None: 15217 attrv = get_attribute('TITLE', ncfile, 'global') 15218 self.version = attrv.split(' ')[4] 15219 15220 elif model == 'LMD': 15221 self.model = 'LMDZ' 15222 self.dimxn = 'lon' 15223 self.dimyn = 'lat' 15224 self.dimzn = 'presnivs' 15225 self.dimtn = 'time_counter' 15226 self.vardxn = 'lon' 15227 self.vardyn = 'lat' 15228 self.vardzn = 'pres' 15229 self.vardtn = 'time_counter' 15230 15231 if ncfile is not None: 15232 self.version = None 15233 15234 def model_characteristics(values, ncfile): 15235 """ Class object to determine major characterisitcs of a given model output 15236 values= [model] 15237 model: name of the model 15238 ncfile= name of the file to use to check 15239 """ 15240 fname = 'model_characteristics' 15241 15242 if values == 'h': 15243 print fname + '_____________________________________________________________' 15244 print model_characteristics.__doc__ 15245 quit() 15246 15247 model = values 15248 15249 if ncfile == 'None': ncfile = None 15250 15251 modchar = ModelChar(model,ncfile) 15252 gen.printing_class(modchar) 15253 15254 return 15255 15190 15256 #quit() 15191 15257
Note: See TracChangeset
for help on using the changeset viewer.