Пример #1
0
def step(x, t, dt):
    assert dt == tseq.dt
    return x @ Fm.T


Dyn = {
    'M': Nx,
    'model': step,
    'linear': lambda x, t, dt: Fm,
    'noise': 0,
}

# In the animation, it can sometimes/somewhat occur
# that the truth is outside 3*sigma !!!
# Yet this is not so implausible because sinusoidal_sample()
# yields (multivariate) uniform (random numbers) -- not Gaussian.
wnum = 25
a = np.sqrt(5) / 10
X0 = modelling.RV(M=Nx, func=lambda N: a * sinusoidal_sample(Nx, wnum, N))

Obs = modelling.partial_Id_Obs(Nx, jj)
Obs['noise'] = 0.01

HMM = modelling.HiddenMarkovModel(Dyn, Obs, tseq, X0, LP=LPs(jj))

####################
# Suggested tuning
####################
# xp = EnKF('PertObs',N=100,infl=1.02)
Пример #2
0
# Instead of sampling model noise from sinusoidal_sample(),
# we will replicate it below by a covariance matrix approach.
# But, for strict equivalence, one would have to use
# uniform (i.e. not Gaussian) random numbers.
wnumQ = 25
sample_filename = modelling.rc.dirs.samples / ('LA_Q_wnum%d.npz' % wnumQ)

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 * (A - A.mean(0)) / np.sqrt(NQ)
    Q = A.T @ A
    U, s, _ = tsvd(Q)
    L = U * np.sqrt(s)
    np.savez(sample_filename, Left=L)

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

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

Пример #3
0
# WITHOUT explicit matrix (assumes dt == dx/c):
# step = lambda x,t,dt: np.roll(x,1,axis=x.ndim-1)
# WITH:
Fm = Fmat(Nx, c=-1, dx=1, dt=tseq.dt)


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


Dyn = {'M': Nx, 'model': step, 'linear': lambda x, t, dt: Fm, 'noise': 0}

# In the animation, it can sometimes/somewhat occur
# that the truth is outside 3*sigma !!!
# Yet this is not so implausible because sinusoidal_sample()
# yields (multivariate) uniform (random numbers) -- not Gaussian.
wnum = 25
a = np.sqrt(5) / 10
X0 = dpr.RV(M=Nx, func=lambda N: a * sinusoidal_sample(Nx, wnum, N))

Obs = dpr.partial_Id_Obs(Nx, jj)
Obs['noise'] = 0.01

HMM = dpr.HiddenMarkovModel(Dyn, Obs, tseq, X0, LP=LPs(jj))

####################
# Suggested tuning
####################
# xp = EnKF('PertObs',N=100,infl=1.02)