Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda-env/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies:
- pywavelets
- scipy
- xarray >=2024.3.0
- xcdat >=0.7.3,<1.0.0
- xcdat >=0.9.1,<1.0.0
- xesmf >=0.8.7
- xskillscore >=0.0.20
# Testing
Expand Down
2 changes: 1 addition & 1 deletion conda-env/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:
- numpy >=2.0.0,<3.0.0
- pywavelets
- scipy
- xcdat >=0.7.3,<1.0.0
- xcdat >=0.9.1,<1.0.0
- xesmf >=0.8.7
- xskillscore >=0.0.20
# Testing
Expand Down
35 changes: 0 additions & 35 deletions e3sm_diags/driver/arm_diags_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,6 @@ def _run_diag_annual_cycle(parameter: ARMDiagsParameter) -> ARMDiagsParameter:
vars_funcs = _get_vars_funcs_for_derived_var(ds_ref, var)
target_var = list(vars_funcs.keys())[0][0]

# NOTE: The bounds dimension can be "nv", which is not
# currently recognized as a valid bounds dimension
# by xcdat. We rename it to "bnds" to make it compatible.
ds_ref = _rename_bounds_dim(ds_ref)

ds_ref_climo = ds_ref.temporal.climatology(target_var, "month")
da_ref = vars_funcs[(target_var,)](ds_ref_climo[target_var]).rename(
var
Expand Down Expand Up @@ -536,33 +531,3 @@ def _save_metrics_to_json(parameter: ARMDiagsParameter, metrics_dict: dict[str,
json.dump(metrics_dict, outfile)

logger.info(f"Metrics saved in: {abs_path}")


def _rename_bounds_dim(ds: xr.Dataset) -> xr.Dataset:
"""
Renames the bounds dimension "nv" to "bnds" in the given xarray.Dataset for
xCDAT compatibility.
This is a temporary workaround to ensure compatibility with xCDAT's bounds
handling. The bounds dimension "nv" is commonly used in datasets to
represent the number of vertices in a polygon, but xCDAT expects the
bounds dimension to be in `xcdat.bounds.VALID_BOUNDS_DIMS`. This function
renames "nv" to "bnds" to align with xCDAT's expectations.
Parameters
----------
ds : xr.Dataset
The input xarray.Dataset which may contain a bounds dimension named "nv".
Returns
-------
xr.Dataset
A new xarray.Dataset with the "nv" dimension renamed to "bnds" if it
existed; otherwise, the original dataset copy.
"""
ds_new = ds.copy()

if "nv" in ds_new.dims:
ds_new = ds_new.rename({"nv": "bnds"})

return ds_new
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies = [
"pywavelets",
"scipy",
"xarray >=2024.03.0",
"xcdat >=0.7.3,<1.0.0",
"xcdat >=0.9.1,<1.0.0",
"xesmf >=0.8.7",
"xskillscore >=0.0.20",
]
Expand Down Expand Up @@ -211,7 +211,7 @@ addopts = "--cov=e3sm_diags --cov-report term --cov-report html:tests_coverage_r
python_files = ["tests.py", "test_*.py"]
# Only run the unit tests because integration tests take a long time.
# Integration tests can be executed manually with `test.sh` or `pytest tests/integration`.
testpaths = "tests/e3sm_diags"
# testpaths = "tests/e3sm_diags"

[tool.mypy]
# Docs: https://mypy.readthedocs.io/en/stable/config_file.html
Expand Down
Loading