Changeset 1779 in lmdz_wrf for trunk/tools/nc_var_tools.py


Ignore:
Timestamp:
Feb 21, 2018, 4:28:22 PM (7 years ago)
Author:
lfita
Message:

Adding `WRFtime' on 'netcdf_fold_concatenation_HMT'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1744 r1779  
    1121011210      giving Header, Middle, Tail for the name files
    1121111211    netcdf_fold_concateation(values, ncfile, varn)
    11212       [values]= [fold],[dimname]
     11212      [values]= [fold],[dimname],[vardimname]
    1121311213        [fold]: folder with the location of the netCDF files
    1121411214        [dimname]: dimension along which files should be concatenated
    11215         [vardimname]: name of the dimension variable with the values
     11215        [vardimname]: name of the dimension variable with the values ('WRFtime' for
     11216          CF time conversion from WRF 'Times')
    1121611217      [ncfile]= [header],[middle],[tail]
    1121711218        [header] = header of the name of the files to concatenate [ncfile]*[middle]*[tail]
     
    1130611307# Dimension variable for the concatenation
    1130711308   
    11308     odimvar = ncobjs[0].variables[vardimname]
    11309     odimvardims = odimvar.dimensions
    11310     odimattrs = odimvar.ncattrs()
    11311     for dimn in odimvardims:
    11312         if not gen.searchInlist(newnc.dimensions,dimn):
    11313             Ldim = len(odimvar.dimensions[dimn])
    11314     newvar = newnc.createVariable(vardimname, odimvar.dtype, odimvardims)
    11315     for attrn in odimattrs:
    11316         attrv = odimvar.getncattr(attrn)
    11317         newattr = set_attribute(newvar, attrn, attrv)
    11318         if attrn == 'units': urefvals = attrv
     11309    if vardimname != 'WRFtime':
     11310        odimvar = ncobjs[0].variables[vardimname]
     11311        odimvardims = odimvar.dimensions
     11312        odimattrs = odimvar.ncattrs()
     11313        for dimn in odimvardims:
     11314            if not gen.searchInlist(newnc.dimensions,dimn):
     11315                Ldim = len(odimvar.dimensions[dimn])
     11316        newvar = newnc.createVariable(vardimname, odimvar.dtype, odimvardims)
     11317        for attrn in odimattrs:
     11318            attrv = odimvar.getncattr(attrn)
     11319            newattr = set_attribute(newvar, attrn, attrv)
     11320            if attrn == 'units': urefvals = attrv
     11321    else:
     11322        print infmsg
     11323        print '    ' + fname + ": creation of variable 'time' from WRF 'Times' !!"
     11324        odimvar = ncobjs[0].variables[vardimname]
     11325        timewrfv = odimvar[:]
     11326        tvals, tunits = compute_WRFtime(timewrfv, refdate='19491201000000', tunitsval='minutes')
     11327        dimtwrf = len(tvals)
     11328        if not gen.searchInlist(newnc.dimensions,'time'):
     11329            newnc.createDimension('time',None)
     11330        newvar = newnc.createVariable('time', 'f8', 'time')
     11331        basicvardef(newvar, 'time', 'Time', tunits)
     11332        newvar.setncattr('axis', 'T')
     11333        newvar.setncattr('_CoordinateAxisType', 'Time')
     11334        set_attribute(newvar, 'calendar', 'standard')
    1131911335
    1132011336    # Checking units of condimvar
Note: See TracChangeset for help on using the changeset viewer.