Changeset 492 in lmdz_wrf
- Timestamp:
- Jun 15, 2015, 12:14:14 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/validation_sim.py
r491 r492 985 985 return self.__values[elem] 986 986 987 def adding_station_desc(onc,stdesc): 988 """ Function to add a station description in a netCDF file 989 onc= netCDF object 990 stdesc= station description lon, lat, height 991 """ 992 fname = 'adding_station_desc' 993 994 newvar = objfile.createVariable( 'station', 'c', ('StrLength')) 995 newvar[0:len(stdesc[0])] = stdesc[0] 996 997 newdim = onc.createDimension('nst',1) 998 999 if onc.variables.has_key('lon'): 1000 print warnmsg 1001 print ' ' + fname + ": variable 'lon' already exist !!" 1002 print " renaming it as 'lonst'" 1003 lonname = 'lonst' 1004 else: 1005 lonname = 'lon' 1006 1007 newvar = objfile.createVariable( lonname, 'f4', ('nst')) 1008 basicvardef(newvar, lonname, 'longitude', 'degrees_West' ) 1009 newvar[:] = stdesc[1] 1010 1011 if onc.variables.has_key('lat'): 1012 print warnmsg 1013 print ' ' + fname + ": variable 'lat' already exist !!" 1014 print " renaming it as 'latst'" 1015 latname = 'latst' 1016 else: 1017 latname = 'lat' 1018 1019 newvar = objfile.createVariable( latname, 'f4', ('nst')) 1020 basicvardef(newvar, lonname, 'latitude', 'degrees_North' ) 1021 newvar[:] = stdesc[2] 1022 1023 if onc.variables.has_key('height'): 1024 print warnmsg 1025 print ' ' + fname + ": variable 'height' already exist !!" 1026 print " renaming it as 'heightst'" 1027 heightname = 'heightst' 1028 else: 1029 heightname = 'height' 1030 1031 newvar = objfile.createVariable( heightname, 'f4', ('nst')) 1032 basicvardef(newvar, heightname, 'height above sea level', 'm' ) 1033 newvar[:] = stdesc[3] 1034 1035 return 1036 987 1037 ####### ###### ##### #### ### ## # 988 1038 … … 1029 1079 help=strkObs, metavar="FILE") 1030 1080 parser.add_option("-l", "--stationLocation", dest="stloc", 1031 help=" longitude, latitude and height of the station (only for 'single-station')",1081 help="name, longitude, latitude and height of the station (only for 'single-station')", 1032 1082 metavar="FILE") 1033 1083 parser.add_option("-o", "--observation", dest="fobs", … … 1106 1156 quit(-1) 1107 1157 else: 1108 stationdesc = [np.float(opts.stloc.split(',')[0]), \ 1109 np.float(opts.stloc.split(',')[1]), np.float(opts.stloc.split(',')[2])] 1158 stationdesc = [opts.stloc.split(',')[0], \ 1159 np.float(opts.stloc.split(',')[1]), np.float(opts.stloc.split(',')[2]),\ 1160 np.float(opts.stloc.split(',')[3])] 1110 1161 1111 1162 if opts.fobs is None: … … 1176 1227 else: 1177 1228 if dn == 'X': 1178 valdimobs[dn] = stationdesc[ 0]1229 valdimobs[dn] = stationdesc[1] 1179 1230 elif dn == 'Y': 1180 valdimobs[dn] = stationdesc[ 1]1231 valdimobs[dn] = stationdesc[2] 1181 1232 elif dn == 'Z': 1182 valdimobs[dn] = stationdesc[ 2]1233 valdimobs[dn] = stationdesc[3] 1183 1234 1184 1235 osim = NetCDFFile(opts.fsim, 'r') … … 1728 1779 newvar[:] = trjsim.transpose() 1729 1780 1781 # Adding three variables with the station location, longitude, latitude and height 1782 if obskind == 'single-station': 1783 adding_station_desc(objfile,stationdesc) 1784 1730 1785 # Global attributes 1731 1786 ##
Note: See TracChangeset
for help on using the changeset viewer.