diff --git a/src/parcels/_core/spatialhash.py b/src/parcels/_core/spatialhash.py index 444710baa..c9049206f 100644 --- a/src/parcels/_core/spatialhash.py +++ b/src/parcels/_core/spatialhash.py @@ -696,7 +696,9 @@ def _spherical_face_bounds(verts): # A triangle with no area encloses nothing. Rather # than let np.linalg.solve raise on it, conver those faces' weights to NaN. weights = np.full(M.shape[:-1] + (len(_AXIS_POINTS),), np.nan) - has_area = np.abs(np.linalg.det(M)) > 1e-14 + # Faces with NaN nodes give a NaN determinant + with np.errstate(invalid="ignore"): + has_area = np.abs(np.linalg.det(M)) > 1e-14 if has_area.any(): weights[has_area] = np.linalg.solve(M[has_area], _AXIS_POINTS.T) diff --git a/tests/test_field.py b/tests/test_field.py index 7def3ca8b..872bf4bcc 100644 --- a/tests/test_field.py +++ b/tests/test_field.py @@ -90,7 +90,7 @@ def test_vectorfield_init_different_time_intervals(): dsV["timeV"] = dsV["timeV"] + np.timedelta64(1, "D") dsV["timeV"].attrs["axis"] = "T" - ds = xr.merge([dsU, dsV]) + ds = xr.merge([dsU, dsV], compat="no_conflicts") with pytest.raises(ValueError, match="Multiple time coordinates"): FieldSet.from_sgrid_conventions(ds) diff --git a/tests/test_fieldset.py b/tests/test_fieldset.py index c010f6ec4..7fd63f5c9 100644 --- a/tests/test_fieldset.py +++ b/tests/test_fieldset.py @@ -445,7 +445,7 @@ def test_vectorfields_without_time(): """Test that vector fields without a time dimension can be evaluated.""" ds1 = datasets_structured["ds_2d_left"][["U_A_grid", "V_A_grid", "grid"]].rename({"U_A_grid": "U", "V_A_grid": "V"}) ds2 = ds1.isel(time=0).drop_vars("time").rename({"U": "U_const", "V": "V_const"}) - ds = xr.merge([ds1, ds2]) + ds = xr.merge([ds1, ds2], compat="no_conflicts") fset = FieldSet.from_sgrid_conventions(ds, vector_fields={"UV_const": ("U_const", "V_const")}) fset.UV_const.eval(t=0, z=0, y=0, x=0)