xeofs 2.2.4__tar.gz → 2.2.6__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.
- {xeofs-2.2.4 → xeofs-2.2.6}/PKG-INFO +13 -8
- {xeofs-2.2.4 → xeofs-2.2.6}/README.md +12 -7
- {xeofs-2.2.4 → xeofs-2.2.6}/pyproject.toml +1 -1
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/_base_model.py +10 -3
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/cca.py +20 -20
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/eof.py +3 -3
- {xeofs-2.2.4 → xeofs-2.2.6}/LICENSE +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/__init__.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/_version.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/data_container/__init__.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/data_container/data_container.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/__init__.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/_base_cross_model.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/decomposer.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/eeof.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/eof_rotator.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/gwpca.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/mca.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/mca_rotator.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/opa.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/models/rotator_factory.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/__init__.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/concatenator.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/dimension_renamer.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/list_processor.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/multi_index_converter.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/preprocessor.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/sanitizer.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/scaler.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/stacker.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/preprocessing/transformer.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/__init__.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/constants.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/data_types.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/dimension_renamer.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/distance_metrics.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/hilbert_transform.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/io.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/kernels.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/numba_utils.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/rotation.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/sanity_checks.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/statistics.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/utils/xarray_utils.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/validation/__init__.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/validation/_base_bootstrapper.py +0 -0
- {xeofs-2.2.4 → xeofs-2.2.6}/xeofs/validation/bootstrapper.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xeofs
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.6
|
|
4
4
|
Summary: Comprehensive EOF analysis in Python with xarray: A versatile, multidimensional, and scalable tool for advanced climate data analysis
|
|
5
5
|
Home-page: https://github.com/xarray-contrib/xeofs
|
|
6
6
|
License: MIT
|
|
@@ -173,13 +173,18 @@ For questions or support, please open a [Github issue](https://github.com/xarray
|
|
|
173
173
|
When using `xeofs`, kindly remember to cite the original references of the methods employed in your work. Additionally, if `xeofs` is proving useful in your research, we'd appreciate if you could acknowledge its use with the following citation:
|
|
174
174
|
|
|
175
175
|
```bibtex
|
|
176
|
-
@
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
176
|
+
@article{rieger_xeofs_2024,
|
|
177
|
+
author = {Rieger, Niclas and Levang, Samuel J.},
|
|
178
|
+
doi = {10.21105/joss.06060},
|
|
179
|
+
journal = {Journal of Open Source Software},
|
|
180
|
+
month = jan,
|
|
181
|
+
number = {93},
|
|
182
|
+
pages = {6060},
|
|
183
|
+
title = {{xeofs: Comprehensive EOF analysis in Python with xarray}},
|
|
184
|
+
url = {https://joss.theoj.org/papers/10.21105/joss.06060},
|
|
185
|
+
volume = {9},
|
|
186
|
+
year = {2024}
|
|
187
|
+
}
|
|
183
188
|
```
|
|
184
189
|
|
|
185
190
|
## Contributors
|
|
@@ -142,13 +142,18 @@ For questions or support, please open a [Github issue](https://github.com/xarray
|
|
|
142
142
|
When using `xeofs`, kindly remember to cite the original references of the methods employed in your work. Additionally, if `xeofs` is proving useful in your research, we'd appreciate if you could acknowledge its use with the following citation:
|
|
143
143
|
|
|
144
144
|
```bibtex
|
|
145
|
-
@
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
@article{rieger_xeofs_2024,
|
|
146
|
+
author = {Rieger, Niclas and Levang, Samuel J.},
|
|
147
|
+
doi = {10.21105/joss.06060},
|
|
148
|
+
journal = {Journal of Open Source Software},
|
|
149
|
+
month = jan,
|
|
150
|
+
number = {93},
|
|
151
|
+
pages = {6060},
|
|
152
|
+
title = {{xeofs: Comprehensive EOF analysis in Python with xarray}},
|
|
153
|
+
url = {https://joss.theoj.org/papers/10.21105/joss.06060},
|
|
154
|
+
volume = {9},
|
|
155
|
+
year = {2024}
|
|
156
|
+
}
|
|
152
157
|
```
|
|
153
158
|
|
|
154
159
|
## Contributors
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "xeofs"
|
|
3
|
-
version = "2.2.
|
|
3
|
+
version = "2.2.6"
|
|
4
4
|
description = "Comprehensive EOF analysis in Python with xarray: A versatile, multidimensional, and scalable tool for advanced climate data analysis"
|
|
5
5
|
authors = ["Niclas Rieger <niclasrieger@gmail.com>", "Samuel J. Levang <slevang@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -283,13 +283,13 @@ class _BaseModel(ABC):
|
|
|
283
283
|
return self.fit(data, dim, weights).transform(data, **kwargs)
|
|
284
284
|
|
|
285
285
|
def inverse_transform(
|
|
286
|
-
self, scores:
|
|
286
|
+
self, scores: DataArray, normalized: bool = True
|
|
287
287
|
) -> DataObject:
|
|
288
288
|
"""Reconstruct the original data from transformed data.
|
|
289
289
|
|
|
290
290
|
Parameters
|
|
291
291
|
----------
|
|
292
|
-
scores:
|
|
292
|
+
scores: DataArray
|
|
293
293
|
Transformed data to be reconstructed. This could be a subset
|
|
294
294
|
of the `scores` data of a fitted model, or unseen data. Must
|
|
295
295
|
have a 'mode' dimension.
|
|
@@ -303,8 +303,15 @@ class _BaseModel(ABC):
|
|
|
303
303
|
|
|
304
304
|
"""
|
|
305
305
|
if normalized:
|
|
306
|
-
|
|
306
|
+
norms = self.data["norms"].sel(mode=scores.mode)
|
|
307
|
+
scores = scores * norms
|
|
307
308
|
data_reconstructed = self._inverse_transform_algorithm(scores)
|
|
309
|
+
|
|
310
|
+
# Reconstructing the data using a single mode introduces a
|
|
311
|
+
# redundant "mode" coordinate
|
|
312
|
+
if "mode" in data_reconstructed.coords:
|
|
313
|
+
data_reconstructed = data_reconstructed.drop_vars("mode")
|
|
314
|
+
|
|
308
315
|
return self.preprocessor.inverse_transform_data(data_reconstructed)
|
|
309
316
|
|
|
310
317
|
@abstractmethod
|
|
@@ -4,13 +4,12 @@ Source: https://github.com/jameschapman19/cca_zoo
|
|
|
4
4
|
|
|
5
5
|
The original code is licensed under the MIT License.
|
|
6
6
|
|
|
7
|
-
Copyright (c) 2020
|
|
7
|
+
Copyright (c) 2020 onward James Chapman
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
from abc import abstractmethod
|
|
11
11
|
from datetime import datetime
|
|
12
|
-
from typing import
|
|
13
|
-
from typing_extensions import Self
|
|
12
|
+
from typing import Hashable, List, Sequence
|
|
14
13
|
|
|
15
14
|
import dask.array as da
|
|
16
15
|
import numpy as np
|
|
@@ -18,11 +17,13 @@ import xarray as xr
|
|
|
18
17
|
from scipy.linalg import eigh
|
|
19
18
|
from sklearn.base import BaseEstimator
|
|
20
19
|
from sklearn.utils.validation import FLOAT_DTYPES
|
|
20
|
+
from typing_extensions import Self
|
|
21
|
+
|
|
21
22
|
from xeofs.models import EOF
|
|
22
23
|
|
|
23
24
|
from .._version import __version__
|
|
24
25
|
from ..preprocessing.preprocessor import Preprocessor
|
|
25
|
-
from ..utils.data_types import
|
|
26
|
+
from ..utils.data_types import DataArray, DataList, DataObject
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
def _check_parameter_number(parameter_name: str, parameter, n_views: int):
|
|
@@ -171,6 +172,7 @@ class CCABaseModel(BaseEstimator):
|
|
|
171
172
|
view_transformed = []
|
|
172
173
|
|
|
173
174
|
for i, view in enumerate(views):
|
|
175
|
+
# NOTE: coslat weighting already happens in Preprocessor class
|
|
174
176
|
pca = EOF(n_modes=n_pca_modes[i], compute=self.compute)
|
|
175
177
|
pca.fit(view, dim=self.sample_name)
|
|
176
178
|
if self.compute:
|
|
@@ -196,20 +198,18 @@ class CCABaseModel(BaseEstimator):
|
|
|
196
198
|
cum_exp_var_ratio.isel(mode=-1).item()
|
|
197
199
|
)
|
|
198
200
|
)
|
|
199
|
-
n_modes_keep =
|
|
200
|
-
cum_exp_var_ratio
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
#
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
scores = (
|
|
210
|
-
|
|
211
|
-
.rename({"mode": self.feature_name})
|
|
212
|
-
.transpose(self.sample_name, self.feature_name)
|
|
201
|
+
n_modes_keep = (
|
|
202
|
+
cum_exp_var_ratio.where(
|
|
203
|
+
cum_exp_var_ratio <= self.variance_fraction, drop=True
|
|
204
|
+
).size
|
|
205
|
+
+ 1
|
|
206
|
+
)
|
|
207
|
+
# Take at least 2 modes
|
|
208
|
+
n_modes_keep = max(n_modes_keep, 2)
|
|
209
|
+
|
|
210
|
+
scores = pca.scores(normalized=False).isel(mode=slice(0, n_modes_keep))
|
|
211
|
+
scores = scores.rename({"mode": self.feature_name}).transpose(
|
|
212
|
+
self.sample_name, self.feature_name
|
|
213
213
|
)
|
|
214
214
|
view_transformed.append(scores)
|
|
215
215
|
return view_transformed
|
|
@@ -328,7 +328,7 @@ class CCA(CCABaseModel):
|
|
|
328
328
|
# Transform the views using the loadings
|
|
329
329
|
transformed_views = [
|
|
330
330
|
xr.dot(view, loading, dims=self.feature_name)
|
|
331
|
-
for view, loading in zip(
|
|
331
|
+
for view, loading in zip(self.data["input_data"], self.data["loadings"])
|
|
332
332
|
]
|
|
333
333
|
# Calculate the variance of each latent dimension in the transformed views
|
|
334
334
|
self.data["explained_variance"] = [
|
|
@@ -337,7 +337,7 @@ class CCA(CCABaseModel):
|
|
|
337
337
|
|
|
338
338
|
# Explained variance ratio
|
|
339
339
|
self.data["total_variance"] = [
|
|
340
|
-
view.var(self.sample_name).sum() for view in views
|
|
340
|
+
view.var(self.sample_name, ddof=1).sum() for view in views
|
|
341
341
|
]
|
|
342
342
|
|
|
343
343
|
# Calculate the explained variance ratio for each latent dimension for each view
|
|
@@ -128,12 +128,12 @@ class EOF(_BaseModel):
|
|
|
128
128
|
|
|
129
129
|
return projections
|
|
130
130
|
|
|
131
|
-
def _inverse_transform_algorithm(self, scores:
|
|
131
|
+
def _inverse_transform_algorithm(self, scores: DataArray) -> DataArray:
|
|
132
132
|
"""Reconstruct the original data from transformed data.
|
|
133
133
|
|
|
134
134
|
Parameters
|
|
135
135
|
----------
|
|
136
|
-
scores:
|
|
136
|
+
scores: DataArray
|
|
137
137
|
Transformed data to be reconstructed. This could be a subset
|
|
138
138
|
of the `scores` data of a fitted model, or unseen data. Must
|
|
139
139
|
have a 'mode' dimension.
|
|
@@ -147,7 +147,7 @@ class EOF(_BaseModel):
|
|
|
147
147
|
# Reconstruct the data
|
|
148
148
|
comps = self.data["components"].sel(mode=scores.mode)
|
|
149
149
|
|
|
150
|
-
reconstructed_data = xr.dot(comps.conj(), scores)
|
|
150
|
+
reconstructed_data = xr.dot(comps.conj(), scores, dims="mode")
|
|
151
151
|
reconstructed_data.name = "reconstructed_data"
|
|
152
152
|
|
|
153
153
|
# Enforce real output
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|