xeofs 2.3.0__tar.gz → 2.3.2__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.
Files changed (47) hide show
  1. {xeofs-2.3.0 → xeofs-2.3.2}/PKG-INFO +1 -1
  2. {xeofs-2.3.0 → xeofs-2.3.2}/pyproject.toml +1 -1
  3. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/_base_cross_model.py +16 -2
  4. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/_base_model.py +5 -0
  5. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/mca.py +4 -8
  6. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/transformer.py +9 -4
  7. {xeofs-2.3.0 → xeofs-2.3.2}/LICENSE +0 -0
  8. {xeofs-2.3.0 → xeofs-2.3.2}/README.md +0 -0
  9. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/__init__.py +0 -0
  10. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/_version.py +0 -0
  11. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/data_container/__init__.py +0 -0
  12. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/data_container/data_container.py +0 -0
  13. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/__init__.py +0 -0
  14. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/cca.py +0 -0
  15. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/decomposer.py +0 -0
  16. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/eeof.py +0 -0
  17. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/eof.py +0 -0
  18. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/eof_rotator.py +0 -0
  19. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/gwpca.py +0 -0
  20. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/mca_rotator.py +0 -0
  21. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/opa.py +0 -0
  22. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/models/rotator_factory.py +0 -0
  23. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/__init__.py +0 -0
  24. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/concatenator.py +0 -0
  25. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/dimension_renamer.py +0 -0
  26. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/list_processor.py +0 -0
  27. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/multi_index_converter.py +0 -0
  28. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/preprocessor.py +0 -0
  29. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/sanitizer.py +0 -0
  30. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/scaler.py +0 -0
  31. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/preprocessing/stacker.py +0 -0
  32. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/__init__.py +0 -0
  33. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/constants.py +0 -0
  34. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/data_types.py +0 -0
  35. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/dimension_renamer.py +0 -0
  36. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/distance_metrics.py +0 -0
  37. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/hilbert_transform.py +0 -0
  38. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/io.py +0 -0
  39. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/kernels.py +0 -0
  40. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/numba_utils.py +0 -0
  41. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/rotation.py +0 -0
  42. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/sanity_checks.py +0 -0
  43. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/statistics.py +0 -0
  44. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/utils/xarray_utils.py +0 -0
  45. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/validation/__init__.py +0 -0
  46. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/validation/_base_bootstrapper.py +0 -0
  47. {xeofs-2.3.0 → xeofs-2.3.2}/xeofs/validation/bootstrapper.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xeofs
3
- Version: 2.3.0
3
+ Version: 2.3.2
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "xeofs"
3
- version = "2.3.0"
3
+ version = "2.3.2"
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"
@@ -214,7 +214,15 @@ class _BaseCrossModel(ABC):
214
214
  # Preprocess data2
215
215
  data2 = self.preprocessor2.transform(data2)
216
216
 
217
- return self._transform_algorithm(data1, data2)
217
+ data = self._transform_algorithm(data1, data2)
218
+ data_list = []
219
+ if data1 is not None:
220
+ data1 = self.preprocessor1.inverse_transform_scores_unseen(data["data1"])
221
+ data_list.append(data1)
222
+ if data2 is not None:
223
+ data2 = self.preprocessor2.inverse_transform_scores_unseen(data["data2"])
224
+ data_list.append(data2)
225
+ return data_list
218
226
 
219
227
  def inverse_transform(
220
228
  self, scores1: DataArray, scores2: DataArray
@@ -240,6 +248,12 @@ class _BaseCrossModel(ABC):
240
248
  Reconstructed data of right field.
241
249
 
242
250
  """
251
+ # Handle scalar mode in xr.dot
252
+ if "mode" not in scores1.dims:
253
+ scores1 = scores1.expand_dims("mode")
254
+ if "mode" not in scores2.dims:
255
+ scores2 = scores2.expand_dims("mode")
256
+
243
257
  data1, data2 = self._inverse_transform_algorithm(scores1, scores2)
244
258
 
245
259
  # Unstack and rescale the data
@@ -265,7 +279,7 @@ class _BaseCrossModel(ABC):
265
279
  @abstractmethod
266
280
  def _transform_algorithm(
267
281
  self, data1: Optional[DataArray] = None, data2: Optional[DataArray] = None
268
- ) -> Sequence[DataArray]:
282
+ ) -> Dict[str, DataArray]:
269
283
  """
270
284
  Transform the preprocessed data. This method needs to be implemented in the respective
271
285
  subclass.
@@ -305,6 +305,11 @@ class _BaseModel(ABC):
305
305
  if normalized:
306
306
  norms = self.data["norms"].sel(mode=scores.mode)
307
307
  scores = scores * norms
308
+
309
+ # Handle scalar mode in xr.dot
310
+ if "mode" not in scores.dims:
311
+ scores = scores.expand_dims("mode")
312
+
308
313
  data_reconstructed = self._inverse_transform_algorithm(scores)
309
314
 
310
315
  # Reconstructing the data using a single mode introduces a
@@ -237,25 +237,21 @@ class MCA(_BaseCrossModel):
237
237
 
238
238
  def _transform_algorithm(
239
239
  self, data1: Optional[DataArray] = None, data2: Optional[DataArray] = None
240
- ) -> Sequence[DataArray]:
241
- results = []
240
+ ) -> Dict[str, DataArray]:
241
+ results = {}
242
242
  if data1 is not None:
243
243
  # Project data onto singular vectors
244
244
  comps1 = self.data["components1"]
245
245
  norm1 = self.data["norm1"]
246
246
  scores1 = xr.dot(data1, comps1) / norm1
247
- # Inverse transform scores
248
- scores1 = self.preprocessor1.inverse_transform_scores(scores1)
249
- results.append(scores1)
247
+ results["data1"] = scores1
250
248
 
251
249
  if data2 is not None:
252
250
  # Project data onto singular vectors
253
251
  comps2 = self.data["components2"]
254
252
  norm2 = self.data["norm2"]
255
253
  scores2 = xr.dot(data2, comps2) / norm2
256
- # Inverse transform scores
257
- scores2 = self.preprocessor2.inverse_transform_scores(scores2)
258
- results.append(scores2)
254
+ results["data2"] = scores2
259
255
 
260
256
  return results
261
257
 
@@ -96,14 +96,19 @@ class Transformer(BaseEstimator, TransformerMixin, ABC):
96
96
  ds = data
97
97
  else:
98
98
  # Convert DataArray to Dataset
99
+ coords = {}
100
+ data_vars = {}
99
101
  if data.name in data.coords:
100
102
  # Convert a coord-like DataArray to Dataset and note multiindexes
101
103
  if isinstance(data.to_index(), pd.MultiIndex):
102
104
  multiindexes[data.name] = [n for n in data.to_index().names]
103
- # Make sure the DataArray has some name so we can create a string mapping
104
- elif data.name is None:
105
- data.name = key
106
- ds = xr.Dataset(data_vars={data.name: data})
105
+ coords[data.name] = data
106
+ else:
107
+ # Make sure the DataArray has some name so we can create a string mapping
108
+ if data.name is None:
109
+ data.name = key
110
+ data_vars[data.name] = data
111
+ ds = xr.Dataset(data_vars=data_vars, coords=coords)
107
112
  name_map = data.name
108
113
 
109
114
  # Drop multiindexes and record for later
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