Changeset 552 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jul 1, 2015, 1:33:21 PM (9 years ago)
Author:
lfita
Message:

Fixing non 'time' variables on `TimeSplitmat?'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r551 r552  
    1618816188    newdim = onewfile.createDimension('time', None)
    1618916189
     16190# Variable time
     16191    newvar = onewfile.createVariable('time', 'f8', tuple(newdimns))
     16192    newvar[:] = newtime
     16193    basicvardef(newvar, 'time', 'time', tunits)
     16194
    1619016195    splitS = seltimes.replace(',','')
    1619116196
     
    1624916254            newvar[:] = newvarv
    1625016255            onewfile.sync()
    16251     else:
    16252         newvar = oVn
     16256        elif Vn != tvdim:
     16257            for dvn in Vndims:
     16258                if not searchInlist(onewfile.dimensions,dvn):
     16259                    dsize = len(of.dimensions[dvn])
     16260                    newdim = onewfile.createDimension(dvn, dsize)
     16261# From http://guziy.blogspot.fr/2014/01/netcdf4-python-copying-variables-from.html
     16262            vartype = oVn.dtype
     16263            newvar = onewfile.createVariable(Vn, vartype, Vndims)
     16264            for attrn in oVn.ncattrs():
     16265                attrv = oVn.getncattr(attrn)
     16266                newattr = set_attribute(newvar, attrn, attrv)
     16267
     16268            newvar[:] = oVn[:]
    1625316269
    1625416270# Variable time
    16255     newvar = onewfile.createVariable('time', 'f8', tuple(newdimns))
     16271    newvar = onewfile.variables['time']
    1625616272    newvar[:] = newtime
    16257     basicvardef(newvar, 'time', 'time', tunits)
    1625816273
    1625916274# Variables selection
Note: See TracChangeset for help on using the changeset viewer.