Esempio n. 1
0
"""Estimtate the Lyapunov spectrum using an ensemble of perturbations."""

# An old version using explicit TLMs can be found in EmblAUS/Lyap_L{63,96}.

import numpy as np
import scipy.linalg as sla
from matplotlib import pyplot as plt
from mpl_tools.fig_layout import freshfig
from numpy.random import randn

import dapper.tools.series as series
import dapper.tools.viz as viz
from dapper.mods import set_seed, with_recursion, with_rk4
from dapper.tools.progressbar import progbar

set_seed(3000)

########################
# Model selection
########################
mod = "L05"

# Lyapunov exponents: [ 1.05  0.   -0.01 -1.05]
if mod == "DP":
    from dapper.mods.DoublePendulum import step, x0
    T   = 5e2
    dt  = 0.005
    eps = 0.0002
    Nx  = len(x0)
    N   = Nx
Esempio n. 2
0
"""Prettier, static illustration of Lorenz two-speed/scale/layer model."""
# Sorry for the mess.

if __name__ == "__main__":
    import matplotlib as mpl
    import numpy as np
    from matplotlib import pyplot as plt

    import dapper.mods as modelling
    from dapper.mods.LorenzUV.lorenz96 import LUV

    # Setup
    sd0 = modelling.set_seed(4)
    # from dapper.mods.LorenzUV.wilks05 import LUV
    nU, J = LUV.nU, LUV.J

    dt = 0.005
    t0 = np.nan
    K  = int(10/dt)

    step_1 = modelling.with_rk4(LUV.dxdt, autonom=True)
    step_K = modelling.with_recursion(step_1, prog=1)

    x0 = 0.01*np.random.randn(LUV.M)
    x0 = step_K(x0, int(2/dt), t0, dt)[-1]  # BurnIn
    xx = step_K(x0, K, t0, dt)

    # Grab parts of state vector
    ii = np.arange(nU+1)
    jj = np.arange(nU*J+1)
    circU = np.mod(ii, nU)
Esempio n. 3
0
    # mpl.rcParams['toolbar'] = 'None'
    ###########################
    # Setup
    ###########################
    PRMS = 'Lorenz'
    if PRMS == 'Wilks':
        from dapper.mods.LorenzUV.wilks05 import LUV
    else:
        from dapper.mods.LorenzUV.lorenz96 import LUV
    nU = LUV.nU

    K = 400
    dt = 0.005
    t0 = np.nan

    modelling.set_seed(30)  # 3 5 7 13 15 30
    x0 = np.random.randn(LUV.M)

    true_step = with_rk4(LUV.dxdt, autonom=True)
    model_step = with_rk4(LUV.dxdt_trunc, autonom=True)
    true_K = with_recursion(true_step, prog=1)

    ###########################
    # Compute truth trajectory
    ###########################
    x0 = true_K(x0, int(2 / dt), t0, dt)[-1]  # BurnIn
    xx = true_K(x0, K, t0, dt)

    ###########################
    # Compute unresovled scales
    ###########################