Changeset 648 in lmdz_wrf
- Timestamp:
- Sep 23, 2015, 11:23:57 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/create_OBSnetcdf.py
r587 r648 216 216 newval = None 217 217 else: 218 print 'op: **' + op + '**'219 218 if op != '-': 220 219 opern = op.split(',')[0] … … 816 815 " and time units: 'weeks', 'days', 'hours', 'miuntes', 'seconds')" 817 816 818 kindobs=[' multi-points', 'single-station', 'trajectory']817 kindobs=['stations-map','multi-points', 'single-station', 'trajectory'] 819 818 strkObs="kind of observations; 'multi-points': multiple individual punctual obs " + \ 820 819 "(e.g., lightning strikes), 'single-station': single station on a fixed position,"+\ … … 963 962 # Total number of values 964 963 Ntvalues = len(datavalues[description['varN'][0]]) 965 print main + ': total temporal values found:',Ntvalues 964 if obskind == 'stations-map': 965 print main + ': total values found:',Ntvalues 966 else: 967 print main + ': total temporal values found:',Ntvalues 966 968 967 969 objfile = NetCDFFile(ofile, 'w') … … 969 971 # Creation of dimensions 970 972 ## 971 objfile.createDimension('time',None) 973 if obskind == 'stations-map': 974 rowsdim = 'Npoints' 975 dimlength = Ntvalues 976 else: 977 rowsdim = 'time' 978 dimlength = None 979 980 objfile.createDimension(rowsdim,dimlength) 972 981 objfile.createDimension('StrLength',StringLength) 973 982 … … 979 988 980 989 if formats[ivar] == 'D': 981 newvar = objfile.createVariable(varn, 'f32', ( 'time'), fill_value=fillValueF)990 newvar = objfile.createVariable(varn, 'f32', (rowsdim), fill_value=fillValueF) 982 991 basicvardef(newvar, varn, description['varLN'][ivar], \ 983 992 description['varU'][ivar]) 984 993 newvar[:] = np.where(datavalues[varn] is None, fillValueF, datavalues[varn]) 985 994 elif formats[ivar] == 'F': 986 newvar = objfile.createVariable(varn, 'f', ( 'time'), fill_value=fillValueF)995 newvar = objfile.createVariable(varn, 'f', (rowsdim), fill_value=fillValueF) 987 996 basicvardef(newvar, varn, description['varLN'][ivar], \ 988 997 description['varU'][ivar]) 989 998 newvar[:] = np.where(datavalues[varn] is None, fillValueF, datavalues[varn]) 990 999 elif formats[ivar] == 'I': 991 newvar = objfile.createVariable(varn, 'i', ( 'time'), fill_value=fillValueI)1000 newvar = objfile.createVariable(varn, 'i', (rowsdim), fill_value=fillValueI) 992 1001 basicvardef(newvar, varn, description['varLN'][ivar], \ 993 1002 description['varU'][ivar]) … … 998 1007 newvar[:] = vals 999 1008 elif formats[ivar] == 'S': 1000 newvar = objfile.createVariable(varn, 'c', ( 'time','StrLength'))1009 newvar = objfile.createVariable(varn, 'c', (rowsdim,'StrLength')) 1001 1010 basicvardef(newvar, varn, description['varLN'][ivar], \ 1002 1011 description['varU'][ivar]) … … 1058 1067 basicvardef(newvar, timeCFname, 'time', tunits ) 1059 1068 else: 1069 newdim = objfile.createDimension('time',None) 1060 1070 timeCFname = 'time' 1061 1071 newvar = objfile.createVariable( timeCFname, 'f8', ('time')) … … 1063 1073 1064 1074 set_attribute(newvar, 'calendar', 'standard') 1065 newvar[:] = timevals 1075 if obskind == 'stations-map': 1076 newvar[:] = timevals[0] 1077 else: 1078 newvar[:] = timevals 1066 1079 1067 1080 # Global attributes
Note: See TracChangeset
for help on using the changeset viewer.