Пример #1
0
def test_1():
    d = np.array([.3, 1, 2, 1])
    C = dpr.CovMat(d)
    assert np.allclose(np.diag(C.full), d)
Пример #2
0
def test_3():
    """Make sure truncation and sorting works."""
    d = np.array([1, 0, 1])
    C = dpr.CovMat(d)
    assert np.allclose(np.diag(C.full), d)
Пример #3
0
try:
    # Load pre-generated
    L = np.load(sample_filename)['Left']
except FileNotFoundError:
    # First-time use
    print('Did not find sample file', sample_filename,
          'for experiment initialization. Generating...')
    NQ = 20000  # Must have NQ > (2*wnumQ+1)
    A = sinusoidal_sample(Nx, wnumQ, NQ)
    A = 1 / 10 * center(A)[0] / np.sqrt(NQ)
    Q = A.T @ A
    U, s, _ = tsvd(Q)
    L = U * np.sqrt(s)
    np.savez(sample_filename, Left=L)

X0 = dpr.GaussRV(C=dpr.CovMat(np.sqrt(5) * L, 'Left'))

###################
#  Forward model  #
###################
damp = 0.98
Fm = Fmat(Nx, -1, 1, tseq.dt)


def step(x, t, dt):
    assert dt == tseq.dt
    return x @ Fm.T


Dyn = {
    'M': Nx,
Пример #4
0
def test_2():
    """Special case: np.all(d==d[0])"""
    d = np.array([1, 1, 1])
    C = dpr.CovMat(d)
    assert np.allclose(np.diag(C.full), d)
Пример #5
0
"""Reproduce results from Fig 11 of
M. Bocquet and P. Sakov (2012): 'Combining inflation-free and
iterative ensemble Kalman filters for strongly nonlinear systems'"""

import numpy as np

import dapper as dpr
from dapper.mods.Lorenz63.sakov2012 import HMM

# The only diff to sakov2012 is R:
# bocquet2012 uses 1 and 8, sakov2012 uses 2 (and 8)

HMM.Obs.noise.C = dpr.CovMat(np.eye(3))

HMM.name = HMM.name.replace("sakov", "bocquet")

####################
# Suggested tuning
####################
# from dapper.mods.Lorenz63.bocquet2012 import HMM         # rmse.a:
# HMM.t.dkObs = 25
# xps += iEnKS('Sqrt', N=10,infl=1.02,rot=True)            # 0.22
# xps += iEnKS('Sqrt', N=3, infl=1.04)                     # 0.23
# xps += iEnKS('Sqrt', N=3, xN=1.0)                        # 0.22
#
# HMM.t.dkObs = 5
# xps += iEnKS('Sqrt', N=10,infl=1.02,rot=True)            # 0.13
# xps += iEnKS('Sqrt', N=3, infl=1.02)                     # 0.13
# xps += iEnKS('Sqrt', N=3, xN=1.0)                        # 0.15
# xps += iEnKS('Sqrt', N=3, xN=2.0)                        # 0.14
#