Changeset 566 in lmdz_wrf for trunk/tools/TS_ASCII_netCDF.py
- Timestamp:
- Jul 6, 2015, 2:38:18 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/TS_ASCII_netCDF.py
r504 r566 13 13 14 14 fillValue = 1.e20 15 16 def ts_header(ln): 17 """ Function to get the values of the header of the *.TS files 18 line=ASCII lines with the header of the TS file 19 getting the line format from WRFV3.3 'EMCORE' in file 'share/wrf_timeseries.F' 20 """ 21 fname = 'ts_header' 22 23 fmt=['A26', 'I2', 'I3', 'A6', 'A2', 'F7.3', 'A1', 'F8.3', 'A3', 'I4', 'A1', 'I4',\ 24 'A3', 'F7.3', 'A1', 'F8.3', 'A2', 'F6.1', 'A7'] 25 26 ncvar.values_fortran_fmt(ln,fmt) 27 28 return headervalues 15 29 16 30 ####### ###### ##### #### ### ## # … … 87 101 if iline == 0: 88 102 newvar = objofile.createVariable('station','c') 89 values par=line.split('(')103 valueshead = ts_header(line) 90 104 91 sec = ncvar.reduce_spaces(valuespar[0]) 92 Nsec = len(sec) 93 ncvar.set_attribute(newvar, 'name', ncvar.numVector_String(sec[0:Nsec-3],' ')) 94 ncvar.set_attribute(newvar, 'acronym',sec[Nsec-1]) 105 ncvar.set_attribute(newvar, 'name', valueshead[0]) 106 ncvar.set_attribute(newvar, 'acronym',valueshead[3].replace(' ','')) 95 107 96 sec = ncvar.reduce_spaces(valuespar[1]) 97 Nsec = len(sec) 98 ncvar.set_attribute(newvar, 'real_lon', \ 99 np.float(sec[1].replace(',','').replace('(','').replace(')','')) ) 100 ncvar.set_attribute(newvar, 'real_lat', \ 101 np.float(sec[0].replace(',','').replace('(','').replace(')','')) ) 108 ncvar.set_attribute(newvar, 'real_lon', valueshead[5]) 109 ncvar.set_attribute(newvar, 'real_lat', valueshead[7]) 102 110 103 sec = ncvar.reduce_spaces(valuespar[2]) 104 Nsec = len(sec) 105 ncvar.set_attribute(newvar, 'x_grid_point', \ 106 int(sec[0].replace(',','').replace('(','').replace(')','')) ) 107 ncvar.set_attribute(newvar, 'y_grid_point', \ 108 int(sec[1].replace(',','').replace('(','').replace(')','')) ) 111 ncvar.set_attribute(newvar, 'x_grid_point', valueshead[9]) 112 ncvar.set_attribute(newvar, 'y_grid_point', valueshead[11]) 109 113 110 sec = ncvar.reduce_spaces(valuespar[3]) 111 Nsec = len(sec) 112 ncvar.set_attribute(newvar, 'model_lon', \ 113 np.float(sec[1].replace(',','').replace('(','').replace(')','')) ) 114 ncvar.set_attribute(newvar, 'model_lat', \ 115 np.float(sec[0].replace(',','').replace('(','').replace(')','')) ) 116 ncvar.set_attribute(newvar, 'model_height', \ 117 np.float(sec[2].replace(',','').replace('(','').replace(')','')) ) 114 ncvar.set_attribute(newvar, 'model_lon', valueshead[13]) 115 ncvar.set_attribute(newvar, 'model_lat', valueshead[15]) 116 ncvar.set_attribute(newvar, 'model_height', valueshead[17]) 118 117 simstarttime = refdate 119 118 else:
Note: See TracChangeset
for help on using the changeset viewer.