Skip to content

da_methods⚓︎

Contains the data assimilation methods included with DAPPER.

Also see this section on DA Methods for an overview of the methods included with DAPPER.

Defining your own method⚓︎

Follow the example of one of the methods within one of the sub-directories/packages. The simplest example is perhaps da_methods.ensemble.EnKF.

General advice for programming/debugging scientific experiments⚓︎

  • Start with something simple. This helps make sure the basics of the experiment are reasonable. For example, start with

    • a pre-existing example,
    • something you are able to reproduce,
    • a small/simple model.

      • Set the observation error to be small.
      • Observe everything.
      • Don't include model error and/or noise to begin with.
  • Additionally, test a simple/baseline method to begin with. When including an ensemble method, start with using a large ensemble, and introduce localisation later.

  • Take incremental steps towards your ultimate experiment setup. Validate each incremental setup with prints/plots. If results change, make sure you understand why.

  • Use short experiment duration. You probably don't need statistical significance while debugging.

Modules:

Name Description
baseline

Unsophisticated" but robust (widely applicable) DA methods.

ensemble

The EnKF and other ensemble-based methods.

extended

The extended KF (EKF) and the (Rauch-Tung-Striebel) smoother.

other

More experimental or esoteric DA methods.

particle

Weight- & resampling-based DA methods.

variational

Variational DA methods (iEnKS, 4D-Var, etc).

da_method ⚓︎

Base class for all DA methods.

Objects hereof are often called xp, short for "experiment".

Inheriting from this class makes the subclass a dataclass (auto-generating __init__, __repr__, __eq__) and also endows it .stats, .avrgs, and an enhanced .assimilate().

Example::

class MyMethod(da_method):
    param: float = 1.0

    def assimilate(self, HMM, xx, yy):
        ...

To share default parameters across methods, define a @dataclass(kw_only=True) base and inherit from both::

@dataclass(kw_only=True)
class ens_defaults:
    infl: float = 1.0
    rot:  bool  = False

class EnKF(da_method, ens_defaults):
    N: int

    def assimilate(self, HMM, xx, yy): ...

avrgs ⚓︎

stats.Avrgs object of time-averaged statistics.

Populated by stats.average_in_time() from stats.

stats ⚓︎

stats.Stats object of time series recorded during assimilate().

assimilate(HMM, xx, yy, desc=None, fail_gently=False, **stat_kwargs) ⚓︎

Wraps subclasses .assimilate() method to add the extra parameters below,

as well as initialise self.stats and measure wall-clock time.

Parameters:

Name Type Description Default
HMM

The mods.HiddenMarkovModel defining the twin experiment.

required
xx

True states, shape (K+1, Nx).

required
yy

Observations, shape (Ko+1, Ny).

required
desc str | None

Label for the progress bar. Defaults to the class name.

None
fail_gently bool | str

If truthy, catch exceptions and print a cropped traceback instead of re-raising. Pass "silent" or "quiet" to suppress even that.

False
**stat_kwargs

Forwarded to stats.Stats.__init__ (e.g. liveplots=True, store_i=False).

{}