Skip to content

Commit c9bef4e

Browse files
committed
Fix xcdat bounds dim issue with v0.9.1
1 parent 6ce9b41 commit c9bef4e

File tree

4 files changed

+4
-39
lines changed

4 files changed

+4
-39
lines changed

conda-env/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies:
2525
- pywavelets
2626
- scipy
2727
- xarray >=2024.3.0
28-
- xcdat >=0.7.3,<1.0.0
28+
- xcdat >=0.9.1,<1.0.0
2929
- xesmf >=0.8.7
3030
- xskillscore >=0.0.20
3131
# Testing

conda-env/dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies:
2222
- numpy >=2.0.0,<3.0.0
2323
- pywavelets
2424
- scipy
25-
- xcdat >=0.7.3,<1.0.0
25+
- xcdat >=0.9.1,<1.0.0
2626
- xesmf >=0.8.7
2727
- xskillscore >=0.0.20
2828
# Testing

e3sm_diags/driver/arm_diags_driver.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,6 @@ def _run_diag_annual_cycle(parameter: ARMDiagsParameter) -> ARMDiagsParameter:
279279
vars_funcs = _get_vars_funcs_for_derived_var(ds_ref, var)
280280
target_var = list(vars_funcs.keys())[0][0]
281281

282-
# NOTE: The bounds dimension can be "nv", which is not
283-
# currently recognized as a valid bounds dimension
284-
# by xcdat. We rename it to "bnds" to make it compatible.
285-
ds_ref = _rename_bounds_dim(ds_ref)
286-
287282
ds_ref_climo = ds_ref.temporal.climatology(target_var, "month")
288283
da_ref = vars_funcs[(target_var,)](ds_ref_climo[target_var]).rename(
289284
var
@@ -536,33 +531,3 @@ def _save_metrics_to_json(parameter: ARMDiagsParameter, metrics_dict: dict[str,
536531
json.dump(metrics_dict, outfile)
537532

538533
logger.info(f"Metrics saved in: {abs_path}")
539-
540-
541-
def _rename_bounds_dim(ds: xr.Dataset) -> xr.Dataset:
542-
"""
543-
Renames the bounds dimension "nv" to "bnds" in the given xarray.Dataset for
544-
xCDAT compatibility.
545-
546-
This is a temporary workaround to ensure compatibility with xCDAT's bounds
547-
handling. The bounds dimension "nv" is commonly used in datasets to
548-
represent the number of vertices in a polygon, but xCDAT expects the
549-
bounds dimension to be in `xcdat.bounds.VALID_BOUNDS_DIMS`. This function
550-
renames "nv" to "bnds" to align with xCDAT's expectations.
551-
552-
Parameters
553-
----------
554-
ds : xr.Dataset
555-
The input xarray.Dataset which may contain a bounds dimension named "nv".
556-
557-
Returns
558-
-------
559-
xr.Dataset
560-
A new xarray.Dataset with the "nv" dimension renamed to "bnds" if it
561-
existed; otherwise, the original dataset copy.
562-
"""
563-
ds_new = ds.copy()
564-
565-
if "nv" in ds_new.dims:
566-
ds_new = ds_new.rename({"nv": "bnds"})
567-
568-
return ds_new

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies = [
4343
"pywavelets",
4444
"scipy",
4545
"xarray >=2024.03.0",
46-
"xcdat >=0.7.3,<1.0.0",
46+
"xcdat >=0.9.1,<1.0.0",
4747
"xesmf >=0.8.7",
4848
"xskillscore >=0.0.20",
4949
]
@@ -211,7 +211,7 @@ addopts = "--cov=e3sm_diags --cov-report term --cov-report html:tests_coverage_r
211211
python_files = ["tests.py", "test_*.py"]
212212
# Only run the unit tests because integration tests take a long time.
213213
# Integration tests can be executed manually with `test.sh` or `pytest tests/integration`.
214-
testpaths = "tests/e3sm_diags"
214+
# testpaths = "tests/e3sm_diags"
215215

216216
[tool.mypy]
217217
# Docs: https://mypy.readthedocs.io/en/stable/config_file.html

0 commit comments

Comments
 (0)