Changeset 1430 in lmdz_wrf


Ignore:
Timestamp:
Jan 20, 2017, 12:53:55 PM (8 years ago)
Author:
lfita
Message:

Adding creation of varibale `time' in 'mthDYNAMICO_toCF'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1429 r1430  
    1790017900
    1790117901    # CFing variable 'time_centerd'
    17902     if gen.searchInlist(ncvars,'time_centered'):
     17902    if gen.searchInlist(ncvars,'time'):
    1790317903        print warnmsg
    17904         print fname + ": renaming variable 'time_centerd' as 'time' !!"
    17905         newname = ncf.renameVariable('time_centered','time')
     17904        print fname + ": readjusting variable 'time' !!"
     17905        otime = ncf.variables['time']
     17906        otime[:] = newtvals
     17907        timeattrs = otime.ncattrs()
     17908        chgattrs = ['standard_name', 'long_name', 'units', 'time_origin']
     17909        for chga in chgattrs:
     17910            if gen.searchInlist(timeattrs,chga):
     17911                otime.delncattr(chga)
     17912        newattr = set_attribute(otime, 'standard_name', 'time')
     17913        newattr = set_attribute(otime, 'long_name', 'Time')
     17914        newattr = set_attribute(otime, 'units', CFtimeUnits)
     17915    else:
     17916        newvar = ncf.createVariable('time', 'f8', ('time'))
     17917        newvar[:] = newtvals
     17918        newattr = set_attribute(newvar, 'standard_name', 'time')
     17919        newattr = set_attribute(newvar, 'long_name', 'Time')
     17920        newattr = set_attribute(newvar, 'units', CFtimeUnits)
    1790617921    ncf.sync()
    1790717922
Note: See TracChangeset for help on using the changeset viewer.