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


Ignore:
Timestamp:
Jan 20, 2017, 1:09:01 PM (8 years ago)
Author:
lfita
Message:

Reverting order, first re-name dimension, then create variable `time' in 'mthDYNAMICO_toCF'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1430 r1432  
    1789917899    ncf.sync()
    1790017900
     17901    # CFing dimensions
     17902    CFdims = {'time_counter': 'time', 'presnivs': 'pres'}
     17903    for dimn in CFdims.keys():
     17904        if gen.searchInlist(ncdims,dimn):
     17905            # Making sure CF dimension is not in the file
     17906            if not gen.searchInlist(ncdims,CFdims[dimn]):
     17907                newname = ncf.renameDimension(dimn,CFdims[dimn])
     17908    ncf.sync()
     17909
    1790117910    # CFing variable 'time_centerd'
    1790217911    if gen.searchInlist(ncvars,'time'):
     
    1790617915        otime[:] = newtvals
    1790717916        timeattrs = otime.ncattrs()
    17908         chgattrs = ['standard_name', 'long_name', 'units', 'time_origin']
     17917        chgattrs= ['standard_name','long_name','units', 'time_origin', 'cell_method']
    1790917918        for chga in chgattrs:
    1791017919            if gen.searchInlist(timeattrs,chga):
     
    1791317922        newattr = set_attribute(otime, 'long_name', 'Time')
    1791417923        newattr = set_attribute(otime, 'units', CFtimeUnits)
     17924        newattr = set_attribute(otime, 'cell_method', 'time mean')
    1791517925    else:
    1791617926        newvar = ncf.createVariable('time', 'f8', ('time'))
     
    1791917929        newattr = set_attribute(newvar, 'long_name', 'Time')
    1792017930        newattr = set_attribute(newvar, 'units', CFtimeUnits)
    17921     ncf.sync()
    17922 
    17923     # CFing dimensions
    17924     CFdims = {'time_counter': 'time', 'presnivs': 'pres'}
    17925     for dimn in CFdims.keys():
    17926         if gen.searchInlist(ncdims,dimn):
    17927             # Making sure CF dimension is not in the file
    17928             if not gen.searchInlist(ncdims,CFdims[dimn]):
    17929                 newname = ncf.renameDimension(dimn,CFdims[dimn])
     17931        newattr = set_attribute(otime, 'cell_method', 'time mean')
    1793017932    ncf.sync()
    1793117933
Note: See TracChangeset for help on using the changeset viewer.