biasda 0.1.1__tar.gz
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-0.1.1/LICENSE +21 -0
- biasda-0.1.1/MANIFEST.in +4 -0
- biasda-0.1.1/PKG-INFO +24 -0
- biasda-0.1.1/biasda/__init__.py +160 -0
- biasda-0.1.1/biasda/base.py +727 -0
- biasda-0.1.1/biasda/bias/__init__.py +25 -0
- biasda-0.1.1/biasda/bias/bias.py +486 -0
- biasda-0.1.1/biasda/bias/innovation.py +592 -0
- biasda-0.1.1/biasda/bias/polynomial.py +565 -0
- biasda-0.1.1/biasda/inflation.py +175 -0
- biasda-0.1.1/biasda/localization.py +115 -0
- biasda-0.1.1/biasda/observations.py +569 -0
- biasda-0.1.1/biasda/sequential/__init__.py +78 -0
- biasda-0.1.1/biasda/sequential/ensemble.py +1643 -0
- biasda-0.1.1/biasda/sequential/formulations.py +224 -0
- biasda-0.1.1/biasda/sequential/kalman.py +457 -0
- biasda-0.1.1/biasda/sequential/nudging.py +207 -0
- biasda-0.1.1/biasda/sequential/particle.py +407 -0
- biasda-0.1.1/biasda/sequential/smoothers.py +478 -0
- biasda-0.1.1/biasda/utils.py +271 -0
- biasda-0.1.1/biasda/variational/__init__.py +31 -0
- biasda-0.1.1/biasda/variational/envar.py +363 -0
- biasda-0.1.1/biasda/variational/estimator.py +523 -0
- biasda-0.1.1/biasda/variational/var.py +540 -0
- biasda-0.1.1/biasda.egg-info/PKG-INFO +24 -0
- biasda-0.1.1/biasda.egg-info/SOURCES.txt +62 -0
- biasda-0.1.1/biasda.egg-info/dependency_links.txt +1 -0
- biasda-0.1.1/biasda.egg-info/requires.txt +10 -0
- biasda-0.1.1/biasda.egg-info/top_level.txt +1 -0
- biasda-0.1.1/pyproject.toml +59 -0
- biasda-0.1.1/setup.cfg +4 -0
- biasda-0.1.1/tests/conftest.py +205 -0
- biasda-0.1.1/tests/test_adjoint.py +82 -0
- biasda-0.1.1/tests/test_augmented.py +59 -0
- biasda-0.1.1/tests/test_bias.py +86 -0
- biasda-0.1.1/tests/test_bias_calibration.py +302 -0
- biasda-0.1.1/tests/test_bias_config.py +367 -0
- biasda-0.1.1/tests/test_bias_models.py +230 -0
- biasda-0.1.1/tests/test_deprecated_presets.py +86 -0
- biasda-0.1.1/tests/test_ekf.py +103 -0
- biasda-0.1.1/tests/test_ensemble.py +401 -0
- biasda-0.1.1/tests/test_envar.py +202 -0
- biasda-0.1.1/tests/test_esn_bias.py +405 -0
- biasda-0.1.1/tests/test_examples_construct.py +46 -0
- biasda-0.1.1/tests/test_formulations.py +77 -0
- biasda-0.1.1/tests/test_independence.py +14 -0
- biasda-0.1.1/tests/test_innovation_inflation.py +210 -0
- biasda-0.1.1/tests/test_kalman.py +290 -0
- biasda-0.1.1/tests/test_literature_equivalence.py +455 -0
- biasda-0.1.1/tests/test_localization.py +356 -0
- biasda-0.1.1/tests/test_monte_carlo.py +131 -0
- biasda-0.1.1/tests/test_nudging.py +225 -0
- biasda-0.1.1/tests/test_observations.py +170 -0
- biasda-0.1.1/tests/test_parameter_estimation.py +165 -0
- biasda-0.1.1/tests/test_particle.py +407 -0
- biasda-0.1.1/tests/test_smoother_equals_var4d.py +74 -0
- biasda-0.1.1/tests/test_smoothers.py +220 -0
- biasda-0.1.1/tests/test_time_linear_bias.py +264 -0
- biasda-0.1.1/tests/test_two_stage.py +273 -0
- biasda-0.1.1/tests/test_var_hierarchy.py +71 -0
- biasda-0.1.1/tests/test_variational.py +122 -0
- biasda-0.1.1/tests/test_variational_estimator.py +355 -0
- biasda-0.1.1/tests/test_variational_regularization.py +78 -0
- biasda-0.1.1/tests/test_zero_bias_identity.py +104 -0
biasda-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrea Nóvoa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
biasda-0.1.1/MANIFEST.in
ADDED
biasda-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: biasda
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Bias-aware data assimilation for any forecast model: variational and sequential state, parameter and bias estimation
|
|
5
|
+
Author-email: Andrea Nóvoa <a.novoa@imperial.ac.uk>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/andreanovoa/biasda
|
|
8
|
+
Project-URL: Repository, https://github.com/andreanovoa/biasda
|
|
9
|
+
Project-URL: Issues, https://github.com/andreanovoa/biasda/issues
|
|
10
|
+
Keywords: data-assimilation,ensemble-kalman-filter,state-estimation,parameter-estimation,bias-aware
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: matplotlib<4.0,>=3.9
|
|
17
|
+
Requires-Dist: numpy<3.0,>=2.0
|
|
18
|
+
Requires-Dist: scipy<2.0,>=1.13
|
|
19
|
+
Provides-Extra: esn
|
|
20
|
+
Requires-Dist: echostatenetwork>=0.1.4; extra == "esn"
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=9.0.3; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff>=0.11.5; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
@@ -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
|
+
]
|