Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add longitude_bnds and latitude_bnds to cmip_renaming_dict #300

Merged
merged 14 commits into from
Jun 25, 2024
Merged
2 changes: 1 addition & 1 deletion docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ v0.7.2 (unreleased)
Internal Changes
~~~~~~~~~~~~~~~~
- Added PR template (:pull:`304`). By `Julius Busecke <https://github.com/jbusecke>`

- Add `longitude_bnds` and `latitude_bnds` to `cmip_renaming_dict` (:pull:`300`). By `Joran Angevaare <https://github.com/JoranAngevaare>`

.. _whats-new.0.7.0:

Expand Down
13 changes: 13 additions & 0 deletions tests/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ def test_correct_coordinates(coord):
assert coord in list(ds_corrected.coords)


@pytest.mark.parametrize(
"bad_coord", [v for values in cmip6_renaming_dict().values() for v in values]
)
def test_renamed_coordinates(bad_coord):
xlen, ylen, zlen = (10, 5, 6)
ds = create_test_ds("xx", "yy", "zz", xlen, ylen, zlen)
# set a new variable which we want to rename
ds = ds.assign({bad_coord: ds.test})

ds_corrected = correct_coordinates(ds)
assert bad_coord not in list(ds_corrected.coords)


def test_parse_lon_lat_bounds():
lon = np.arange(0, 10)
lat = np.arange(20, 30)
Expand Down
4 changes: 3 additions & 1 deletion xmip/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def cmip6_renaming_dict():
"x": ["i", "ni", "xh", "nlon"],
"y": ["j", "nj", "yh", "nlat"],
"lev": ["deptht", "olevel", "zlev", "olev", "depth"],
"bnds": ["bnds", "axis_nbounds", "d2"],
"bnds": ["axis_nbounds", "d2"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbusecke this is the line I mentioned, so from the cmip6_renaming_dict, you were renaming bnds to bnds. But okay, I'll revert a6a5835 - maybe that is safer.

"vertex": ["vertex", "nvertex", "vertices"],
# coordinate labels
"lon": ["longitude", "nav_lon"],
Expand All @@ -44,13 +44,15 @@ def cmip6_renaming_dict():
"lon_bnds",
"x_bnds",
"vertices_longitude",
"longitude_bnds",
],
"lat_bounds": [
"bounds_lat",
"bounds_nav_lat",
"lat_bnds",
"y_bnds",
"vertices_latitude",
"latitude_bnds",
],
"time_bounds": ["time_bnds"],
}
Expand Down