pyteda 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.

Potentially problematic release.


This version of pyteda might be problematic. Click here for more details.

pyteda-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,339 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyteda
3
+ Version: 0.1.1
4
+ Summary: TEDA: Toy models and ensemble-based Data Assimilation methods for education and experimentation
5
+ Author-email: "Elías D. Niño-Ruiz" <elias.d.nino@gmail.com>
6
+ License: MIT
7
+ Keywords: data assimilation,EnKF,education,Lorenz96,Python
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.7
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: numpy
19
+ Requires-Dist: scipy
20
+ Requires-Dist: matplotlib
21
+ Requires-Dist: scikit-learn
22
+
23
+ # TEDA - A Computational Toolbox for Teaching Ensemble Based Data Assimilation
24
+
25
+ ### 📚 Citation
26
+
27
+ If you use **TEDA** in your teaching, research, or publications, please cite the following paper:
28
+
29
+ > **Nino-Ruiz, E.D., Valbuena, S.R.** (2022).
30
+ > *TEDA: A Computational Toolbox for Teaching Ensemble Based Data Assimilation*.
31
+ > In: Groen, D., de Mulatier, C., Paszynski, M., Krzhizhanovskaya, V.V., Dongarra, J.J., Sloot, P.M.A. (eds) **Computational Science – ICCS 2022**.
32
+ > Lecture Notes in Computer Science, vol 13353. Springer, Cham.
33
+ > [https://doi.org/10.1007/978-3-031-08760-8\_60](https://doi.org/10.1007/978-3-031-08760-8_60)
34
+
35
+ You can also use this BibTeX entry:
36
+
37
+ ```bibtex
38
+ @inproceedings{nino2022teda,
39
+ title={TEDA: A Computational Toolbox for Teaching Ensemble Based Data Assimilation},
40
+ author={Nino-Ruiz, Elias D. and Valbuena, Sebastian Racedo},
41
+ booktitle={Computational Science – ICCS 2022},
42
+ series={Lecture Notes in Computer Science},
43
+ volume={13353},
44
+ pages={787--801},
45
+ year={2022},
46
+ publisher={Springer, Cham},
47
+ doi={10.1007/978-3-031-08760-8_60}
48
+ }
49
+ ```
50
+
51
+ [![Cite TEDA](https://img.shields.io/badge/Cite-TEDA-blue.svg)](https://doi.org/10.1007/978-3-031-08760-8_60)
52
+
53
+ ---
54
+
55
+
56
+ ## Introducing TEDA: The Premier Python Toolbox for Teaching Ensemble-based Data Assimilation
57
+
58
+ ![Class Diagram](imgs/Class_TEDA.svg)
59
+
60
+ We are thrilled to present TEDA, a cutting-edge Python toolbox designed to facilitate the teaching and learning of ensemble-based data assimilation (DA). TEDA caters to the needs of educators and learners alike, offering a comprehensive platform to explore the captivating world of meteorological anomalies, climate change, and DA methodologies.
61
+
62
+ TEDA stands out as an exceptional resource in the landscape of DA software, as it prioritizes the educational experience. While operational software tends to focus on practical applications, TEDA empowers undergraduate and graduate students by providing an intuitive platform to grasp the intricacies of ensemble-based DA concepts and foster enthusiasm for scientific exploration.
63
+
64
+ Equipped with a diverse range of features and functionalities, TEDA enriches the learning process by offering powerful visualization tools. Students can delve into error statistics, model errors, observational errors, error distributions, and the dynamic evolution of errors. These visualizations provide multiple perspectives on numerical results, enabling students to develop a deep understanding of ensemble-based DA principles.
65
+
66
+ TEDA offers numerous ensemble-based DA methods, allowing students to explore an extensive range of techniques. From the stochastic ensemble Kalman filter (EnKF) to dual EnKF formulations, EnKF via Cholesky decomposition, EnKF based on modified Cholesky decomposition, EnKF based on B-localization, and beyond, TEDA equips learners with a comprehensive toolkit to study and compare various DA methodologies.
67
+
68
+ TEDA's foundation is rooted in the Object-Oriented Programming (OOP) paradigm, enabling effortless integration of new techniques and models. This ensures that TEDA remains at the forefront of the rapidly evolving field of ensemble-based DA, allowing educators and researchers to incorporate the latest advancements into their teaching and experimentation.
69
+
70
+ Embark on a captivating journey of discovery and knowledge with TEDA as it unveils the secrets of data assimilation. Simulate various DA scenarios, experiment with different model configurations, and witness firsthand the transformative impact of ensemble-based DA methods on forecast accuracy and data analysis.
71
+
72
+ Unlock your true potential in the realm of data assimilation with TEDA. Whether you are an enthusiastic student or a dedicated educator, TEDA stands as your ultimate companion in unraveling the complexities of ensemble-based DA.
73
+
74
+ Keywords: Data Assimilation, Ensemble Kalman Filter, Education, Python.
75
+
76
+ ### 🧪 Toy Models for Data Assimilation
77
+
78
+ To enhance the learning experience, **TEDA** is built around **toy models** that exhibit chaotic behavior under specific configurations. These models are ideal for experimenting with and validating various Data Assimilation (DA) techniques in a hands-on, controlled setting.
79
+
80
+ Currently, TEDA includes the **Lorenz 96 model** (40 variables), a well-known benchmark in DA research.
81
+
82
+ > 📌 *Support for other classic chaotic systems like the Duffing equation and Lorenz 63 may be added in future versions.*
83
+
84
+
85
+
86
+ ## How easy is to use it?
87
+
88
+ Choose the desired method from the pool of available methods:
89
+
90
+ ```python
91
+ from analysis.analysis_enkf_modified_cholesky import AnalysisEnKFModifiedCholesky
92
+ ```
93
+
94
+ Select a model to perform the simulations:
95
+
96
+ ```python
97
+ model = Lorenz96()
98
+ ```
99
+
100
+ Create a background object with the desired parameters:
101
+
102
+ ```python
103
+ background = Background(model, ensemble_size=20)
104
+ ```
105
+
106
+ Create an analysis object with the desired method and its parameters + the chosen model:
107
+
108
+ ```python
109
+ analysis = AnalysisEnKFModifiedCholesky(model, r=2)
110
+ ```
111
+
112
+ Define the observation parameters:
113
+
114
+ ```python
115
+ observation = Observation(m=32, std_obs=0.01)
116
+ ```
117
+
118
+ Set up the parameters for the simulation:
119
+
120
+ ```python
121
+ params = {'obs_freq': 0.1, 'obs_times': 10, 'inf_fact': 1.04}
122
+
123
+ simulation = Simulation(
124
+ model,
125
+ background,
126
+ analysis,
127
+ observation,
128
+ params=params,
129
+ log_level=None # set to None to disable logging
130
+ )
131
+ ```
132
+
133
+ and then, run the simulation!
134
+
135
+ ```python
136
+ simulation.run()
137
+ ```
138
+
139
+
140
+ ### ✨ Logging (Optional)
141
+
142
+ > 💡 **Note:** If you want to enable logs (e.g., for debugging or monitoring), just pass a `log_level` when creating the simulation.
143
+ > To **disable logs**, use `log_level=None`.
144
+
145
+ ```python
146
+ import logging
147
+
148
+ simulation = Simulation(
149
+ model,
150
+ background,
151
+ analysis,
152
+ observation,
153
+ params=params,
154
+ log_level=logging.INFO # set to None to disable logging
155
+ )
156
+ ```
157
+
158
+ You can then request the backgound and analysis errors per assimilation step for plotting purposes or statistical computations:
159
+
160
+ ```python
161
+ import matplotlib.pyplot as plt
162
+
163
+ errb, erra = simulation.get_errors()
164
+
165
+ plt.figure(figsize=(12, 10))
166
+ plt.plot(np.log10(errb),'-ob')
167
+ plt.plot(np.log10(erra),'-or')
168
+ plt.show()
169
+ ```
170
+
171
+ 📁 Example usage
172
+
173
+ See [`examples/basic_template.py`](examples/basic_template.py) for a complete simulation workflow.
174
+
175
+ ---
176
+
177
+ ### 🚀 Installation and Quick Start
178
+
179
+ We recommend using a virtual environment:
180
+
181
+ ```bash
182
+ python -m venv venv
183
+ source venv/bin/activate # On Windows: venv\Scripts\activate
184
+ ```
185
+
186
+ Install the required dependencies:
187
+
188
+ ```bash
189
+ pip install -r requirements.txt
190
+ ```
191
+
192
+ > Or, if you're developing TEDA locally:
193
+
194
+ ```bash
195
+ pip install -e .
196
+ ```
197
+
198
+ ---
199
+
200
+ ### ▶️ Run the basic example
201
+
202
+ Once installed, you can run the full example with:
203
+
204
+ ```bash
205
+ python -m examples.basic_template
206
+ ```
207
+
208
+ This will initialize the Lorenz96 model, run an ensemble-based data assimilation simulation, and display the log-relative errors for both the background and analysis states.
209
+
210
+
211
+ ## Supported methods
212
+
213
+
214
+ | Class | Description | Reference |
215
+ | ------------------------------ | ------------------------------------------------ | ---------------------------------------------------------- |
216
+ | AnalysisEnKFShrinkagePrecision | Compute the precision matrix for EnKF Shrinkage Precision. | Nino-Ruiz, Elias D., and Adrian Sandu. "Ensemble Kalman filter implementations based on shrinkage covariance matrix estimation." Ocean Dynamics 65 (2015): 1423-1439. |
217
+ | AnalysisEnKFModifiedCholesky | Compute the precision matrix for EnKF Modified Cholesky. | Nino-Ruiz, Elias D., Adrian Sandu, and Xinwei Deng. "An ensemble Kalman filter implementation based on modified Cholesky decomposition for inverse covariance matrix estimation." SIAM Journal on Scientific Computing 40.2 (2018): A867-A886. |
218
+ | AnalysisEnKFNaive | Perform assimilation using Naive EnKF method. | Nino Ruiz, Elias D., Adrian Sandu, and Jeffrey Anderson. "An efficient implementation of the ensemble Kalman filter based on an iterative Sherman–Morrison formula." Statistics and Computing 25 (2015): 561-577. |
219
+ | AnalysisEnSRF | Perform assimilation using EnSRF method. | Tippett, Michael K., et al. "Ensemble square root filters." Monthly weather review 131.7 (2003): 1485-1490. |
220
+ | AnalysisETKF | Perform assimilation using ETKF method. | Bishop, Craig H., Brian J. Etherton, and Sharanya J. Majumdar. "Adaptive sampling with the ensemble transform Kalman filter. Part I: Theoretical aspects." Monthly weather review 129.3 (2001): 420-436. |
221
+ | AnalysisLETKF | Perform assimilation using LETKF method. | Hunt, Brian R., Eric J. Kostelich, and Istvan Szunyogh. "Efficient data assimilation for spatiotemporal chaos: A local ensemble transform Kalman filter." Physica D: Nonlinear Phenomena 230.1-2 (2007): 112-126. |
222
+ | AnalysisLEnKF | Perform assimilation using LEnKF method. |Ott, Edward, et al. "A local ensemble Kalman filter for atmospheric data assimilation." Tellus A: Dynamic Meteorology and Oceanography 56.5 (2004): 415-428. |
223
+ | AnalysisEnKFBLoc | Perform assimilation using EnKF B-Loc method. | Greybush, Steven J., et al. "Balance and ensemble Kalman filter localization techniques." Monthly Weather Review 139.2 (2011): 511-522. |
224
+ | AnalysisEnKFCholesky | Perform assimilation using EnKF Cholesky decomposition. | Mandel, Jan. Efficient implementation of the ensemble Kalman filter. University of Colorado at Denver and Health Sciences Center, Center for Computational Mathematics, 2006. |
225
+ | AnalysisEnKF | Perform assimilation using EnKF full covariance matrix. | Evensen, Geir. Data assimilation: the ensemble Kalman filter. Vol. 2. Berlin: springer, 2009. |
226
+ | Analysis | Perform assimilation given background and observations. | Abstract class to define general methods for all assimilation steps. |
227
+
228
+ **Analysis (Abstract class for analysis methods)**
229
+
230
+ | Method | Description |
231
+ | ---------------------- | ------------------------------------------------ |
232
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
233
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
234
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
235
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
236
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
237
+
238
+ **AnalysisEnKF (Analysis EnKF full covariance matrix)**
239
+
240
+ | Method | Description |
241
+ | ---------------------- | ------------------------------------------------ |
242
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
243
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
244
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
245
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
246
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
247
+
248
+ **AnalysisEnKFBLoc (Analysis EnKF B-Loc)**
249
+
250
+ | Method | Description |
251
+ | ---------------------- | ------------------------------------------------ |
252
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
253
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
254
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
255
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
256
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
257
+
258
+ **AnalysisEnKFCholesky (EnKF implementation Cholesky)**
259
+
260
+ | Method | Description |
261
+ | ---------------------- | ------------------------------------------------ |
262
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
263
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
264
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
265
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
266
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
267
+
268
+ **AnalysisEnKFModifiedCholesky (Analysis EnKF Modified Cholesky decomposition)**
269
+
270
+ | Method | Description |
271
+ | ---------------------- | ------------------------------------------------ |
272
+ | get_precision_matrix | Returns the computed precision matrix. It takes the following parameters: <br>- **DX**: Deviation matrix.<br>- **regularization_factor**: Value used as alpha in the ridge model. |
273
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
274
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
275
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
276
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
277
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
278
+
279
+ **AnalysisEnKFNaive (Analysis EnKF Naive)**
280
+
281
+ | Method | Description |
282
+ | ---------------------- | ------------------------------------------------ |
283
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
284
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
285
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
286
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
287
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
288
+
289
+ **AnalysisEnKFShrinkagePrecision (Analysis EnKF Shrinkage Precision)**
290
+
291
+ | Method | Description |
292
+ | ---------------------- | ------------------------------------------------ |
293
+ | get_precision_matrix | Returns the computed precision matrix. It takes the following parameters: <br>- **DX**: Deviation matrix.<br>- **regularization_factor**: Value used as alpha in the ridge model. |
294
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
295
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
296
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
297
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
298
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
299
+
300
+ **AnalysisEnSRF (Analysis EnSRF)**
301
+
302
+ | Method | Description |
303
+ | ---------------------- | ------------------------------------------------ |
304
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
305
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
306
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
307
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
308
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
309
+
310
+ **AnalysisETKF (Analysis Ensemble Transform Kalman Filter (ETKF))**
311
+
312
+ | Method | Description |
313
+ | ---------------------- | ------------------------------------------------ |
314
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
315
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
316
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
317
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
318
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
319
+
320
+ **AnalysisLEnKF (Analysis LEnKF)**
321
+
322
+ | Method | Description |
323
+ | ---------------------- | ------------------------------------------------ |
324
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
325
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
326
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
327
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
328
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
329
+
330
+ **AnalysisLETKF (Analysis Local Ensemble Transform Kalman Filter (LETKF))**
331
+
332
+ | Method | Description |
333
+ | ---------------------- | ------------------------------------------------ |
334
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
335
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
336
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
337
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
338
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
339
+
pyteda-0.1.1/README.md ADDED
@@ -0,0 +1,317 @@
1
+ # TEDA - A Computational Toolbox for Teaching Ensemble Based Data Assimilation
2
+
3
+ ### 📚 Citation
4
+
5
+ If you use **TEDA** in your teaching, research, or publications, please cite the following paper:
6
+
7
+ > **Nino-Ruiz, E.D., Valbuena, S.R.** (2022).
8
+ > *TEDA: A Computational Toolbox for Teaching Ensemble Based Data Assimilation*.
9
+ > In: Groen, D., de Mulatier, C., Paszynski, M., Krzhizhanovskaya, V.V., Dongarra, J.J., Sloot, P.M.A. (eds) **Computational Science – ICCS 2022**.
10
+ > Lecture Notes in Computer Science, vol 13353. Springer, Cham.
11
+ > [https://doi.org/10.1007/978-3-031-08760-8\_60](https://doi.org/10.1007/978-3-031-08760-8_60)
12
+
13
+ You can also use this BibTeX entry:
14
+
15
+ ```bibtex
16
+ @inproceedings{nino2022teda,
17
+ title={TEDA: A Computational Toolbox for Teaching Ensemble Based Data Assimilation},
18
+ author={Nino-Ruiz, Elias D. and Valbuena, Sebastian Racedo},
19
+ booktitle={Computational Science – ICCS 2022},
20
+ series={Lecture Notes in Computer Science},
21
+ volume={13353},
22
+ pages={787--801},
23
+ year={2022},
24
+ publisher={Springer, Cham},
25
+ doi={10.1007/978-3-031-08760-8_60}
26
+ }
27
+ ```
28
+
29
+ [![Cite TEDA](https://img.shields.io/badge/Cite-TEDA-blue.svg)](https://doi.org/10.1007/978-3-031-08760-8_60)
30
+
31
+ ---
32
+
33
+
34
+ ## Introducing TEDA: The Premier Python Toolbox for Teaching Ensemble-based Data Assimilation
35
+
36
+ ![Class Diagram](imgs/Class_TEDA.svg)
37
+
38
+ We are thrilled to present TEDA, a cutting-edge Python toolbox designed to facilitate the teaching and learning of ensemble-based data assimilation (DA). TEDA caters to the needs of educators and learners alike, offering a comprehensive platform to explore the captivating world of meteorological anomalies, climate change, and DA methodologies.
39
+
40
+ TEDA stands out as an exceptional resource in the landscape of DA software, as it prioritizes the educational experience. While operational software tends to focus on practical applications, TEDA empowers undergraduate and graduate students by providing an intuitive platform to grasp the intricacies of ensemble-based DA concepts and foster enthusiasm for scientific exploration.
41
+
42
+ Equipped with a diverse range of features and functionalities, TEDA enriches the learning process by offering powerful visualization tools. Students can delve into error statistics, model errors, observational errors, error distributions, and the dynamic evolution of errors. These visualizations provide multiple perspectives on numerical results, enabling students to develop a deep understanding of ensemble-based DA principles.
43
+
44
+ TEDA offers numerous ensemble-based DA methods, allowing students to explore an extensive range of techniques. From the stochastic ensemble Kalman filter (EnKF) to dual EnKF formulations, EnKF via Cholesky decomposition, EnKF based on modified Cholesky decomposition, EnKF based on B-localization, and beyond, TEDA equips learners with a comprehensive toolkit to study and compare various DA methodologies.
45
+
46
+ TEDA's foundation is rooted in the Object-Oriented Programming (OOP) paradigm, enabling effortless integration of new techniques and models. This ensures that TEDA remains at the forefront of the rapidly evolving field of ensemble-based DA, allowing educators and researchers to incorporate the latest advancements into their teaching and experimentation.
47
+
48
+ Embark on a captivating journey of discovery and knowledge with TEDA as it unveils the secrets of data assimilation. Simulate various DA scenarios, experiment with different model configurations, and witness firsthand the transformative impact of ensemble-based DA methods on forecast accuracy and data analysis.
49
+
50
+ Unlock your true potential in the realm of data assimilation with TEDA. Whether you are an enthusiastic student or a dedicated educator, TEDA stands as your ultimate companion in unraveling the complexities of ensemble-based DA.
51
+
52
+ Keywords: Data Assimilation, Ensemble Kalman Filter, Education, Python.
53
+
54
+ ### 🧪 Toy Models for Data Assimilation
55
+
56
+ To enhance the learning experience, **TEDA** is built around **toy models** that exhibit chaotic behavior under specific configurations. These models are ideal for experimenting with and validating various Data Assimilation (DA) techniques in a hands-on, controlled setting.
57
+
58
+ Currently, TEDA includes the **Lorenz 96 model** (40 variables), a well-known benchmark in DA research.
59
+
60
+ > 📌 *Support for other classic chaotic systems like the Duffing equation and Lorenz 63 may be added in future versions.*
61
+
62
+
63
+
64
+ ## How easy is to use it?
65
+
66
+ Choose the desired method from the pool of available methods:
67
+
68
+ ```python
69
+ from analysis.analysis_enkf_modified_cholesky import AnalysisEnKFModifiedCholesky
70
+ ```
71
+
72
+ Select a model to perform the simulations:
73
+
74
+ ```python
75
+ model = Lorenz96()
76
+ ```
77
+
78
+ Create a background object with the desired parameters:
79
+
80
+ ```python
81
+ background = Background(model, ensemble_size=20)
82
+ ```
83
+
84
+ Create an analysis object with the desired method and its parameters + the chosen model:
85
+
86
+ ```python
87
+ analysis = AnalysisEnKFModifiedCholesky(model, r=2)
88
+ ```
89
+
90
+ Define the observation parameters:
91
+
92
+ ```python
93
+ observation = Observation(m=32, std_obs=0.01)
94
+ ```
95
+
96
+ Set up the parameters for the simulation:
97
+
98
+ ```python
99
+ params = {'obs_freq': 0.1, 'obs_times': 10, 'inf_fact': 1.04}
100
+
101
+ simulation = Simulation(
102
+ model,
103
+ background,
104
+ analysis,
105
+ observation,
106
+ params=params,
107
+ log_level=None # set to None to disable logging
108
+ )
109
+ ```
110
+
111
+ and then, run the simulation!
112
+
113
+ ```python
114
+ simulation.run()
115
+ ```
116
+
117
+
118
+ ### ✨ Logging (Optional)
119
+
120
+ > 💡 **Note:** If you want to enable logs (e.g., for debugging or monitoring), just pass a `log_level` when creating the simulation.
121
+ > To **disable logs**, use `log_level=None`.
122
+
123
+ ```python
124
+ import logging
125
+
126
+ simulation = Simulation(
127
+ model,
128
+ background,
129
+ analysis,
130
+ observation,
131
+ params=params,
132
+ log_level=logging.INFO # set to None to disable logging
133
+ )
134
+ ```
135
+
136
+ You can then request the backgound and analysis errors per assimilation step for plotting purposes or statistical computations:
137
+
138
+ ```python
139
+ import matplotlib.pyplot as plt
140
+
141
+ errb, erra = simulation.get_errors()
142
+
143
+ plt.figure(figsize=(12, 10))
144
+ plt.plot(np.log10(errb),'-ob')
145
+ plt.plot(np.log10(erra),'-or')
146
+ plt.show()
147
+ ```
148
+
149
+ 📁 Example usage
150
+
151
+ See [`examples/basic_template.py`](examples/basic_template.py) for a complete simulation workflow.
152
+
153
+ ---
154
+
155
+ ### 🚀 Installation and Quick Start
156
+
157
+ We recommend using a virtual environment:
158
+
159
+ ```bash
160
+ python -m venv venv
161
+ source venv/bin/activate # On Windows: venv\Scripts\activate
162
+ ```
163
+
164
+ Install the required dependencies:
165
+
166
+ ```bash
167
+ pip install -r requirements.txt
168
+ ```
169
+
170
+ > Or, if you're developing TEDA locally:
171
+
172
+ ```bash
173
+ pip install -e .
174
+ ```
175
+
176
+ ---
177
+
178
+ ### ▶️ Run the basic example
179
+
180
+ Once installed, you can run the full example with:
181
+
182
+ ```bash
183
+ python -m examples.basic_template
184
+ ```
185
+
186
+ This will initialize the Lorenz96 model, run an ensemble-based data assimilation simulation, and display the log-relative errors for both the background and analysis states.
187
+
188
+
189
+ ## Supported methods
190
+
191
+
192
+ | Class | Description | Reference |
193
+ | ------------------------------ | ------------------------------------------------ | ---------------------------------------------------------- |
194
+ | AnalysisEnKFShrinkagePrecision | Compute the precision matrix for EnKF Shrinkage Precision. | Nino-Ruiz, Elias D., and Adrian Sandu. "Ensemble Kalman filter implementations based on shrinkage covariance matrix estimation." Ocean Dynamics 65 (2015): 1423-1439. |
195
+ | AnalysisEnKFModifiedCholesky | Compute the precision matrix for EnKF Modified Cholesky. | Nino-Ruiz, Elias D., Adrian Sandu, and Xinwei Deng. "An ensemble Kalman filter implementation based on modified Cholesky decomposition for inverse covariance matrix estimation." SIAM Journal on Scientific Computing 40.2 (2018): A867-A886. |
196
+ | AnalysisEnKFNaive | Perform assimilation using Naive EnKF method. | Nino Ruiz, Elias D., Adrian Sandu, and Jeffrey Anderson. "An efficient implementation of the ensemble Kalman filter based on an iterative Sherman–Morrison formula." Statistics and Computing 25 (2015): 561-577. |
197
+ | AnalysisEnSRF | Perform assimilation using EnSRF method. | Tippett, Michael K., et al. "Ensemble square root filters." Monthly weather review 131.7 (2003): 1485-1490. |
198
+ | AnalysisETKF | Perform assimilation using ETKF method. | Bishop, Craig H., Brian J. Etherton, and Sharanya J. Majumdar. "Adaptive sampling with the ensemble transform Kalman filter. Part I: Theoretical aspects." Monthly weather review 129.3 (2001): 420-436. |
199
+ | AnalysisLETKF | Perform assimilation using LETKF method. | Hunt, Brian R., Eric J. Kostelich, and Istvan Szunyogh. "Efficient data assimilation for spatiotemporal chaos: A local ensemble transform Kalman filter." Physica D: Nonlinear Phenomena 230.1-2 (2007): 112-126. |
200
+ | AnalysisLEnKF | Perform assimilation using LEnKF method. |Ott, Edward, et al. "A local ensemble Kalman filter for atmospheric data assimilation." Tellus A: Dynamic Meteorology and Oceanography 56.5 (2004): 415-428. |
201
+ | AnalysisEnKFBLoc | Perform assimilation using EnKF B-Loc method. | Greybush, Steven J., et al. "Balance and ensemble Kalman filter localization techniques." Monthly Weather Review 139.2 (2011): 511-522. |
202
+ | AnalysisEnKFCholesky | Perform assimilation using EnKF Cholesky decomposition. | Mandel, Jan. Efficient implementation of the ensemble Kalman filter. University of Colorado at Denver and Health Sciences Center, Center for Computational Mathematics, 2006. |
203
+ | AnalysisEnKF | Perform assimilation using EnKF full covariance matrix. | Evensen, Geir. Data assimilation: the ensemble Kalman filter. Vol. 2. Berlin: springer, 2009. |
204
+ | Analysis | Perform assimilation given background and observations. | Abstract class to define general methods for all assimilation steps. |
205
+
206
+ **Analysis (Abstract class for analysis methods)**
207
+
208
+ | Method | Description |
209
+ | ---------------------- | ------------------------------------------------ |
210
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
211
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
212
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
213
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
214
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
215
+
216
+ **AnalysisEnKF (Analysis EnKF full covariance matrix)**
217
+
218
+ | Method | Description |
219
+ | ---------------------- | ------------------------------------------------ |
220
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
221
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
222
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
223
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
224
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
225
+
226
+ **AnalysisEnKFBLoc (Analysis EnKF B-Loc)**
227
+
228
+ | Method | Description |
229
+ | ---------------------- | ------------------------------------------------ |
230
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
231
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
232
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
233
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
234
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
235
+
236
+ **AnalysisEnKFCholesky (EnKF implementation Cholesky)**
237
+
238
+ | Method | Description |
239
+ | ---------------------- | ------------------------------------------------ |
240
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
241
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
242
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
243
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
244
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
245
+
246
+ **AnalysisEnKFModifiedCholesky (Analysis EnKF Modified Cholesky decomposition)**
247
+
248
+ | Method | Description |
249
+ | ---------------------- | ------------------------------------------------ |
250
+ | get_precision_matrix | Returns the computed precision matrix. It takes the following parameters: <br>- **DX**: Deviation matrix.<br>- **regularization_factor**: Value used as alpha in the ridge model. |
251
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
252
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
253
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
254
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
255
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
256
+
257
+ **AnalysisEnKFNaive (Analysis EnKF Naive)**
258
+
259
+ | Method | Description |
260
+ | ---------------------- | ------------------------------------------------ |
261
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
262
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
263
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
264
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
265
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
266
+
267
+ **AnalysisEnKFShrinkagePrecision (Analysis EnKF Shrinkage Precision)**
268
+
269
+ | Method | Description |
270
+ | ---------------------- | ------------------------------------------------ |
271
+ | get_precision_matrix | Returns the computed precision matrix. It takes the following parameters: <br>- **DX**: Deviation matrix.<br>- **regularization_factor**: Value used as alpha in the ridge model. |
272
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
273
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
274
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
275
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
276
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
277
+
278
+ **AnalysisEnSRF (Analysis EnSRF)**
279
+
280
+ | Method | Description |
281
+ | ---------------------- | ------------------------------------------------ |
282
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
283
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
284
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
285
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
286
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
287
+
288
+ **AnalysisETKF (Analysis Ensemble Transform Kalman Filter (ETKF))**
289
+
290
+ | Method | Description |
291
+ | ---------------------- | ------------------------------------------------ |
292
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
293
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
294
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
295
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
296
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
297
+
298
+ **AnalysisLEnKF (Analysis LEnKF)**
299
+
300
+ | Method | Description |
301
+ | ---------------------- | ------------------------------------------------ |
302
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
303
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
304
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
305
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
306
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
307
+
308
+ **AnalysisLETKF (Analysis Local Ensemble Transform Kalman Filter (LETKF))**
309
+
310
+ | Method | Description |
311
+ | ---------------------- | ------------------------------------------------ |
312
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
313
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
314
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
315
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
316
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
317
+
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "pyteda"
3
+ version = "0.1.1"
4
+ description = "TEDA: Toy models and ensemble-based Data Assimilation methods for education and experimentation"
5
+ readme = "README.md"
6
+ requires-python = ">=3.7"
7
+ license = {text = "MIT"}
8
+ authors = [
9
+ { name = "Elías D. Niño-Ruiz", email = "elias.d.nino@gmail.com" }
10
+ ]
11
+ keywords = ["data assimilation", "EnKF", "education", "Lorenz96", "Python"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Education",
15
+ "Topic :: Scientific/Engineering :: Atmospheric Science",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.7",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9"
21
+ ]
22
+ dependencies = [
23
+ "numpy",
24
+ "scipy",
25
+ "matplotlib",
26
+ "scikit-learn"
27
+ ]
28
+
29
+ [tool.setuptools]
30
+ packages = ["teda"]
31
+
32
+ [build-system]
33
+ requires = ["setuptools>=61.0", "wheel"]
34
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,339 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyteda
3
+ Version: 0.1.1
4
+ Summary: TEDA: Toy models and ensemble-based Data Assimilation methods for education and experimentation
5
+ Author-email: "Elías D. Niño-Ruiz" <elias.d.nino@gmail.com>
6
+ License: MIT
7
+ Keywords: data assimilation,EnKF,education,Lorenz96,Python
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.7
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Requires-Python: >=3.7
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: numpy
19
+ Requires-Dist: scipy
20
+ Requires-Dist: matplotlib
21
+ Requires-Dist: scikit-learn
22
+
23
+ # TEDA - A Computational Toolbox for Teaching Ensemble Based Data Assimilation
24
+
25
+ ### 📚 Citation
26
+
27
+ If you use **TEDA** in your teaching, research, or publications, please cite the following paper:
28
+
29
+ > **Nino-Ruiz, E.D., Valbuena, S.R.** (2022).
30
+ > *TEDA: A Computational Toolbox for Teaching Ensemble Based Data Assimilation*.
31
+ > In: Groen, D., de Mulatier, C., Paszynski, M., Krzhizhanovskaya, V.V., Dongarra, J.J., Sloot, P.M.A. (eds) **Computational Science – ICCS 2022**.
32
+ > Lecture Notes in Computer Science, vol 13353. Springer, Cham.
33
+ > [https://doi.org/10.1007/978-3-031-08760-8\_60](https://doi.org/10.1007/978-3-031-08760-8_60)
34
+
35
+ You can also use this BibTeX entry:
36
+
37
+ ```bibtex
38
+ @inproceedings{nino2022teda,
39
+ title={TEDA: A Computational Toolbox for Teaching Ensemble Based Data Assimilation},
40
+ author={Nino-Ruiz, Elias D. and Valbuena, Sebastian Racedo},
41
+ booktitle={Computational Science – ICCS 2022},
42
+ series={Lecture Notes in Computer Science},
43
+ volume={13353},
44
+ pages={787--801},
45
+ year={2022},
46
+ publisher={Springer, Cham},
47
+ doi={10.1007/978-3-031-08760-8_60}
48
+ }
49
+ ```
50
+
51
+ [![Cite TEDA](https://img.shields.io/badge/Cite-TEDA-blue.svg)](https://doi.org/10.1007/978-3-031-08760-8_60)
52
+
53
+ ---
54
+
55
+
56
+ ## Introducing TEDA: The Premier Python Toolbox for Teaching Ensemble-based Data Assimilation
57
+
58
+ ![Class Diagram](imgs/Class_TEDA.svg)
59
+
60
+ We are thrilled to present TEDA, a cutting-edge Python toolbox designed to facilitate the teaching and learning of ensemble-based data assimilation (DA). TEDA caters to the needs of educators and learners alike, offering a comprehensive platform to explore the captivating world of meteorological anomalies, climate change, and DA methodologies.
61
+
62
+ TEDA stands out as an exceptional resource in the landscape of DA software, as it prioritizes the educational experience. While operational software tends to focus on practical applications, TEDA empowers undergraduate and graduate students by providing an intuitive platform to grasp the intricacies of ensemble-based DA concepts and foster enthusiasm for scientific exploration.
63
+
64
+ Equipped with a diverse range of features and functionalities, TEDA enriches the learning process by offering powerful visualization tools. Students can delve into error statistics, model errors, observational errors, error distributions, and the dynamic evolution of errors. These visualizations provide multiple perspectives on numerical results, enabling students to develop a deep understanding of ensemble-based DA principles.
65
+
66
+ TEDA offers numerous ensemble-based DA methods, allowing students to explore an extensive range of techniques. From the stochastic ensemble Kalman filter (EnKF) to dual EnKF formulations, EnKF via Cholesky decomposition, EnKF based on modified Cholesky decomposition, EnKF based on B-localization, and beyond, TEDA equips learners with a comprehensive toolkit to study and compare various DA methodologies.
67
+
68
+ TEDA's foundation is rooted in the Object-Oriented Programming (OOP) paradigm, enabling effortless integration of new techniques and models. This ensures that TEDA remains at the forefront of the rapidly evolving field of ensemble-based DA, allowing educators and researchers to incorporate the latest advancements into their teaching and experimentation.
69
+
70
+ Embark on a captivating journey of discovery and knowledge with TEDA as it unveils the secrets of data assimilation. Simulate various DA scenarios, experiment with different model configurations, and witness firsthand the transformative impact of ensemble-based DA methods on forecast accuracy and data analysis.
71
+
72
+ Unlock your true potential in the realm of data assimilation with TEDA. Whether you are an enthusiastic student or a dedicated educator, TEDA stands as your ultimate companion in unraveling the complexities of ensemble-based DA.
73
+
74
+ Keywords: Data Assimilation, Ensemble Kalman Filter, Education, Python.
75
+
76
+ ### 🧪 Toy Models for Data Assimilation
77
+
78
+ To enhance the learning experience, **TEDA** is built around **toy models** that exhibit chaotic behavior under specific configurations. These models are ideal for experimenting with and validating various Data Assimilation (DA) techniques in a hands-on, controlled setting.
79
+
80
+ Currently, TEDA includes the **Lorenz 96 model** (40 variables), a well-known benchmark in DA research.
81
+
82
+ > 📌 *Support for other classic chaotic systems like the Duffing equation and Lorenz 63 may be added in future versions.*
83
+
84
+
85
+
86
+ ## How easy is to use it?
87
+
88
+ Choose the desired method from the pool of available methods:
89
+
90
+ ```python
91
+ from analysis.analysis_enkf_modified_cholesky import AnalysisEnKFModifiedCholesky
92
+ ```
93
+
94
+ Select a model to perform the simulations:
95
+
96
+ ```python
97
+ model = Lorenz96()
98
+ ```
99
+
100
+ Create a background object with the desired parameters:
101
+
102
+ ```python
103
+ background = Background(model, ensemble_size=20)
104
+ ```
105
+
106
+ Create an analysis object with the desired method and its parameters + the chosen model:
107
+
108
+ ```python
109
+ analysis = AnalysisEnKFModifiedCholesky(model, r=2)
110
+ ```
111
+
112
+ Define the observation parameters:
113
+
114
+ ```python
115
+ observation = Observation(m=32, std_obs=0.01)
116
+ ```
117
+
118
+ Set up the parameters for the simulation:
119
+
120
+ ```python
121
+ params = {'obs_freq': 0.1, 'obs_times': 10, 'inf_fact': 1.04}
122
+
123
+ simulation = Simulation(
124
+ model,
125
+ background,
126
+ analysis,
127
+ observation,
128
+ params=params,
129
+ log_level=None # set to None to disable logging
130
+ )
131
+ ```
132
+
133
+ and then, run the simulation!
134
+
135
+ ```python
136
+ simulation.run()
137
+ ```
138
+
139
+
140
+ ### ✨ Logging (Optional)
141
+
142
+ > 💡 **Note:** If you want to enable logs (e.g., for debugging or monitoring), just pass a `log_level` when creating the simulation.
143
+ > To **disable logs**, use `log_level=None`.
144
+
145
+ ```python
146
+ import logging
147
+
148
+ simulation = Simulation(
149
+ model,
150
+ background,
151
+ analysis,
152
+ observation,
153
+ params=params,
154
+ log_level=logging.INFO # set to None to disable logging
155
+ )
156
+ ```
157
+
158
+ You can then request the backgound and analysis errors per assimilation step for plotting purposes or statistical computations:
159
+
160
+ ```python
161
+ import matplotlib.pyplot as plt
162
+
163
+ errb, erra = simulation.get_errors()
164
+
165
+ plt.figure(figsize=(12, 10))
166
+ plt.plot(np.log10(errb),'-ob')
167
+ plt.plot(np.log10(erra),'-or')
168
+ plt.show()
169
+ ```
170
+
171
+ 📁 Example usage
172
+
173
+ See [`examples/basic_template.py`](examples/basic_template.py) for a complete simulation workflow.
174
+
175
+ ---
176
+
177
+ ### 🚀 Installation and Quick Start
178
+
179
+ We recommend using a virtual environment:
180
+
181
+ ```bash
182
+ python -m venv venv
183
+ source venv/bin/activate # On Windows: venv\Scripts\activate
184
+ ```
185
+
186
+ Install the required dependencies:
187
+
188
+ ```bash
189
+ pip install -r requirements.txt
190
+ ```
191
+
192
+ > Or, if you're developing TEDA locally:
193
+
194
+ ```bash
195
+ pip install -e .
196
+ ```
197
+
198
+ ---
199
+
200
+ ### ▶️ Run the basic example
201
+
202
+ Once installed, you can run the full example with:
203
+
204
+ ```bash
205
+ python -m examples.basic_template
206
+ ```
207
+
208
+ This will initialize the Lorenz96 model, run an ensemble-based data assimilation simulation, and display the log-relative errors for both the background and analysis states.
209
+
210
+
211
+ ## Supported methods
212
+
213
+
214
+ | Class | Description | Reference |
215
+ | ------------------------------ | ------------------------------------------------ | ---------------------------------------------------------- |
216
+ | AnalysisEnKFShrinkagePrecision | Compute the precision matrix for EnKF Shrinkage Precision. | Nino-Ruiz, Elias D., and Adrian Sandu. "Ensemble Kalman filter implementations based on shrinkage covariance matrix estimation." Ocean Dynamics 65 (2015): 1423-1439. |
217
+ | AnalysisEnKFModifiedCholesky | Compute the precision matrix for EnKF Modified Cholesky. | Nino-Ruiz, Elias D., Adrian Sandu, and Xinwei Deng. "An ensemble Kalman filter implementation based on modified Cholesky decomposition for inverse covariance matrix estimation." SIAM Journal on Scientific Computing 40.2 (2018): A867-A886. |
218
+ | AnalysisEnKFNaive | Perform assimilation using Naive EnKF method. | Nino Ruiz, Elias D., Adrian Sandu, and Jeffrey Anderson. "An efficient implementation of the ensemble Kalman filter based on an iterative Sherman–Morrison formula." Statistics and Computing 25 (2015): 561-577. |
219
+ | AnalysisEnSRF | Perform assimilation using EnSRF method. | Tippett, Michael K., et al. "Ensemble square root filters." Monthly weather review 131.7 (2003): 1485-1490. |
220
+ | AnalysisETKF | Perform assimilation using ETKF method. | Bishop, Craig H., Brian J. Etherton, and Sharanya J. Majumdar. "Adaptive sampling with the ensemble transform Kalman filter. Part I: Theoretical aspects." Monthly weather review 129.3 (2001): 420-436. |
221
+ | AnalysisLETKF | Perform assimilation using LETKF method. | Hunt, Brian R., Eric J. Kostelich, and Istvan Szunyogh. "Efficient data assimilation for spatiotemporal chaos: A local ensemble transform Kalman filter." Physica D: Nonlinear Phenomena 230.1-2 (2007): 112-126. |
222
+ | AnalysisLEnKF | Perform assimilation using LEnKF method. |Ott, Edward, et al. "A local ensemble Kalman filter for atmospheric data assimilation." Tellus A: Dynamic Meteorology and Oceanography 56.5 (2004): 415-428. |
223
+ | AnalysisEnKFBLoc | Perform assimilation using EnKF B-Loc method. | Greybush, Steven J., et al. "Balance and ensemble Kalman filter localization techniques." Monthly Weather Review 139.2 (2011): 511-522. |
224
+ | AnalysisEnKFCholesky | Perform assimilation using EnKF Cholesky decomposition. | Mandel, Jan. Efficient implementation of the ensemble Kalman filter. University of Colorado at Denver and Health Sciences Center, Center for Computational Mathematics, 2006. |
225
+ | AnalysisEnKF | Perform assimilation using EnKF full covariance matrix. | Evensen, Geir. Data assimilation: the ensemble Kalman filter. Vol. 2. Berlin: springer, 2009. |
226
+ | Analysis | Perform assimilation given background and observations. | Abstract class to define general methods for all assimilation steps. |
227
+
228
+ **Analysis (Abstract class for analysis methods)**
229
+
230
+ | Method | Description |
231
+ | ---------------------- | ------------------------------------------------ |
232
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
233
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
234
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
235
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
236
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
237
+
238
+ **AnalysisEnKF (Analysis EnKF full covariance matrix)**
239
+
240
+ | Method | Description |
241
+ | ---------------------- | ------------------------------------------------ |
242
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
243
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
244
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
245
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
246
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
247
+
248
+ **AnalysisEnKFBLoc (Analysis EnKF B-Loc)**
249
+
250
+ | Method | Description |
251
+ | ---------------------- | ------------------------------------------------ |
252
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
253
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
254
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
255
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
256
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
257
+
258
+ **AnalysisEnKFCholesky (EnKF implementation Cholesky)**
259
+
260
+ | Method | Description |
261
+ | ---------------------- | ------------------------------------------------ |
262
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
263
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
264
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
265
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
266
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
267
+
268
+ **AnalysisEnKFModifiedCholesky (Analysis EnKF Modified Cholesky decomposition)**
269
+
270
+ | Method | Description |
271
+ | ---------------------- | ------------------------------------------------ |
272
+ | get_precision_matrix | Returns the computed precision matrix. It takes the following parameters: <br>- **DX**: Deviation matrix.<br>- **regularization_factor**: Value used as alpha in the ridge model. |
273
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
274
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
275
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
276
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
277
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
278
+
279
+ **AnalysisEnKFNaive (Analysis EnKF Naive)**
280
+
281
+ | Method | Description |
282
+ | ---------------------- | ------------------------------------------------ |
283
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
284
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
285
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
286
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
287
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
288
+
289
+ **AnalysisEnKFShrinkagePrecision (Analysis EnKF Shrinkage Precision)**
290
+
291
+ | Method | Description |
292
+ | ---------------------- | ------------------------------------------------ |
293
+ | get_precision_matrix | Returns the computed precision matrix. It takes the following parameters: <br>- **DX**: Deviation matrix.<br>- **regularization_factor**: Value used as alpha in the ridge model. |
294
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
295
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
296
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
297
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
298
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
299
+
300
+ **AnalysisEnSRF (Analysis EnSRF)**
301
+
302
+ | Method | Description |
303
+ | ---------------------- | ------------------------------------------------ |
304
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
305
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
306
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
307
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
308
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
309
+
310
+ **AnalysisETKF (Analysis Ensemble Transform Kalman Filter (ETKF))**
311
+
312
+ | Method | Description |
313
+ | ---------------------- | ------------------------------------------------ |
314
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
315
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
316
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
317
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
318
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
319
+
320
+ **AnalysisLEnKF (Analysis LEnKF)**
321
+
322
+ | Method | Description |
323
+ | ---------------------- | ------------------------------------------------ |
324
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
325
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
326
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
327
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
328
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
329
+
330
+ **AnalysisLETKF (Analysis Local Ensemble Transform Kalman Filter (LETKF))**
331
+
332
+ | Method | Description |
333
+ | ---------------------- | ------------------------------------------------ |
334
+ | perform_assimilation | Perform the assimilation step given the background and observations. It takes the following parameters: <br>- **background**: Background object representing the background ensemble or state.<br>- **observation**: Observation object representing the observation used for assimilation. |
335
+ | get_analysis_state | Return the computed column mean of the ensemble Xa. It doesn't take any parameters. |
336
+ | inflate_ensemble | Compute the new ensemble Xa given the inflation factor. It takes the following parameter: <br>- **inflation_factor**: Double number indicating the inflation factor to be applied to the ensemble. |
337
+ | get_ensemble | Return the ensemble Xa. It doesn't take any parameters. |
338
+ | get_error_covariance | Return the computed covariance matrix of the ensemble Xa. It doesn't take any parameters. |
339
+
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ pyteda.egg-info/PKG-INFO
4
+ pyteda.egg-info/SOURCES.txt
5
+ pyteda.egg-info/dependency_links.txt
6
+ pyteda.egg-info/requires.txt
7
+ pyteda.egg-info/top_level.txt
8
+ teda/__init__.py
@@ -0,0 +1,4 @@
1
+ numpy
2
+ scipy
3
+ matplotlib
4
+ scikit-learn
@@ -0,0 +1 @@
1
+ teda
pyteda-0.1.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,14 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Thu Oct 22 00:43:05 2020
4
+
5
+ @author: ElíasN
6
+ """
7
+
8
+ # Expose main submodules as namespaces
9
+ from . import simulation
10
+ from . import analysis
11
+ from . import background
12
+ from . import models
13
+ from . import observation
14
+