def test_L63(): from dapper.mods.Lorenz63.sakov2012 import HMM xps = dpr.xpList() xps += dpr.EnKF("Sqrt", N=10, infl=1.02, rot=True) xps += dpr.PartFilt(N=20, reg=2.4, NER=0.3) xps += dpr.OptInterp() # xps += dpr.iEnKS('Sqrt', N=10, infl=1.02,rot=True) HMM.t.BurnIn = HMM.t.dtObs HMM.t.KObs = 1 xps.launch( HMM, free=False, statkeys=True, liveplots=None, store_u=False, fail_gently=False, save_as=False, ) print(xps.tabulate_avrgs(["rmse.a"])) spell_out(HMM) spell_out(xps[-1]) spell_out(xps[-1].stats) spell_out(xps[-1].avrgs) assert True # An assertion for pytest to count return HMM, xps # Return useful stuff
def test_L63(): from dapper.mods.Lorenz63.sakov2012 import HMM xps = dpr.xpList() xps += dpr.EnKF('Sqrt', N=10, infl=1.02, rot=True) xps += dpr.PartFilt(N=20, reg=2.4, NER=0.3) xps += dpr.OptInterp() # xps += dpr.iEnKS('Sqrt', N=10, infl=1.02,rot=True) HMM.t.BurnIn = HMM.t.dtObs HMM.t.KObs = 1 xps.launch(HMM, free=False, liveplots="all", store_u=False, fail_gently=False) for xp in xps: xp.stats.replay("all") xp.stats.replay(t2=1) xp.stats.replay(t2=0.0) xp.stats.replay(t2=0.3) xp.stats.replay(t2=0.8) xp.stats.replay(t2=0.8, t1=0.2) xp.stats.replay(t2=np.inf) xp.stats.replay(t2=np.inf, speed=1) xp.stats.replay(t2=np.inf, pause_a=0, pause_f=0) assert True # An assertion for pytest to count return HMM, xps # Return useful stuff
def test_L96(): xps = dpr.xpList() from dapper.mods.Lorenz96.sakov2008 import HMM xps += dpr.EnKF('PertObs', N=40, infl=1.06) xps += dpr.EnKF('Serial', N=28, infl=1.02, rot=True) xps += dpr.OptInterp() xps += dpr.Var3D(xB=0.02) xps += dpr.ExtKF(infl=10) xps += dpr.LETKF(N=6, rot=True, infl=1.05, loc_rad=4, taper='Step') # from dapper.mods.Lorenz96.bocquet2015loc import HMM # xps += dpr.EnKF_N( N=24, rot=True ,infl=1.01) # xps += dpr.PartFilt(N=3000,NER=0.20,reg=1.2) # xps += dpr.PFxN( N=1000,xN=100, NER=0.9,Qs=0.6) # HMM.t.BurnIn = 10*HMM.t.dtObs # HMM.t.KObs = 30 HMM.t.BurnIn = HMM.t.dtObs HMM.t.KObs = 2 xps.launch(HMM, free=False, liveplots="all", store_u=False, fail_gently=False, save_as=False) for xp in xps: xp.stats.replay("all") xp.stats.replay(t2=1) xp.stats.replay(t2=0.0) xp.stats.replay(t2=0.3) xp.stats.replay(t2=0.8) xp.stats.replay(t2=0.8, t1=0.2) xp.stats.replay(t2=np.inf) xp.stats.replay(t2=np.inf, speed=1) xp.stats.replay(t2=np.inf, pause_a=0, pause_f=0) assert True # An assertion for pytest to count return HMM, xps # Return useful stuff
def test_L96(): xps = dpr.xpList() from dapper.mods.Lorenz96.sakov2008 import HMM xps += dpr.EnKF("PertObs", N=40, infl=1.06) xps += dpr.EnKF("Serial", N=28, infl=1.02, rot=True) xps += dpr.OptInterp() xps += dpr.Var3D(xB=0.02) xps += dpr.ExtKF(infl=10) xps += dpr.LETKF(N=6, rot=True, infl=1.05, loc_rad=4, taper="Step") # from dapper.mods.Lorenz96.bocquet2015loc import HMM # xps += dpr.EnKF_N( N=24, rot=True ,infl=1.01) # xps += dpr.PartFilt(N=3000,NER=0.20,reg=1.2) # xps += dpr.PFxN( N=1000,xN=100, NER=0.9,Qs=0.6) # HMM.t.BurnIn = 10*HMM.t.dtObs # HMM.t.KObs = 30 HMM.t.BurnIn = HMM.t.dtObs HMM.t.KObs = 2 xps.launch( HMM, free=False, statkeys=True, liveplots=None, store_u=False, fail_gently=False, save_as=False, ) print(xps.tabulate_avrgs(["rmse.a"])) spell_out(HMM) spell_out(xps[-1]) spell_out(xps[-1].stats) spell_out(xps[-1].avrgs) assert True # An assertion for pytest to count return HMM, xps # Return useful stuff
import dapper as dpr dpr.set_seed(3000) ############################## # DA method configurations ############################## xps = dpr.xpList() from dapper.mods.Lorenz63.sakov2012 import HMM # Expected rmse.a: xps += dpr.Climatology() # 7.6 xps += dpr.OptInterp() # 1.25 xps += dpr.Var3D(xB=0.1) # 1.03 xps += dpr.ExtKF(infl=90) # 0.87 xps += dpr.EnKF('Sqrt', N=3, infl=1.30) # 0.82 xps += dpr.EnKF('Sqrt', N=10, infl=1.02, rot=True) # 0.63 xps += dpr.EnKF('PertObs', N=500, infl=0.95, rot=False) # 0.56 xps += dpr.EnKF_N(N=10, rot=True) # 0.54 xps += dpr.iEnKS('Sqrt', N=10, infl=1.02, rot=True) # 0.31 xps += dpr.PartFilt(N=100, reg=2.4, NER=0.3) # 0.38 xps += dpr.PartFilt(N=800, reg=0.9, NER=0.2) # 0.28 # xps += dpr.PartFilt( N=4000, reg=0.7 , NER=0.05) # 0.27 # xps += dpr.PFxN(xN=1000, N=30 , Qs=2 , NER=0.2) # 0.56 # from dapper.mods.Lorenz96.sakov2008 import HMM # Expected rmse.a: # xps += dpr.Climatology() # 3.6 # xps += dpr.OptInterp() # 0.95 # xps += dpr.Var3D(xB=0.02) # 0.41 # xps += dpr.ExtKF(infl=6) # 0.24 # xps += dpr.EnKF('PertObs', N=40, infl=1.06) # 0.22
# L63 ############################## from dapper.mods.Lorenz63.sakov2012 import HMM HMM.t.BurnIn = 0 HMM.t.KObs = 10 dpr.set_seed(3000) # xps xps = dpr.xpList() xps += dpr.Climatology() xps += dpr.OptInterp() xps += dpr.Var3D(xB=0.1) xps += dpr.ExtKF(infl=90) xps += dpr.EnKF("Sqrt", N=3, infl=1.30) xps += dpr.EnKF("Sqrt", N=10, infl=1.02, rot=True) xps += dpr.EnKF("PertObs", N=500, infl=0.95, rot=False) xps += dpr.EnKF_N(N=10, rot=True) xps += dpr.iEnKS("Sqrt", N=10, infl=1.02, rot=True) xps += dpr.PartFilt(N=100, reg=2.4, NER=0.3) xps += dpr.PartFilt(N=800, reg=0.9, NER=0.2) xps += dpr.PartFilt(N=4000, reg=0.7, NER=0.05) xps += dpr.PFxN(xN=1000, N=30, Qs=2, NER=0.2) # Run xps.launch(HMM, store_u=True) table = xps.tabulate_avrgs(statkeys, decimals=4) old = """ da_method infl upd_a N rot xN reg NER | err.rms.a 1σ err.rms.f 1σ err.rms.u 1σ
"""Illustrate usage of DAPPER to (interactively) run a 'twin experiment'.""" import dapper as dpr # Load experiment setup: the hidden Markov model (HMM) from dapper.mods.Lorenz63.sakov2012 import HMM # Generate the same random numbers every time dpr.set_seed(3000) HMM.t.T = 30 # shorten experiment # Simulate synthetic truth (xx) and noisy obs (yy) xx, yy = HMM.simulate() # Specify a DA method configuration ("xp" for "experiment") xp = dpr.EnKF('Sqrt', N=10, infl=1.02, rot=True) # xp = dpr.Var3D() # xp = dpr.PartFilt(N=100,reg=2.4,NER=0.3) # Assimilate yy, knowing the HMM; xx is used to assess the performance xp.assimilate(HMM, xx, yy, liveplots=True) # Average the time series of various statistics xp.stats.average_in_time() # Print some averages print(xp.avrgs.tabulate(['rmse.a', 'rmv.a'])) # Replay liveplotters xp.stats.replay(speed=100)
############################## # Preamble ############################## import numpy as np import dapper as dpr from dapper.dict_tools import deep_getattr from dapper.mods.LA.small import HMM HMM.t.BurnIn = 0 HMM.t.KObs = 10 xps = dpr.xpList(unique=True) # yapf: disable xps += dpr.EnKF('Sqrt', N=20) xps += dpr.EnKF('PertObs', N=20) xps += dpr.EnKF('DEnKF', N=20) for Lag in [0, 1, 3]: xps += dpr.EnKS('Sqrt', N=20, Lag=Lag) xps += dpr.EnKS('PertObs', N=20, Lag=Lag) xps += dpr.EnKS('DEnKF', N=20, Lag=Lag) for nIter in [1, 4]: for MDA in [False, True]: xps += dpr.iEnKS('Sqrt', N=20, Lag=Lag, nIter=nIter, MDA=MDA) xps += dpr.iEnKS('PertObs', N=20, Lag=Lag, nIter=nIter, MDA=MDA) xps += dpr.iEnKS('Order1', N=20, Lag=Lag, nIter=nIter, MDA=MDA) # yapf: enable for xp in xps: xp.seed = 3000