Skip to content

Commit 68642db

Browse files
committed
Fix xcdat bounds dim issue with v0.9.1
1 parent 0811305 commit 68642db

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
@@ -278,11 +278,6 @@ def _run_diag_annual_cycle(parameter: ARMDiagsParameter) -> ARMDiagsParameter:
278278
vars_funcs = _get_vars_funcs_for_derived_var(ds_ref, var)
279279
target_var = list(vars_funcs.keys())[0][0]
280280

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

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