Changeset 1047 in lmdz_wrf for trunk


Ignore:
Timestamp:
Aug 26, 2016, 9:19:03 PM (9 years ago)
Author:
lfita
Message:

Adding creation of dimension from a new variable just in case it does not exist in `compute_opersvarsfiles'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1046 r1047  
    58065806        ncoobj.sync()
    58075807
    5808         print newvar
    5809 
    58105808        for attrs in varattrs:
    58115809            if not attrs == '_FillValue':
     
    58135811                attr = set_attribute(newvar, attrs, attrv)
    58145812        ncoobj.sync()
    5815 
    58165813
    58175814# Global attributes
     
    68686865# Variables for dimensions
    68696866    for varn in dimovars:
     6867
    68706868        if not gen.searchInlist(list(objnc.variables.keys()), varn):
    68716869            print warnmsg
     
    68746872        else:
    68756873            dvarobj = objnc.variables[varn]
     6874            # Adding that dimensions of the variable which might not be in the output
     6875            for vdn in dvarobj.dimensions:
     6876                if not objofile.dimensions.has_key(vdn):
     6877                    addvdno = objnc.dimensions[vdn]
     6878                    if addvdno.isunlimited():
     6879                        objofile.createDimension(vdn, None)
     6880                    else:
     6881                        objofile.createDimension(vdn, len(addvdno))
     6882            # Adding new variable to output
    68766883            newvar = objofile.createVariable(varn, dvarobj.dtype, dvarobj.dimensions)
    68776884            for attrn in  dvarobj.ncattrs():
Note: See TracChangeset for help on using the changeset viewer.