Changeset 619 in lmdz_wrf for trunk


Ignore:
Timestamp:
Aug 21, 2015, 1:06:47 PM (9 years ago)
Author:
lfita
Message:

Adding right names for the variables more CF like!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/TS_ASCII_netCDF.py

    r571 r619  
    149149ncvar.set_attribute(newvar, 'calendar', 'standard')
    150150
     151dt = time_stepv[1] - time_stepv[0]
     152
    151153# time-series variables
    152154for iv in range(Ntsvariables):
    153     newvar = objofile.createVariable(tsvn[iv], 'f4', ('time'))
     155    if tsvn[iv] == 't' or tsvn[iv] == 'u' or tsvn[iv] == 'v' or tsvn[iv] == 'q':
     156      varname, stdname, minvar, maxvar, longname, unitsvar, cbarvar =                \
     157      ncvar.variables_values('TS' + tsvn[iv])
     158      tsu = unitsvar
     159    else:
     160      varname, stdname, minvar, maxvar, longname, unitsvar, cbarvar =                \
     161      ncvar.variables_values(tsvn[iv])
     162      tsu = tsvu[iv]
     163
     164    newvar = objofile.createVariable(varname, 'f4', ('time'))
    154165    newvar[:] = tsvaluesv[:,iv]
    155     newattr = ncvar.basicvardef(newvar, tsvn[iv], tsvln[iv], tsvu[iv] )
     166
     167    newattr = ncvar.basicvardef(newvar, stdname, longname.replace('|',' '), tsu)
     168    newattr = ncvar.set_attribute(newvar, 'wrfTSname', tsvn[iv])
     169    newattr = ncvar.set_attribute(newvar, 'wrfTSdesc', tsvln[iv])
    156170
    157171# Extra vars
     
    160174varvals = np.zeros((dimt), dtype=np.float)
    161175varvals[1:dimt] = pracc[1:dimt] - pracc[0:dimt-1]
     176varname, stdname, minvar, maxvar, longname, unitsvar, cbarvar =                      \
     177      ncvar.variables_values('RAINTOT')
    162178
    163 newvar = objofile.createVariable('pr', 'f4', ('time'))
    164 newvar[:] = varvals
    165 newattr = ncvar.basicvardef(newvar, 'pr', 'precipitation', 'mm' )
     179newvar = objofile.createVariable(varname, 'f4', ('time'))
     180newvar[:] = varvals / dt
     181newattr = ncvar.basicvardef(newvar, stdname, longname.replace('|',' '), unitsvar )
    166182
    167183objofile.sync()
Note: See TracChangeset for help on using the changeset viewer.