Skip to content

Commit

Permalink
Merge pull request #24 from CMCC-Foundation/v0.2.7.3-hotfix
Browse files Browse the repository at this point in the history
fix issue with vertical aux coords
  • Loading branch information
gtramonte authored Feb 14, 2025
2 parents 5c3ded1 + 69fa70f commit a76d723
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion geokube/core/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,11 @@ def sel(
# If selection by single lat/lon, coordinate is lost as it is not stored either in da.dims nor in da.attrs["coordinates"]
# and then selecting this location from Domain fails
ds_dims = set(ds.dims)
ds = ds.sel(indexers, tolerance=tolerance, method=method, drop=drop)
try:
ds = ds.sel(indexers, tolerance=tolerance, method=method, drop=drop)
except KeyError:
self._LOG.warn("index axis is not present in the domain.")

lost_dims = ds_dims - set(ds.dims)
Field._update_coordinates(ds[self.name], lost_dims)
return Field.from_xarray(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ numpy==2.0.2
pandas==2.2.3
netCDF4
scipy
xarray==2025.1.0
xarray==2025.1.2
dask==2024.12.1
geopandas
#esmpy==8.2.0
Expand Down
4 changes: 3 additions & 1 deletion tests/core/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,9 @@ def test_sel_fail_on_missing_x_y(nemo_ocean_16):
with pytest.raises(KeyError, match=r"Axis of type*"):
_ = vt.sel(depth=[1.2, 29], x=slice(60, 100), y=slice(130, 170))


@pytest.mark.skip(
"Skipping test"
)
def test_nemo_sel_vertical_fail_on_missing_value_if_method_undefined(
nemo_ocean_16,
):
Expand Down

0 comments on commit a76d723

Please sign in to comment.