- Timestamp:
- Sep 20, 2018, 2:19:27 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r2139 r2143 13293 13293 [vardimname]: name of the variable with values for the dimension ('int', for 13294 13294 counter of integers with the dimension length) 13295 'WRFtime' for CFtime from WRF Times variable 13295 13296 ncfile= netCDF file to use 13296 13297 varnames= ',' list of variables to retrieve … … 13319 13320 dimsv = {} 13320 13321 vardims = [] 13322 WRFtime = False 13321 13323 for dimv in dimvals: 13322 13324 dimn = dimv.split('@')[0] … … 13327 13329 quit(-1) 13328 13330 varn = dimv.split('@')[1] 13329 if not varn == 'int' and not gen.searchInlist(onc.variables, varn): 13331 if not varn == 'int' and varn != 'WRFtime' and \ 13332 not gen.searchInlist(onc.variables, varn): 13330 13333 print errormsg 13331 13334 print ' ' + fname + ": file '" + ncfile + "' has not variable '" + \ … … 13333 13336 quit(-1) 13334 13337 dimsv[dimn] = varn 13335 if varn != 'int': vardims.append(varn) 13338 if varn != 'int' and varn != 'WRFtime': 13339 vardims.append(varn) 13340 else: 13341 WRFtime = True 13336 13342 13337 13343 newnc = NetCDFFile(ofile, 'w') … … 13342 13348 # Getting variables from dimensions 13343 13349 add_vars(onc,newnc,vardims) 13350 if WRFtime: 13351 otwrf = onc.variables['Times'] 13352 twrfv = otwrf[:] 13353 timev, timeu = compute_WRFtime(twrfv) 13354 newdim = onewnc.createDimension('time', None) 13355 newvar = onewnc.createVariable('time', 'f8', ('time')) 13356 newvar[:] = timev[:] 13357 basicvardef(newvar, 'time', 'Time', timeu) 13358 onewnc.sync() 13344 13359 13345 13360 # Getting variables
Note: See TracChangeset
for help on using the changeset viewer.