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


Ignore:
Timestamp:
Aug 15, 2016, 2:37:52 PM (8 years ago)
Author:
lfita
Message:

Adding `[chdimname]': whether west_east, south_north dimensions should change names to 'lon','lat' to 'WRF_CFlonlat_creation'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1019 r1021  
    1005610056    """ Function to add a CF-convention longitude/latitude variables in a WRF file
    1005710057    WRF_CFlon_creation(values, ncfile, varn)
    10058       [values]= [lonname],[latname] names of the variables to add (standard names
    10059         'longitude', 'latitude')
     10058      [values]= [lonname],[latname],[chdimname]
     10059        [lonname],[latname]: names of the variables to add (standard names 'longitude', 'latitude')
     10060        [chdimname]: whether west_east, south_north dimensions should change names to 'lon','lat'
    1006010061      [ncfile]= WRF file to add the CF-convention time variable
    1006110062      [varn]= [lonname],[latname] name of the variables to use
     
    1007010071    cflonn = values.split(',')[0]
    1007110072    cflatn = values.split(',')[1]
     10073    chdimn = gen.Str_Bool(values.split(',')[2])
    1007210074
    1007310075    wlonn = varn.split(',')[0]
     
    1013710139
    1013810140    # Creation of CF-dimensions
    10139     if not wrfnc.dimensions.has_key('lon'):
    10140         newdim = wrfnc.createDimension('lon', dimx)
    10141     if not wrfnc.dimensions.has_key('lat'):
    10142         newdim = wrfnc.createDimension('lat', dimy)
     10141    if chdimn:
     10142        wrfnc.renameDimension('west_east', 'lon')
     10143        wrfnc.renameDimension('south_north', 'lat')
     10144    else:
     10145        if not wrfnc.dimensions.has_key('lon'):
     10146            newdim = wrfnc.createDimension('lon', dimx)
     10147        if not wrfnc.dimensions.has_key('lat'):
     10148            newdim = wrfnc.createDimension('lat', dimy)
    1014310149
    1014410150    if wrfnc.variables.has_key(cflonn):
     
    1625816264    # Creation of pressure variable dimension
    1625916265    newvar = onewnc.createVariable('pres', 'f8', ('pres'))
    16260     newvar[:] = interplevs * 100.
     16266    newvar[:] = interplevs
    1626116267    basicvardef(newvar, 'pressure', 'Pressure', 'Pa')
    1626216268    attr = set_attribute(newvar, 'positive', 'down')
     
    1647816484 
    1647916485    # CFing lon,lat
    16480     WRF_CFlonlat_creation('lon,lat', ncfile, wrfvl+','+wrfvL)
     16486    WRF_CFlonlat_creation('lon,lat,true', ncfile, wrfvl+','+wrfvL)
    1648116487
    1648216488    ncf = NetCDFFile(ncfile,'a')
Note: See TracChangeset for help on using the changeset viewer.