Example #1
0
from dapper.tools.localization import nd_Id_localization

# Use small dt to "cope with" ocean sector blow up
# (due to spatially-constant infl)
OneYear = 0.05 * (24 / 6) * 365
t = dpr.Chronology(0.005,
                   dtObs=0.05,
                   T=110 * OneYear,
                   Tplot=Tplot,
                   BurnIn=10 * OneYear)

land_sites = np.arange(Nx // 2)
ocean_sites = np.arange(Nx // 2, Nx)

jj = land_sites
Obs = dpr.partial_Id_Obs(Nx, jj)
Obs['noise'] = 1
Obs['localizer'] = nd_Id_localization((Nx, ), (1, ), jj)

HMM = dpr.HiddenMarkovModel(Dyn,
                            Obs,
                            t,
                            X0,
                            LP=LPs(jj),
                            sectors={
                                'land': land_sites,
                                'ocean': ocean_sites
                            })

####################
# Suggested tuning
Example #2
0
from dapper.mods.DoublePendulum import step, x0, LP_setup, dstep_dx

t = dpr.Chronology(0.01, dkObs=100, T=30, BurnIn=10)

Dyn = {
    'M': len(x0),
    'model': step,
    'noise': 0,
    'linear': dstep_dx,
}

X0 = dpr.GaussRV(mu=x0, C=0.01**2)

jj = [0, 2]
Obs = dpr.partial_Id_Obs(len(x0), jj)
Obs['noise'] = 0.1**2

HMM = dpr.HiddenMarkovModel(Dyn, Obs, t, X0, LP=LP_setup(jj))

####################
# Suggested tuning
####################
# from dapper.mods.DoublePendulum.settings101 import HMM # Expct rmse.a:

# HMM.t.dkObs = anything
# xps += Climatology()                                 # 5
# xps += OptInterp()                                   # 2.5

# HMM.t.dkObs = 7 # <-- max dkObs for tolerable performance with Var3D
# xps += Var3D(xB=0.1)                                 # 0.81
Example #3
0
t = dpr.Chronology(dt=0.005, dtObs=0.05, T=4**3, BurnIn=6)


Dyn = {
    'M': LUV.M,
    'model': dpr.with_rk4(LUV.dxdt, autonom=True),
    'noise': 0,
    'linear': LUV.dstep_dx,
}

X0 = dpr.GaussRV(mu=LUV.x0, C=0.01)

R = 1.0
jj = np.arange(nU)
Obs = dpr.partial_Id_Obs(LUV.M, jj)
Obs['noise'] = R

other = {'name': utils.rel2mods(__file__)+'_full'}
HMM_full = dpr.HiddenMarkovModel(Dyn, Obs, t, X0, **other)


################
# Truncated
################

# Just change dt from 005 to 05
t = dpr.Chronology(dt=0.05, dtObs=0.05, T=4**3, BurnIn=6)

Dyn = {
    'M': nU,
Example #4
0
"""As in Anderson 2010 rank histogram filter"""

import numpy as np

import dapper as dpr
from dapper.mods.Lorenz63 import Tplot, dstep_dx, step, x0

t = dpr.Chronology(0.01, dkObs=12, KObs=1000, Tplot=Tplot, BurnIn=4 * Tplot)

Nx = len(x0)

Dyn = {'M': Nx, 'model': step, 'linear': dstep_dx, 'noise': 0}

X0 = dpr.GaussRV(C=2, mu=x0)

Obs = dpr.partial_Id_Obs(Nx, np.arange(Nx))
Obs['noise'] = 8.0

HMM = dpr.HiddenMarkovModel(Dyn, Obs, t, X0)

####################
# Suggested tuning
####################
# Compare with Anderson's figure 10.
# Benchmarks are fairly reliable (KObs=2000):
# from dapper.mods.Lorenz63.anderson2010rhf import HMM   # rmse.a
# xps += SL_EAKF(N=20,infl=1.01,rot=True,loc_rad=np.inf) # 0.87
# xps += EnKF_N (N=20,rot=True)                          # 0.87
# xps += RHF    (N=50,infl=1.10)                         # 1.28
# xps += RHF    (N=50,infl=0.95,rot=True)                # 0.94
# xps += RHF    (N=20,infl=0.95,rot=True)                # 1.07