- Timestamp:
- Aug 21, 2015, 1:06:47 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/TS_ASCII_netCDF.py
r571 r619 149 149 ncvar.set_attribute(newvar, 'calendar', 'standard') 150 150 151 dt = time_stepv[1] - time_stepv[0] 152 151 153 # time-series variables 152 154 for 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')) 154 165 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]) 156 170 157 171 # Extra vars … … 160 174 varvals = np.zeros((dimt), dtype=np.float) 161 175 varvals[1:dimt] = pracc[1:dimt] - pracc[0:dimt-1] 176 varname, stdname, minvar, maxvar, longname, unitsvar, cbarvar = \ 177 ncvar.variables_values('RAINTOT') 162 178 163 newvar = objofile.createVariable( 'pr', 'f4', ('time'))164 newvar[:] = varvals 165 newattr = ncvar.basicvardef(newvar, 'pr', 'precipitation', 'mm')179 newvar = objofile.createVariable(varname, 'f4', ('time')) 180 newvar[:] = varvals / dt 181 newattr = ncvar.basicvardef(newvar, stdname, longname.replace('|',' '), unitsvar ) 166 182 167 183 objofile.sync()
Note: See TracChangeset
for help on using the changeset viewer.