def HMMs(stepper="Tay2", resolution="Low", R=1): """Define the various HMMs used.""" # Use small version of L96. Has 4 non-stable Lyapunov exponents. Nx = 10 # Time sequence # Grudzien'2020 uses the below chronology with Ko=25000, BurnIn=5000. t = modelling.Chronology(dt=0.005, dto=.1, T=30, Tplot=Tplot, BurnIn=10) if resolution == "High": t.dt = 0.001 elif stepper != "Tay2": t.dt = 0.01 # Dynamical operator Dyn = {'M': Nx, 'model': steppers(stepper)} # (Random) initial condition X0 = modelling.GaussRV(mu=x0(Nx), C=0.001) # Observation operator jj = range(Nx) # obs_inds Obs = modelling.partial_Id_Obs(Nx, jj) Obs['noise'] = R return modelling.HiddenMarkovModel(Dyn, Obs, t, X0)
"""Demonstrate the Lorenz-96 model.""" # For a deeper introduction, see # "DA-tutorials/T4 - Dynamical systems, chaos, Lorenz.ipynb" from matplotlib import pyplot as plt from numpy import eye import dapper as dpr from dapper.mods.Lorenz96 import step, x0 from dapper.tools.viz import amplitude_animation simulator = dpr.with_recursion(step, prog="Simulating") x0 = x0(40) E0 = x0 + 1e-3*eye(len(x0))[:3] dt = 0.05 xx = simulator(E0, k=500, t=0, dt=dt) ani = amplitude_animation(xx, dt=dt, interval=70) plt.show()
`bib.bocquet2011ensemble`, `bib.sakov2012iterative`, `bib.bocquet2015expanding`, `bib.bocquet2013joint`. """ import numpy as np import dapper.mods as modelling from dapper.mods.Lorenz96 import LPs, Tplot, dstep_dx, step, x0 from dapper.tools.localization import nd_Id_localization # Sakov uses K=300000, BurnIn=1000*0.05 tseq = modelling.Chronology(0.05, dko=1, Ko=1000, Tplot=Tplot, BurnIn=2*Tplot) Nx = 40 x0 = x0(Nx) Dyn = { 'M': Nx, 'model': step, 'linear': dstep_dx, 'noise': 0, } X0 = modelling.GaussRV(mu=x0, C=0.001) jj = np.arange(Nx) # obs_inds Obs = modelling.partial_Id_Obs(Nx, jj) Obs['noise'] = 1 Obs['localizer'] = nd_Id_localization((Nx,), (2,))
"""Demonstrate the Lorenz-96 model.""" # For a deeper introduction, see # "DA-tutorials/T4 - Dynamical systems, chaos, Lorenz.ipynb" from matplotlib import pyplot as plt from numpy import eye import dapper.mods as modelling from dapper.mods.Lorenz96 import step, x0 from dapper.tools.viz import amplitude_animation simulator = modelling.with_recursion(step, prog="Simulating") M = 40 N = 3 x0 = x0(M) E0 = x0 + 1e-3 * eye(M)[:N] dt = 0.05 xx = simulator(E0, k=500, t=0, dt=dt) ani = amplitude_animation(xx, dt=dt, interval=70) plt.show()
model.Force = 8.17 tseq = modelling.Chronology(0.01, dko=10, K=4000, Tplot=10, BurnIn=10) Nx = 1000 Dyn = { 'M': Nx, 'model': step, # It's not clear from the paper whether Q=0.5 or 0.25. # But I'm pretty sure it's applied each dto (not dt). 'noise': 0.25 / tseq.dto, # 'noise': 0.5 / t.dto, } X0 = modelling.GaussRV(mu=x0(Nx), C=0.001) jj = linspace_int(Nx, Nx // 4, periodic=True) Obs = modelling.partial_Id_Obs(Nx, jj) Obs['noise'] = 0.1**2 Obs['localizer'] = nd_Id_localization((Nx, ), (1, ), jj, periodic=True) HMM = modelling.HiddenMarkovModel(Dyn, Obs, tseq, X0) HMM.liveplotters = LPs(jj) # Pinheiro et al. use # - N = 30, but this is only really stated for their PF. # - loc-rad = 4, but don't state its definition, nor the exact tapering function. # - infl-factor 1.05, but I'm not sure if it's squared or not. #