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(*default_dataclasses)
⚓︎
Turn a dataclass-style class into a DA method for DAPPER (xp
).
This decorator applies to classes that define DA methods.
An instances of the resulting class is referred to (in DAPPER)
as an xp
(short for experiment).
The decorated classes are defined like a dataclass
,
but are decorated by @da_method()
instead of @dataclass
.
Note
The classes must define a method called assimilate
.
This method gets slightly enhanced by this wrapper which provides:
- Initialisation of the
Stats
object, accessible byself.stats
. fail_gently
functionality.- Duration timing
- Progressbar naming magic.
Examples:
>>> @da_method()
... class Sleeper():
... "Do nothing."
... seconds : int = 10
... success : bool = True
... def assimilate(self, *args, **kwargs):
... for k in range(self.seconds):
... time.sleep(1)
... if not self.success:
... raise RuntimeError("Sleep over. Failing as intended.")
Internally, da_method
is just like dataclass
,
except that adds an outer layer
(hence the empty parantheses in the above)
which enables defining default parameters which can be inherited,
similar to subclassing.
>>> @da_method(ens_defaults)
... class EnKF:
... N : int
... upd_a : str = "Sqrt"
...
... def assimilate(self, HMM, xx, yy):
... ...
Note
Apart from what's listed in the above Note
, there is nothing special to the
resulting xp
. That is, just like any Python object, it can serve as a data
container, and you can write any number of attributes to it (at creation-time,
or later). For example, you can set attributes that are not used by the
assimilate
method, but are instead used to customize other aspects of the
experiments (see xp_launch.run_experiment
).