Changeset 1467 in lmdz_wrf for trunk


Ignore:
Timestamp:
Mar 9, 2017, 9:50:54 AM (8 years ago)
Author:
lfita
Message:

Adding:

`get_varunits': Getting the units of a variable object

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1461 r1467  
    7474# get_Variables: Function to get a list of variables from an existing file
    7575# getvalues_lonlat: Function to retrieve the values from the closest grid point to a set of longitude, latitude values
     76# get_varunits: Getting the units of a variable object
    7677# getvars_tofile: Function to get variables from a file and pass them to another one
    7778# grattr: Function to read a global atribute
     
    1904519046    return arrayvalues
    1904619047
     19048def get_varunits(ovar):
     19049    """ Getting the units of a variable object
     19050      ovar: object variable from which get the units
     19051    """
     19052    fname = 'get_varunits'
     19053
     19054    varattrs = ovar.ncattrs()
     19055    if gen.searchInlist(varattrs,'units'):
     19056        varunits = ovar.units
     19057    else:
     19058        varunits = gen.variables_values(ovar.name)[5]
     19059
     19060    return varunits
     19061
    1904719062#quit()
Note: See TracChangeset for help on using the changeset viewer.