biasda 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- biasda/__init__.py +160 -0
- biasda/base.py +727 -0
- biasda/bias/__init__.py +25 -0
- biasda/bias/bias.py +486 -0
- biasda/bias/innovation.py +592 -0
- biasda/bias/polynomial.py +565 -0
- biasda/inflation.py +175 -0
- biasda/localization.py +115 -0
- biasda/observations.py +569 -0
- biasda/sequential/__init__.py +78 -0
- biasda/sequential/ensemble.py +1643 -0
- biasda/sequential/formulations.py +224 -0
- biasda/sequential/kalman.py +457 -0
- biasda/sequential/nudging.py +207 -0
- biasda/sequential/particle.py +407 -0
- biasda/sequential/smoothers.py +478 -0
- biasda/utils.py +271 -0
- biasda/variational/__init__.py +31 -0
- biasda/variational/envar.py +363 -0
- biasda/variational/estimator.py +523 -0
- biasda/variational/var.py +540 -0
- biasda-0.1.1.dist-info/METADATA +24 -0
- biasda-0.1.1.dist-info/RECORD +26 -0
- biasda-0.1.1.dist-info/WHEEL +5 -0
- biasda-0.1.1.dist-info/licenses/LICENSE +21 -0
- biasda-0.1.1.dist-info/top_level.txt +1 -0
biasda/__init__.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
r"""biasda — data assimilation for any forecast model.
|
|
2
|
+
|
|
3
|
+
Taxonomy
|
|
4
|
+
--------
|
|
5
|
+
From the top down, an estimator is classified by **what it estimates** and by
|
|
6
|
+
**how it assimilates**.
|
|
7
|
+
|
|
8
|
+
What is estimated (a configuration of the augmented state, not a class tree):
|
|
9
|
+
|
|
10
|
+
- state ($\vect{\phi}$) — the default;
|
|
11
|
+
- state + parameters ($\vect{\alpha}$) — name the parameters in
|
|
12
|
+
``est_alpha``; they are appended to the state and updated by the same analysis;
|
|
13
|
+
- state + parameters + bias ($\vect{b}$) — attach a `Bias` estimator
|
|
14
|
+
(`biasda.bias`) to any estimator: the analysis then corrects the forecast
|
|
15
|
+
observables with the current bias estimate (the un-regularized,
|
|
16
|
+
$\gamma = 0$ bias-aware update). Like localization and inflation, this is
|
|
17
|
+
a configuration, not a class per filter; the $\gamma > 0$ bias-norm
|
|
18
|
+
regularization is a configuration too (``bias_regularization`` on the
|
|
19
|
+
estimators, ``gamma`` on the variational functions), and ``bias_estimation``
|
|
20
|
+
selects how the analysis updates the bias.
|
|
21
|
+
|
|
22
|
+
How it assimilates, in three families that derive from `Estimator` (the root, which holds the
|
|
23
|
+
configuration and the bias machinery they share):
|
|
24
|
+
|
|
25
|
+
- **sequential** (`SequentialEstimator`, `biasda.sequential`): filters in a forecast/analysis cycle,
|
|
26
|
+
- Kalman-type, deterministic: `KalmanFilter` (``type`` = linear, extended or unscented;
|
|
27
|
+
``parameter_estimation`` = None, joint or dual);
|
|
28
|
+
- continuous: `Nudging` (Newtonian relaxation; the optimal gain is the
|
|
29
|
+
Kalman gain);
|
|
30
|
+
- Kalman-type, ensemble: `EnsembleFilter` (``type`` = stochastic, deterministic or
|
|
31
|
+
square-root; ``parameter_estimation`` = None, joint or dual; ``localization``);
|
|
32
|
+
- particle: `ParticleFilter` (``type`` = classic, i.e., bootstrap resampling with
|
|
33
|
+
optional kernel rejuvenation, or flow, i.e., the exact Daum-Huang Gaussian flow);
|
|
34
|
+
- **smoothers** (`Smoother`, ``type`` = rts or ks): around an `EnsembleFilter` or a `ParticleFilter`,
|
|
35
|
+
the ensemble RTS smoother or the EnKS; around a `KalmanFilter`, the Rauch-Tung-Striebel smoother;
|
|
36
|
+
- **variational** (`VariationalEstimator`, `biasda.variational`): `Var3D`, `Var4D` and `EnVar`, batch
|
|
37
|
+
analyses of a record (`assimilate`), one minimization per window (cycled 3D-Var by default; 4D-Var and
|
|
38
|
+
4DEnVar need a window); `Var4D` with ``type`` = the cost gradient (auto, finite-difference, linear,
|
|
39
|
+
jacobian, user), and `EnVar` with ``type`` = 3d or 4d (3DEnVar, 4DEnVar: the ensemble subspace, no
|
|
40
|
+
adjoint, iterable on chaotic windows);
|
|
41
|
+
the cost functions are also plain functions on arrays, `var3d`, `var4d` and `en4dvar`.
|
|
42
|
+
A bias covariance estimates a bias constant over the window in the control vector (the
|
|
43
|
+
weak-constraint formulation).
|
|
44
|
+
|
|
45
|
+
Auxiliaries: `biasda.inflation` (multiplicative, adaptive and innovation covariance
|
|
46
|
+
inflation), `biasda.localization` (Gaspari-Cohn covariance localization),
|
|
47
|
+
`biasda.observations` (twin-experiment truths and observations).
|
|
48
|
+
|
|
49
|
+
Forecast models are duck-typed: any object satisfying the protocol documented in
|
|
50
|
+
`biasda.base` works (``dynamodels.Model`` is the reference implementation), and
|
|
51
|
+
the deterministic estimators also run from a matrix ``F`` or a one-step map ``f``.
|
|
52
|
+
|
|
53
|
+
Reference
|
|
54
|
+
---------
|
|
55
|
+
Evensen, Vossepoel & van Leeuwen (2022). *Data Assimilation Fundamentals: A
|
|
56
|
+
Unified Formulation of the State and Parameter Estimation Problem.* Springer
|
|
57
|
+
(open access). The implementations are validated against the linear-Gaussian
|
|
58
|
+
identities of the book (see ``tests/``).
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
from .base import Estimator, SequentialEstimator
|
|
62
|
+
from .bias import (
|
|
63
|
+
Bias,
|
|
64
|
+
ConstantBias,
|
|
65
|
+
DriftLinearBias,
|
|
66
|
+
ESNBias,
|
|
67
|
+
InnovationBias,
|
|
68
|
+
LinearBias,
|
|
69
|
+
NoBias,
|
|
70
|
+
PolynomialBias,
|
|
71
|
+
QuadraticBias,
|
|
72
|
+
TimeLinearBias,
|
|
73
|
+
)
|
|
74
|
+
from .inflation import adaptive_inflation_factor, innovation_inflation_factor, multiplicative_inflation
|
|
75
|
+
from .localization import distance_matrix, gaspari_cohn, localization_matrix
|
|
76
|
+
from .observations import (
|
|
77
|
+
Observations,
|
|
78
|
+
measured_idx,
|
|
79
|
+
observation_covariance,
|
|
80
|
+
std_fraction_covariance,
|
|
81
|
+
variance_fraction_covariance,
|
|
82
|
+
)
|
|
83
|
+
from .sequential import (
|
|
84
|
+
DualEnKF,
|
|
85
|
+
EnKF,
|
|
86
|
+
EnKS,
|
|
87
|
+
EnRTS,
|
|
88
|
+
EnsembleEstimator,
|
|
89
|
+
EnsembleFilter,
|
|
90
|
+
EnSRKF,
|
|
91
|
+
ExtendedKalmanFilter,
|
|
92
|
+
KalmanFilter,
|
|
93
|
+
KalmanSmoother,
|
|
94
|
+
LocalizedEnKF,
|
|
95
|
+
Nudging,
|
|
96
|
+
ParticleFilter,
|
|
97
|
+
ParticleFlowFilter,
|
|
98
|
+
Smoother,
|
|
99
|
+
UnscentedKalmanFilter,
|
|
100
|
+
enks_smooth,
|
|
101
|
+
enrts_smooth,
|
|
102
|
+
rEnKF,
|
|
103
|
+
rts_smooth,
|
|
104
|
+
)
|
|
105
|
+
from .variational import EnVar, Var3D, Var4D, VariationalEstimator, en4dvar, var3d, var4d
|
|
106
|
+
|
|
107
|
+
__version__ = "0.1.1"
|
|
108
|
+
|
|
109
|
+
__all__ = [
|
|
110
|
+
'Bias',
|
|
111
|
+
'ConstantBias',
|
|
112
|
+
'DriftLinearBias',
|
|
113
|
+
'ESNBias',
|
|
114
|
+
'InnovationBias',
|
|
115
|
+
'DualEnKF',
|
|
116
|
+
'EnKF',
|
|
117
|
+
'EnKS',
|
|
118
|
+
'EnRTS',
|
|
119
|
+
'EnSRKF',
|
|
120
|
+
'EnsembleEstimator',
|
|
121
|
+
'EnsembleFilter',
|
|
122
|
+
'Estimator',
|
|
123
|
+
'ExtendedKalmanFilter',
|
|
124
|
+
'KalmanFilter',
|
|
125
|
+
'KalmanSmoother',
|
|
126
|
+
'LinearBias',
|
|
127
|
+
'LocalizedEnKF',
|
|
128
|
+
'Nudging',
|
|
129
|
+
'NoBias',
|
|
130
|
+
'PolynomialBias',
|
|
131
|
+
'Observations',
|
|
132
|
+
'ParticleFilter',
|
|
133
|
+
'ParticleFlowFilter',
|
|
134
|
+
'QuadraticBias',
|
|
135
|
+
'SequentialEstimator',
|
|
136
|
+
'Smoother',
|
|
137
|
+
'TimeLinearBias',
|
|
138
|
+
'UnscentedKalmanFilter',
|
|
139
|
+
'adaptive_inflation_factor',
|
|
140
|
+
'innovation_inflation_factor',
|
|
141
|
+
'distance_matrix',
|
|
142
|
+
'enks_smooth',
|
|
143
|
+
'enrts_smooth',
|
|
144
|
+
'rts_smooth',
|
|
145
|
+
'gaspari_cohn',
|
|
146
|
+
'localization_matrix',
|
|
147
|
+
'measured_idx',
|
|
148
|
+
'multiplicative_inflation',
|
|
149
|
+
'observation_covariance',
|
|
150
|
+
'std_fraction_covariance',
|
|
151
|
+
'variance_fraction_covariance',
|
|
152
|
+
'rEnKF',
|
|
153
|
+
'EnVar',
|
|
154
|
+
'Var3D',
|
|
155
|
+
'Var4D',
|
|
156
|
+
'VariationalEstimator',
|
|
157
|
+
'en4dvar',
|
|
158
|
+
'var3d',
|
|
159
|
+
'var4d',
|
|
160
|
+
]
|