File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,10 @@ def from_copernicusmarine(ds: xr.Dataset):
207207 expected_axes = set ("XYZT" ) # TODO: Update after we have support for 2D spatial fields
208208 if missing_axes := (expected_axes - set (ds .cf .axes )):
209209 raise ValueError (
210- f"Dataset missing axes { missing_axes } to have coordinates for all { expected_axes } axes according to CF conventions."
210+ f"Dataset missing CF compliant metadata for axes "
211+ f"{ missing_axes } . Expected 'axis' attribute to be set "
212+ f"on all dimension axes { expected_axes } . "
213+ "HINT: Add xarray metadata attribute 'axis' to dimension - e.g., ds['lat'].attrs['axis'] = 'Y'"
211214 )
212215
213216 ds = _rename_coords_copernicusmarine (ds )
Original file line number Diff line number Diff line change @@ -243,6 +243,20 @@ def test_fieldset_from_copernicusmarine(ds, caplog):
243243 assert "renamed it to 'V'" in caplog .text
244244
245245
246+ @pytest .mark .parametrize ("ds" , [datasets_circulation_models ["ds_copernicusmarine" ].copy ()])
247+ def test_fieldset_from_copernicusmarine_missing_axis (ds , caplog ):
248+ del ds ["latitude" ].attrs ["axis" ]
249+
250+ with pytest .raises (
251+ ValueError ,
252+ match = "Dataset missing CF compliant metadata for axes "
253+ ".*. Expected 'axis' attribute to be set "
254+ "on all dimension axes .*. "
255+ "HINT: Add xarray metadata attribute 'axis' to dimension .*" ,
256+ ):
257+ FieldSet .from_copernicusmarine (ds )
258+
259+
246260def test_fieldset_from_copernicusmarine_no_currents (caplog ):
247261 ds = datasets_circulation_models ["ds_copernicusmarine" ].cf .drop_vars (
248262 ["eastward_sea_water_velocity" , "northward_sea_water_velocity" ]
You can’t perform that action at this time.
0 commit comments