Changeset 970 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jun 29, 2016, 4:56:59 PM (8 years ago)
Author:
lfita
Message:

Adding warning on non existing variable in `compute_opersvarsfiles'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r967 r970  
    68446844# Variables for dimensions
    68456845    for varn in dimovars:
    6846         varobj = objnc.variables[varn]
    6847         newvar = objofile.createVariable(varn, varobj.dtype, varobj.dimensions)
    6848         for attrn in  varobj.ncattrs():
    6849             attrval = varobj.getncattr(attrn)
    6850             newattr = newvar.setncattr(attrn, attrval)
    6851         newvar[:] = varobj[:]
     6846        if not gen.searchInlist(list(objnc.variables.keys()), varn):
     6847            print warnmsg
     6848            print '  ' + fname + " file does not have dimension variable '" + varn + \
     6849              "' skipping it !!"
     6850        else:
     6851            varobj = objnc.variables[varn]
     6852            newvar = objofile.createVariable(varn, varobj.dtype, varobj.dimensions)
     6853            for attrn in  varobj.ncattrs():
     6854                attrval = varobj.getncattr(attrn)
     6855                newattr = newvar.setncattr(attrn, attrval)
     6856            newvar[:] = varobj[:]
    68526857
    68536858    newvar = objofile.createVariable(varname, vartype, vardims)
Note: See TracChangeset for help on using the changeset viewer.