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


Ignore:
Timestamp:
Aug 20, 2016, 3:37:38 PM (8 years ago)
Author:
lfita
Message:

Adding pre-existing attribute `long_name' on variable name in 'compute_opersvarsfiles'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1024 r1033  
    68596859              "' skipping it !!"
    68606860        else:
    6861             varobj = objnc.variables[varn]
    6862             newvar = objofile.createVariable(varn, varobj.dtype, varobj.dimensions)
    6863             for attrn in  varobj.ncattrs():
    6864                 attrval = varobj.getncattr(attrn)
     6861            dvarobj = objnc.variables[varn]
     6862            newvar = objofile.createVariable(varn, dvarobj.dtype, dvarobj.dimensions)
     6863            for attrn in  dvarobj.ncattrs():
     6864                attrval = dvarobj.getncattr(attrn)
    68656865                newattr = newvar.setncattr(attrn, attrval)
    6866             newvar[:] = varobj[:]
     6866            newvar[:] = dvarobj[:]
    68676867
    68686868    newvar = objofile.createVariable(varname, vartype, vardims)
    68696869    newvar[:] = newvarv
     6870    varattrs = varobj.ncattrs()
     6871    if gen.searchInlist(varattrs,'long_name'):
     6872        operation = varobj.getncattr('long_name') + '; ' + operation
     6873
    68706874    newattr = basicvardef(newvar, varname, operation, newunits)
     6875    stdattrs = ['standard_name', 'long_name', 'units']
     6876    for attrn in varattrs:
     6877        if not gen.searchInlist(stdattrs, attrn):
     6878            attrv = varobj.getncattr(attrn)
     6879            newattr = set_attribute(newvar,attrn,attrv)
    68716880
    68726881# Global attributes
Note: See TracChangeset for help on using the changeset viewer.