Пример #1
0
"""Reproduce results from Fig. 2 of `bib.raanes2014ext`."""

import numpy as np

import dapper.mods as modelling
from dapper.mods.LA import Fmat, sinusoidal_sample
from dapper.mods.Lorenz96 import LPs
from dapper.tools.linalg import tsvd

# Burn-in allows damp*x and x+noise balance out
tseq = modelling.Chronology(dt=1, dkObs=5, T=500, BurnIn=60, Tplot=100)

Nx = 1000
Ny = 40

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

#################
#  Noise setup  #
#################
# 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
Пример #2
0
# ≈ (8 bytes/float)*(129² float/stat)*(7 stat/k) * K,
# it should be possible to run experiments of length (K) < 8000.
t = modelling.Chronology(dt=model.prms['dtout'], dko=1, T=1500, BurnIn=250)
# In my opinion the burn in should be 400.
# Sakov also used 10 repetitions.

X0 = modelling.RV(M=Dyn['M'], file=sample_filename)


############################
# Observation settings
############################

# This will look like satellite tracks when plotted in 2D
Ny = 300
jj = modelling.linspace_int(Dyn['M'], Ny)

# Want: random_offset(t1)==random_offset(t2) if t1==t2.
# Solutions: (1) use caching (ensure maxsize=inf) or (2) stream seeding.
# Either way, use a local random stream to avoid interfering with global stream
# (and e.g. ensure equal outcomes for 1st and 2nd run of the python session).
rstream = np.random.RandomState()
max_offset = jj[1]-jj[0]


def random_offset(t):
    rstream.seed(int(t/model.prms['dtout']*100))
    u = rstream.rand()
    return int(np.floor(max_offset * u))