ESCOMP / ESCOMP/CTSM

xarray: Use Dataset.sizes instead of Dataset.dims

Open
#3,333 2 comments 2 reactions 0 assignees View on GitHub
b4b code health priority: low
Dominant language
Fortran
Stars
352
Forks
361
Avg merge
2d 21h
Merged PRs (30d)
7

Description

There are some places in the Python scripts where we use the `dims` member of Xarray Datasets in order to get dimension lengths. As of the latest `ctsm_pylib` (Python 3.13.2, Xarray 2025.1.2), this produces a warning (here produced from ctsm5.3.063):
```
modify_fsurdat.py:49: FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.
self.numurbl = self.file.dims["numurbl"]
```

We should go ahead and convert all such instances to `Dataset.sizes` so we don't have confusing failures when we eventually update Xarray to a version with the new behavior.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.