Changeset 503 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 15, 2015, 6:55:30 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/validation_sim.py
r502 r503 1243 1243 statsn = ['minimum', 'maximum', 'mean', 'mean2', 'standard deviation'] 1244 1244 gstatsn = ['bias', 'simobs_mean', 'sim_obsmin', 'sim_obsmax', 'sim_obsmean', 'mae', \ 1245 'rmse', 'r_pearsoncorr', 'p_pearsoncorr'] 1245 'rmse', 'r_pearsoncorr', 'p_pearsoncorr', 'deviation_of_residuals_SDR', \ 1246 'indef_of_efficiency_IOE', 'index_of_agreement_IOA', 'fractional_mean_bias_FMB'] 1246 1247 ostatsn = ['number of points', 'minimum', 'maximum', 'mean', 'mean2', \ 1247 1248 'standard deviation'] … … 1600 1601 newdim = onewnc.createDimension('xaround',Ngrid*2+1) 1601 1602 newdim = onewnc.createDimension('yaround',Ngrid*2+1) 1602 newdim = onewnc.createDimension('gstats', 9)1603 newdim = onewnc.createDimension('gstats',13) 1603 1604 newdim = onewnc.createDimension('stats',5) 1604 1605 newdim = onewnc.createDimension('tstats',6) 1605 newdim = onewnc.createDimension('Nstsim , 2)1606 newdim = onewnc.createDimension('Nstsim', 2) 1606 1607 1607 1608 # Variable dimensions … … 1742 1743 # statisics obs 1743 1744 # Masking 'nan' 1745 Eobsmask0 = np.where(Earrayvals[:,1] != Earrayvals[:,1], fillValueF, 1746 Earrayvals[:,1]) 1744 1747 obsmask0 = np.where(arrayvals[:,1] != arrayvals[:,1], fillValueF, arrayvals[:,1]) 1748 1749 Eobsmask = ma.masked_equal(Eobsmask0, fillValueF) 1750 Eobsmask2 = Eobsmask*Eobsmask 1745 1751 obsmask = ma.masked_equal(obsmask0, fillValueF) 1746 1752 obsmask2 = obsmask*obsmask 1747 1753 1748 obsstats = np.zeros((5), dtype=np.float) 1749 obsstats[0] = obsmask.min() 1750 obsstats[1] = obsmask.max() 1751 obsstats[2] = obsmask.mean() 1752 obsstats[3] = obsmask2.mean() 1753 obsstats[4] = np.sqrt(obsstats[3] - obsstats[2]*obsstats[2]) 1754 obsstats = np.zeros((2,5), dtype=np.float) 1755 obsstats[0,0] = obsmask.min() 1756 obsstats[0,1] = obsmask.max() 1757 obsstats[0,2] = obsmask.mean() 1758 obsstats[0,3] = obsmask2.mean() 1759 obsstats[0,4] = np.sqrt(obsstats[0,3] - obsstats[0,2]*obsstats[0,2]) 1760 1761 obsstats[1,0] = obsmask.min() 1762 obsstats[1,1] = obsmask.max() 1763 obsstats[1,2] = obsmask.mean() 1764 obsstats[1,3] = obsmask2.mean() 1765 obsstats[1,4] = np.sqrt(obsstats[1,3] - obsstats[1,2]*obsstats[1,2]) 1754 1766 1755 1767 # Statistics sim-obs … … 1758 1770 diffvals = np.zeros((Ncoindt), dtype=np.float) 1759 1771 1760 Ediffvals = Earrayvals[:,0] - obsmask1772 Ediffvals = Earrayvals[:,0] - Eobsmask 1761 1773 diffvals = arrayvals[:,0] - obsmask 1762 1774 … … 1769 1781 sumdiff2 = diff2vals.sum() 1770 1782 1771 simobsstats[0,0] = simstats[0,0] - obsstats[0 ]1772 simobsstats[0,1] = np.mean(Earrayvals[:,0]* obsmask)1783 simobsstats[0,0] = simstats[0,0] - obsstats[0,0] 1784 simobsstats[0,1] = np.mean(Earrayvals[:,0]*Eobsmask) 1773 1785 simobsstats[0,2] = Ediffvals.min() 1774 1786 simobsstats[0,3] = Ediffvals.max() … … 1777 1789 simobsstats[0,6] = np.sqrt(Ediff2vals.mean()) 1778 1790 simobsstats[0,7], simobsstats[0,8] = sts.mstats.pearsonr(Earrayvals[:,0], \ 1779 obsmask)1780 1781 simobsstats[1,0] = simstats[1,0] - obsstats[ 0]1791 Eobsmask) 1792 1793 simobsstats[1,0] = simstats[1,0] - obsstats[1,0] 1782 1794 simobsstats[1,1] = np.mean(arrayvals[:,0]*obsmask) 1783 1795 simobsstats[1,2] = diffvals.min() … … 1789 1801 obsmask) 1790 1802 # From: 1791 #Willmott, C. J. 1981. On the validation of models. Physical Geography, 2, 184â194 1792 #Willmott, C. J. (1984). On the evaluation of model performance in physical geography. Spatial Statistics and Models, G. L. Gaile and C. J. Willmott, eds., 443-460 1793 #Willmott, C. J., S. G. Ackleson, R. E. Davis, J. J. Feddema, K. M. Klink, D. R. Legates, J. O'Donnell, and C. M. Rowe (1985), Statistics for the Evaluation and Comparison of Models, J. Geophys. Res., 90(C5), 8995-9005 1794 #Legates, D. R., and G. J. McCabe Jr. (1999), Evaluating the Use of "Goodness-of-Fit" Measures in Hydrologic and Hydroclimatic Model Validation, Water Resour. Res., 35(1), 233â241 1803 #Willmott, C. J. 1981. 'On the validation of models. Physical Geography', 2, 184-194 1804 #Willmott, C. J. (1984). 'On the evaluation of model performance in physical 1805 # geography'. Spatial Statistics and Models, G. L. Gaile and C. J. Willmott, eds., 1806 # 443-460 1807 #Willmott, C. J., S. G. Ackleson, R. E. Davis, J. J. Feddema, K. M. Klink, D. R. 1808 # Legates, J. O'Donnell, and C. M. Rowe (1985), 'Statistics for the Evaluation and 1809 # Comparison of Models', J. Geophys. Res., 90(C5), 8995-9005 1810 #Legates, D. R., and G. J. McCabe Jr. (1999), 'Evaluating the Use of "Goodness-of-Fit" 1811 # Measures in Hydrologic and Hydroclimatic Model Validation', Water Resour. Res., 1812 # 35(1), 233-241 1795 1813 # 1796 1814 # Deviation of residuals (SDR) 1797 1815 simobsstats[0,9] = np.mean(np.sqrt(np.abs((Ediffvals-simobsstats[0,0])*(Ediffvals-\ 1798 obsstats[0 ]))))1816 obsstats[0,0])))) 1799 1817 simobsstats[1,9] = np.mean(np.sqrt(np.abs((diffvals-simobsstats[1,0])*(diffvals- \ 1800 obsstats[ 0]))))1818 obsstats[1,0])))) 1801 1819 # Index of Efficiency (IOE) 1802 obsbias2series = (obsmask - obsstats[0])*(obsmask - obsstats[0]) 1820 Eobsbias2series = (Eobsmask - obsstats[0,0])*(Eobsmask - obsstats[0,0]) 1821 Esumobsbias2series = Eobsbias2series.sum() 1822 obsbias2series = (obsmask - obsstats[1,0])*(obsmask - obsstats[1,0]) 1803 1823 sumobsbias2series = obsbias2series.sum() 1804 1824 1805 simobsstats[ 1,10] = 1. - Esumdiff2/(sumobsbias2series)1825 simobsstats[0,10] = 1. - Esumdiff2/(Esumobsbias2series) 1806 1826 simobsstats[1,10] = 1. - sumdiff2/(sumobsbias2series) 1807 1827 # Index of Agreement (IOA) 1808 Esimbias2series = Earrayvals[:,0] - obsstats[0] 1809 simbias2series = arrayvals[:,0] - obsstats[0] 1810 1811 obsbias2series = obsmask - obsstats[0] 1828 Esimbias2series = Earrayvals[:,0] - obsstats[0,0] 1829 simbias2series = arrayvals[:,0] - obsstats[1,0] 1830 1831 Eobsbias2series = Eobsmask - obsstats[0,0] 1832 obsbias2series = obsmask - obsstats[1,0] 1812 1833 1813 1834 Eabssimbias2series = np.abs(Esimbias2series) 1814 1835 abssimbias2series = np.abs(simbias2series) 1815 absobsbias2series = obbias2series.abs() 1816 1817 Eabssimobsbias2series = (Eabssimbias2series+absobsbias2series)*(Eabssimbias2series +\ 1818 absobsbias2series) 1836 Eabsobsbias2series = np.where(Eobsbias2series<0, -Eobsbias2series, Eobsbias2series) 1837 absobsbias2series = np.where(obsbias2series<0, -obsbias2series, obsbias2series) 1838 1839 Eabssimobsbias2series=(Eabssimbias2series+Eabsobsbias2series)*(Eabssimbias2series+\ 1840 Eabsobsbias2series) 1819 1841 abssimobsbias2series = (abssimbias2series+absobsbias2series)*(abssimbias2series +\ 1820 1842 absobsbias2series) … … 1823 1845 simobsstats[1,11] = 1. - sumdiff2/(abssimobsbias2series.sum()) 1824 1846 # Fractional Mean Bias (FMB) 1825 simobsstats[0,12] = (simstats[0,0]-obsstats[0])/(0.5*(simstats[0,0]+obsstats[0]))1826 simobsstats[1,12] = (simstats[1,0]-obsstats[0])/(0.5*(simstats[1,0]+obsstats[0]))1847 simobsstats[0,12]=(simstats[0,0]-obsstats[0,0])/(0.5*(simstats[0,0]+obsstats[0,0])) 1848 simobsstats[1,12]=(simstats[1,0]-obsstats[1,0])/(0.5*(simstats[1,0]+obsstats[1,0])) 1827 1849 1828 1850 # Statistics around sim values … … 1881 1903 1882 1904 # sim Statistics 1883 for ist in range(Nstsim):1884 1905 if not searchInlist(onewnc.variables,valvars[ivar][0] + 'stsim'): 1885 1906 newvar = onewnc.createVariable(valvars[ivar][0] + 'stsim', 'f', ('Nstsim', \ … … 1891 1912 # obs Statistics 1892 1913 if not searchInlist(onewnc.variables,valvars[ivar][1] + 'stobs'): 1893 newvar = onewnc.createVariable(valvars[ivar][1] + 'stobs', 'f', (' stats'), \1894 fill_value=fillValueF)1914 newvar = onewnc.createVariable(valvars[ivar][1] + 'stobs', 'f', ('Nstsim', \ 1915 'stats'), fill_value=fillValueF) 1895 1916 descvar = 'observed statisitcs: ' + valvars[ivar][1] 1896 1917 basicvardef(newvar, valvars[ivar][1] + 'stobs', descvar, \
Note: See TracChangeset
for help on using the changeset viewer.