climate-ref-pmp 0.6.0__tar.gz → 0.6.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.
Files changed (29) hide show
  1. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/PKG-INFO +1 -1
  2. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/pyproject.toml +1 -1
  3. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/diagnostics/variability_modes.py +64 -0
  4. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/.gitignore +0 -0
  5. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/LICENCE +0 -0
  6. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/NOTICE +0 -0
  7. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/README.md +0 -0
  8. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/conftest.py +0 -0
  9. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/__init__.py +0 -0
  10. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/dataset_registry/pmp_climatology.txt +0 -0
  11. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/diagnostics/__init__.py +0 -0
  12. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/diagnostics/annual_cycle.py +0 -0
  13. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/diagnostics/enso.py +0 -0
  14. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/drivers/enso_driver.py +0 -0
  15. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/params/pmp_param_MoV-psl.py +0 -0
  16. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/params/pmp_param_MoV-ts.py +0 -0
  17. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/params/pmp_param_annualcycle_1-clims.py +0 -0
  18. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/params/pmp_param_annualcycle_2-metrics.py +0 -0
  19. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/pmp_driver.py +0 -0
  20. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/py.typed +0 -0
  21. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/requirements/conda-lock.yml +0 -0
  22. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/src/climate_ref_pmp/requirements/environment.yml +0 -0
  23. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/tests/integration/test_diagnostics.py +0 -0
  24. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/tests/unit/conftest.py +0 -0
  25. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/tests/unit/test_annual_cycle.py +0 -0
  26. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/tests/unit/test_enso.py +0 -0
  27. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/tests/unit/test_pmp_driver.py +0 -0
  28. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/tests/unit/test_provider.py +0 -0
  29. {climate_ref_pmp-0.6.0 → climate_ref_pmp-0.6.1}/tests/unit/test_variability_modes.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: climate-ref-pmp
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: PMP diagnostic provider for the Rapid Evaluation Framework
5
5
  Author-email: Jiwoo Lee <jwlee@llnl.gov>, Jared Lewis <jared.lewis@climate-resource.com>
6
6
  License-Expression: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "climate-ref-pmp"
3
- version = "0.6.0"
3
+ version = "0.6.1"
4
4
  description = "PMP diagnostic provider for the Rapid Evaluation Framework"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -1,4 +1,6 @@
1
1
  from collections.abc import Iterable
2
+ from pathlib import Path
3
+ from typing import Any, Union
2
4
 
3
5
  from loguru import logger
4
6
 
@@ -171,6 +173,8 @@ class ExtratropicalModesOfVariability(CommandLineDiagnostic):
171
173
  logger.warning(f"A single cmec output file not found: {results_files}")
172
174
  return ExecutionResult.build_from_failure(definition)
173
175
 
176
+ clean_up_json(results_files[0])
177
+
174
178
  # Find the other outputs
175
179
  png_files = [definition.as_relative_path(f) for f in definition.output_directory.glob("*.png")]
176
180
  data_files = [definition.as_relative_path(f) for f in definition.output_directory.glob("*.nc")]
@@ -200,3 +204,63 @@ class ExtratropicalModesOfVariability(CommandLineDiagnostic):
200
204
  cmec_output_bundle=cmec_output_bundle,
201
205
  cmec_metric_bundle=cmec_metric_bundle,
202
206
  )
207
+
208
+
209
+ def clean_up_json(json_file: Union[str, Path]) -> None:
210
+ """
211
+ Clean up the JSON file by removing unnecessary fields.
212
+
213
+ Parameters
214
+ ----------
215
+ json_file : str or Path
216
+ Path to the JSON file to clean up.
217
+ """
218
+ import json
219
+
220
+ with open(str(json_file)) as f:
221
+ data = json.load(f)
222
+
223
+ # Remove null values from the JSON data
224
+ data = remove_null_values(data)
225
+
226
+ with open(str(json_file), "w") as f:
227
+ json.dump(data, f, indent=4)
228
+
229
+ # Log the cleanup action
230
+ logger.debug(f"Cleaned up JSON file: {json_file}")
231
+ logger.info("JSON file cleaned up successfully.")
232
+
233
+
234
+ def remove_null_values(data: Union[dict[Any, Any], list[Any], Any]) -> Union[dict[Any, Any], list[Any], Any]:
235
+ """
236
+ Recursively removes keys with null (None) values from a dictionary or list.
237
+
238
+ Parameters
239
+ ----------
240
+ data : dict, list, or Any
241
+ The JSON-like data structure to process. It can be a dictionary, a list,
242
+ or any other type of data.
243
+
244
+ Returns
245
+ -------
246
+ dict, list, or Any
247
+ A new data structure with null values removed. If the input is a dictionary,
248
+ keys with `None` values are removed. If the input is a list, items are
249
+ recursively processed to remove `None` values. For other types, the input
250
+ is returned unchanged.
251
+
252
+ Examples
253
+ --------
254
+ >>> data = {
255
+ ... "key1": None,
256
+ ... "key2": {"subkey1": 123, "subkey2": None},
257
+ ... "key3": [None, 456, {"subkey3": None}],
258
+ ... }
259
+ >>> remove_null_values(data)
260
+ {'key2': {'subkey1': 123}, 'key3': [456, {}]}
261
+ """
262
+ if isinstance(data, dict):
263
+ return {key: remove_null_values(value) for key, value in data.items() if value is not None}
264
+ if isinstance(data, list):
265
+ return [remove_null_values(item) for item in data if item is not None]
266
+ return data
File without changes
File without changes