Changeset 514 in lmdz_wrf for trunk/tools/validation_sim.py
- Timestamp:
- Jun 19, 2015, 12:04:50 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/validation_sim.py
r512 r514 1120 1120 return 1121 1121 1122 def getting_ValidationValues(okind, dimt , ds, trjpos, ovs, ovo, tvalues, oFill, Ng):1122 def getting_ValidationValues(okind, dimt0, ds, trjpos, ovs, ovo, tvalues, oFill, Ng, kvals): 1123 1123 """ Function to get the values to validate accroding to the type of observation 1124 1124 okind= observational kind 1125 dimt =number of values to retrieve1125 dimt0= initial number of values to retrieve 1126 1126 ds= dictionary with the names of the dimensions (sim, obs) 1127 1127 trjpos= positions of the multi-stations (t, Y, X) or trajectory ([Z], Y, X) … … 1131 1131 oFill= Fill Value for the observations 1132 1132 Ng= number of grid points around the observation 1133 kvals= kind of values 1134 'instantaneous': values are taken as instantaneous values 1135 'tbackwardSmean': simulated values are taken as time averages from back to the point 1136 'tbackwardOmean': observed values are taken as time averages from back to the point 1133 1137 return: 1134 1138 sovalues= simulated values at the observation point and time … … 1141 1145 1142 1146 sovalues = [] 1147 1148 if kvals == 'instantaneous': 1149 dimt = dimt0 1150 elif kvals == 'tbackwardSmean': 1151 print ' ' + fname + ':',kvals,'!!' 1152 dimt = len(tvalues[:,3]) 1153 print ' : initially we got',dimt0,'values which will become',dimt 1154 quit() 1155 elif kvals == 'tbackwardOmean': 1156 print ' ' + fname + ':',kvals,'!!' 1157 dimt = len(tvalues[:,2]) 1158 print ' : initially we got',dimt0,'values which will become',dimt 1159 else: 1160 print errormsg 1161 print ' ' + fname + ": kind of values '" + kvals + "' not ready!!" 1162 quit(-1) 1143 1163 1144 1164 # Simulated values spatially around … … 1810 1830 Esimobsvalues, EsimobsSvalues, EsimobsTvalues, EsimobsTtvalues, trjsim = \ 1811 1831 getting_ValidationValues(obskind, Nexactt, dims, trajpos, ovsim, ovobs, \ 1812 exacttvalues, oFillValue, Ngrid )1832 exacttvalues, oFillValue, Ngrid, 'instantaneous') 1813 1833 1814 1834 # Observed values temporally around coincident times 1815 1835 simobsvalues, simobsSvalues, simobsTvalues, simobsTtvalues, trjsim = \ 1816 1836 getting_ValidationValues(obskind, Ncoindt, dims, trajpos, ovsim, ovobs, \ 1817 coindtvalues, oFillValue, Ngrid )1837 coindtvalues, oFillValue, Ngrid, 'tbackwardaverage') 1818 1838 1819 1839 # Re-arranging values... … … 1968 1988 simobsstats[1,12]=(simstats[1,0]-obsstats[1,0])/(0.5*(simstats[1,0]+obsstats[1,0])) 1969 1989 1970 # Statistics around sim values 1990 # Statistics around sim values exact 1991 Earoundstats = np.zeros((5,Nexactt), dtype=np.float) 1992 for it in range(Nexactt): 1993 Earoundstats[0,it] = np.min(EsimobsSvalues[it,]) 1994 Earoundstats[1,it] = np.max(EsimobsSvalues[it,]) 1995 Earoundstats[2,it] = np.mean(EsimobsSvalues[it,]) 1996 Earoundstats[3,it] = np.mean(EsimobsSvalues[it,]*EsimobsSvalues[it,]) 1997 Earoundstats[4,it] = np.sqrt(Earoundstats[3,it] - Earoundstats[2,it]* \ 1998 Earoundstats[2,it]) 1999 2000 # Statistics around obs values exact 2001 Earoundostats = np.zeros((6,Nexactt), dtype=np.float) 2002 2003 for it in range(Nexactt): 2004 obsmask = ma.masked_equal(EsimobsTvalues[str(it)], fillValueF) 2005 obsmask2 = obsmask*obsmask 2006 2007 Earoundostats[0,it] = len(obsmask.flatten()) 2008 Earoundostats[1,it] = obsmask.min() 2009 Earoundostats[2,it] = obsmask.max() 2010 Earoundostats[3,it] = obsmask.mean() 2011 Earoundostats[4,it] = obsmask2.mean() 2012 Earoundostats[5,it] = np.sqrt(Earoundostats[4,it] - Earoundostats[3,it]* \ 2013 Earoundostats[3,it]) 2014 2015 # Statistics around sim values between 1971 2016 aroundstats = np.zeros((5,Ncoindt), dtype=np.float) 1972 2017 for it in range(Ncoindt): … … 1978 2023 aroundstats[2,it]) 1979 2024 1980 # Statistics around obs values 2025 # Statistics around obs values between 1981 2026 aroundostats = np.zeros((6,Ncoindt), dtype=np.float) 1982 2027 … … 2022 2067 newvar[:] = arrayvals[:,1] 2023 2068 2024 # Around values 2069 # Around values exact 2070 if not onewnc.variables.has_key(valvars[ivar][0] + 'Earound'): 2071 if dims.has_key('Z'): 2072 if not onewnc.dimensions.has_key('zaround'): 2073 newdim = onewnc.createDimension('zaround',Ngrid*2+1) 2074 newvar = onewnc.createVariable(valvars[ivar][0] + 'Earound', 'f', \ 2075 ('time','zaround','yaround','xaround'), fill_value=fillValueF) 2076 else: 2077 newvar = onewnc.createVariable(valvars[ivar][0] + 'Earound', 'f', \ 2078 ('time','yaround','xaround'), fill_value=fillValueF) 2079 2080 descvar = 'exact around simulated values +/- grid values: ' + valvars[ivar][0] 2081 basicvardef(newvar, varsimobs + 'Earound', descvar, ovobs.getncattr('units')) 2082 newvar[:] = EsimobsSvalues 2083 2084 # Around values between 2025 2085 if not onewnc.variables.has_key(valvars[ivar][0] + 'around'): 2026 2086 if dims.has_key('Z'): … … 2028 2088 newdim = onewnc.createDimension('zaround',Ngrid*2+1) 2029 2089 newvar = onewnc.createVariable(valvars[ivar][0] + 'around', 'f', \ 2030 (' time','zaround','yaround','xaround'),fill_value=fillValueF)2090 ('betweentime','zaround','yaround','xaround'),fill_value=fillValueF) 2031 2091 else: 2032 2092 newvar = onewnc.createVariable(valvars[ivar][0] + 'around', 'f', \ … … 2063 2123 newvar[:] = simobsstats 2064 2124 2065 # around sim Statistics 2125 # around sim Statistics exact 2126 if not searchInlist(onewnc.variables,valvars[ivar][0] + 'Estaround'): 2127 newvar = onewnc.createVariable(valvars[ivar][0] + 'Estaround', 'f', \ 2128 ('time','stats'), fill_value=fillValueF) 2129 descvar = 'exact around (' + str(Ngrid) + ', ' + str(Ngrid) + \ 2130 ') simulated statisitcs: ' + valvars[ivar][0] 2131 basicvardef(newvar, valvars[ivar][0] + 'Estaround', descvar, \ 2132 ovobs.getncattr('units')) 2133 set_attribute(newvar, 'cell_methods', 'Etime_bnds') 2134 newvar[:] = Earoundstats.transpose() 2135 2136 if not searchInlist(onewnc.variables, 'Etime_bnds'): 2137 newvar = onewnc.createVariable('Etime_bnds','f8',('time','bnds')) 2138 basicvardef(newvar, 'Etime_bnds', 'betweentime', obstunits ) 2139 set_attribute(newvar, 'calendar', 'standard') 2140 newvar[:] = EsimobsTtvalues 2141 2142 # around obs Statistics exact 2143 if not searchInlist(onewnc.variables,valvars[ivar][1] + 'Estaround'): 2144 newvar = onewnc.createVariable(valvars[ivar][1] + 'Estaround', 'f', \ 2145 ('time','tstats'), fill_value=fillValueF) 2146 descvar = 'exact around temporal observed statisitcs: ' + valvars[ivar][1] 2147 basicvardef(newvar, valvars[ivar][1] + 'Estaround', descvar, \ 2148 ovobs.getncattr('units')) 2149 set_attribute(newvar, 'cell_methods', 'Etime_bnds') 2150 2151 newvar[:] = aroundostats.transpose() 2152 2153 # around sim Statistics between 2066 2154 if not searchInlist(onewnc.variables,valvars[ivar][0] + 'staround'): 2067 2155 newvar = onewnc.createVariable(valvars[ivar][0] + 'staround', 'f', \ 2068 2156 ('betweentime','stats'), fill_value=fillValueF) 2069 descvar = ' around (' + str(Ngrid) + ', ' + str(Ngrid) +\2157 descvar = 'between around (' + str(Ngrid) + ', ' + str(Ngrid) + \ 2070 2158 ') simulated statisitcs: ' + valvars[ivar][0] 2071 2159 basicvardef(newvar, valvars[ivar][0] + 'staround', descvar, \ 2072 2160 ovobs.getncattr('units')) 2161 set_attribute(newvar, 'cell_methods', 'time_bnds') 2073 2162 newvar[:] = aroundstats.transpose() 2074 2163 … … 2079 2168 newvar[:] = simobsTtvalues 2080 2169 2081 # around obs Statistics 2170 # around obs Statistics between 2082 2171 if not searchInlist(onewnc.variables,valvars[ivar][1] + 'staround'): 2083 2172 newvar = onewnc.createVariable(valvars[ivar][1] + 'staround', 'f', \ 2084 2173 ('betweentime','tstats'), fill_value=fillValueF) 2085 descvar = ' around temporal observed statisitcs: ' + valvars[ivar][1]2174 descvar = 'betweem around temporal observed statisitcs: ' + valvars[ivar][1] 2086 2175 basicvardef(newvar, valvars[ivar][1] + 'staround', descvar, \ 2087 2176 ovobs.getncattr('units')) 2088 set_attribute(newvar, 'cell_methods', 'statistics') 2089 2177 set_attribute(newvar, 'cell_methods', 'time_bnds') 2090 2178 newvar[:] = aroundostats.transpose() 2091 2179
Note: See TracChangeset
for help on using the changeset viewer.