Changeset 523 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 19, 2015, 6:43:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/validation_sim.py
r521 r523 1480 1480 # Number of different statistics according to the temporal coincidence 1481 1481 # 0: Exact time 1482 # 1: Simulation values between consecutive observed times 1483 Nstsim = 2 1484 1485 stdescsim = ['E', 'B'] 1486 Lstdescsim = ['exact time', 'between observational time-steps'] 1482 # 1: Simulation values closest to observed times 1483 # 2: Simulation values between consecutive observed times 1484 Nstsim = 3 1485 1486 stdescsim = ['E', 'C', 'B'] 1487 Lstdescsim = ['exact time', 'cloest time', 'between observational time-steps'] 1487 1488 1488 1489 ####### ####### … … 1772 1773 print main + ': found',Nexactt,'Temporal same values in simulation and observations' 1773 1774 1775 # Sim Closest times 1776 ## 1777 Nsimt = 0 1778 closesttvalues0 = [] 1779 closesttvalues0st = [] 1780 tsiminit = 0 1781 tsimend = 0 1782 1783 dtsim = simobstimes[1] - simobstimes[0] 1784 1785 for it in range(dimtsim): 1786 ot = 0 1787 for ito in range(ot,dimtobs-1): 1788 if np.abs(valdimobs['T'][ito] - simobstimes[it]) <= dtsim/2.: 1789 ot = ito 1790 tdist = simobstimes[it] - valdimobs['T'][ito] 1791 closesttvalues0.append([it, ito, simobstimes[it], valdimobs['T'][ito], \ 1792 tdist]) 1793 Nsimt = Nsimt + 1 1794 if tsiminit == 0: tsiminit=simobstimes[it] 1795 tsimend = simobstimes[it] 1796 1797 closesttvalues = np.array(closesttvalues0, dtype=np.float) 1798 1799 Nclosest = len(closesttvalues[:,0]) 1800 print main + ': found',Nclosest,'Simulation time-values closest to observations' 1801 1802 if Nclosest == 0: 1803 print warnmsg 1804 print main + ': no cclosest times found !!' 1805 print ' stopping it' 1806 quit(-1) 1807 1774 1808 # Sim Coincident times 1775 1809 ## 1776 sumsimval = 0.1777 sum2simval = 0.1778 1810 Nsimt = 0 1779 1811 coindtvalues0 = [] … … 1827 1859 newdim = onewnc.createDimension('stats',5) 1828 1860 newdim = onewnc.createDimension('tstats',6) 1829 newdim = onewnc.createDimension('Nstsim', 2)1861 newdim = onewnc.createDimension('Nstsim', 3) 1830 1862 1831 1863 # Variable dimensions … … 1840 1872 basicvardef(newvar, 'obstime', 'time observations for between values', obstunits) 1841 1873 set_attribute(newvar, 'calendar', 'standard') 1842 set_attribute(newvar, 'bounds', 'time_bnds') 1843 newvar[:] = coindtvalues[:,3] 1844 1845 newvar = onewnc.createVariable('betweentime','f8',('betweentime')) 1846 basicvardef(newvar, 'obstime', 'time simulations for between values', simtunits ) 1847 set_attribute(newvar, 'calendar', 'standard') 1848 set_attribute(newvar, 'bounds', 'time_bnds') 1849 newvar[:] = coindtvalues[:,2] 1874 newvar[:] = closesttvalues[:,3] 1850 1875 1851 1876 newvar = onewnc.createVariable('couple', 'c', ('couple','StrLength')) … … 1868 1893 basicvardef(newvar, 'ksimstatistics', 'kind of simulated statitics', '-') 1869 1894 writing_str_nc(newvar, Lstdescsim, StringLength) 1870 1871 1895 1872 1896 if obskind == 'trajectory': … … 1922 1946 oFillValue = None 1923 1947 1924 # Observed values temporally exact times 1925 Esimobsvalues, EsimobsSvalues, EsimobsTtvalues, trjsim = \ 1926 getting_ValidationValues(obskind, Nexactt, dims, trajpos, ovsim, ovobs, \ 1927 exacttvalues, oFillValue, Ngrid, 'instantaneous') 1928 1948 for kst in range(Nstsim): 1949 1950 if stdescsim[kst] == 'E': 1951 # Observed and simualted exact times 1952 simobsvalues, simobsSvalues, simobsTtvalues, trjsim = \ 1953 getting_ValidationValues(obskind, Nexactt, dims, trajpos, ovsim, \ 1954 ovobs, exacttvalues, oFillValue, Ngrid, 'instantaneous') 1955 1956 elif = stdescsim[kst] == 'C': 1957 # Simualted closest to Observed times 1958 simobsvalues, simobsSvalues, simobsTtvalues, trjsim = \ 1959 getting_ValidationValues(obskind, Nclosest, dims, trajpos, ovsim, \ 1960 ovobs, closesttvalues, oFillValue, Ngrid, 'instantaneous') 1961 1962 newvar = onewnc.createVariable('closesttime','f8',('obstime')) 1963 basicvardef(newvar, 'closesttime', 'time simulations closest to ' + \ 1964 'observed values', simtunits ) 1965 set_attribute(newvar, 'calendar', 'standard') 1966 newvar[:] = closesttvalues[:,2] 1967 1968 elif = stdescsim[kst] == 'B': 1929 1969 # Observed values temporally around coincident times 1930 simobsvalues, simobsSvalues, simobsTtvalues, trjsim = \ 1931 getting_ValidationValues(obskind, Ncoindt, dims, trajpos, ovsim, ovobs, \ 1932 coindtvalues, oFillValue, Ngrid, 'tbackwardSmean') 1970 simobsvalues, simobsSvalues, simobsTtvalues, trjsim = \ 1971 getting_ValidationValues(obskind, Ncoindt, dims, trajpos, ovsim, ovobs,\ 1972 coindtvalues, oFillValue, Ngrid, 'tbackwardSmean') 1973 1974 newvar = onewnc.createVariable('betweentime','f8',('betweentime')) 1975 basicvardef(newvar, 'obstime', 'time simulations for between values', \ 1976 simtunits ) 1977 set_attribute(newvar, 'calendar', 'standard') 1978 set_attribute(newvar, 'bounds', 'time_bnds') 1979 newvar[:] = simobsTtvalues[:,1] 1933 1980 1934 1981 # Re-arranging values... 1935 Earrayvals = np.array(Esimobsvalues)1936 1982 arrayvals = np.array(simobsvalues) 1937 1983 if len(valvars[ivar]) > 2: 1938 1984 const=np.float(valvars[ivar][3]) 1939 1985 if valvars[ivar][2] == 'sumc': 1940 EsimobsSvalues = EsimobsSvalues + const1941 Earrayvals[:,0] = Earrayvals[:,0] + const1942 1986 simobsSvalues = simobsSvalues + const 1943 1987 arrayvals[:,0] = arrayvals[:,0] + const 1944 1988 elif valvars[ivar][2] == 'subc': 1945 EsimobsSvalues = EsimobsSvalues - const1946 Earrayvals[:,0] = Earrayvals[:,0] - const1947 1989 simobsSvalues = simobsSvalues - const 1948 1990 arrayvals[:,0] = arrayvals[:,0] - const 1949 1991 elif valvars[ivar][2] == 'mulc': 1950 EsimobsSvalues = EsimobsSvalues * const1951 Earrayvals[:,0] = Earrayvals[:,0] * const1952 1992 simobsSvalues = simobsSvalues * const 1953 1993 arrayvals[:,0] = arrayvals[:,0] * const 1954 1994 elif valvars[ivar][2] == 'divc': 1955 EsimobsSvalues = EsimobsSvalues / const1956 Earrayvals[:,0] = Earrayvals[:,0] / const1957 1995 simobsSvalues = simobsSvalues / const 1958 1996 arrayvals[:,0] = arrayvals[:,0] / const
Note: See TracChangeset
for help on using the changeset viewer.