|
8 | 8 |
|
9 | 9 | from parcels import Field, ParticleFile, ParticleSet, VectorField, XGrid |
10 | 10 | from parcels._core.fieldset import CalendarError, FieldSet, _datetime_to_msg |
11 | | -from parcels._datasets.structured.circulation_models import datasets as datasets_circulation_models |
12 | 11 | from parcels._datasets.structured.generic import T as T_structured |
13 | 12 | from parcels._datasets.structured.generic import datasets as datasets_structured |
14 | 13 | from parcels._datasets.structured.generic import datasets_sgrid |
@@ -243,76 +242,6 @@ def test_fieldset_add_field_after_pset(): |
243 | 242 | ... |
244 | 243 |
|
245 | 244 |
|
246 | | -_COPERNICUS_DATASETS = [ |
247 | | - datasets_circulation_models["ds_copernicusmarine"], |
248 | | - datasets_circulation_models["ds_copernicusmarine_waves"], |
249 | | -] |
250 | | - |
251 | | - |
252 | | -@pytest.mark.parametrize("ds", _COPERNICUS_DATASETS) |
253 | | -def test_fieldset_from_copernicusmarine(ds, caplog): |
254 | | - fieldset = FieldSet.from_copernicusmarine(ds) |
255 | | - assert "U" in fieldset.fields |
256 | | - assert "V" in fieldset.fields |
257 | | - assert "UV" in fieldset.fields |
258 | | - assert "renamed it to 'U'" in caplog.text |
259 | | - assert "renamed it to 'V'" in caplog.text |
260 | | - |
261 | | - |
262 | | -@pytest.mark.parametrize("ds", [datasets_circulation_models["ds_copernicusmarine"].copy()]) |
263 | | -def test_fieldset_from_copernicusmarine_missing_axis(ds, caplog): |
264 | | - del ds["latitude"].attrs["axis"] |
265 | | - |
266 | | - with pytest.raises( |
267 | | - ValueError, |
268 | | - match="Dataset missing CF compliant metadata for axes " |
269 | | - ".*. Expected 'axis' attribute to be set " |
270 | | - "on all dimension axes .*. " |
271 | | - "HINT: Add xarray metadata attribute 'axis' to dimension .*", |
272 | | - ): |
273 | | - FieldSet.from_copernicusmarine(ds) |
274 | | - |
275 | | - |
276 | | -def test_fieldset_from_copernicusmarine_no_currents(caplog): |
277 | | - ds = datasets_circulation_models["ds_copernicusmarine"].cf.drop_vars( |
278 | | - ["eastward_sea_water_velocity", "northward_sea_water_velocity"] |
279 | | - ) |
280 | | - fieldset = FieldSet.from_copernicusmarine(ds) |
281 | | - assert "U" not in fieldset.fields |
282 | | - assert "V" not in fieldset.fields |
283 | | - assert "UV" not in fieldset.fields |
284 | | - assert caplog.text == "" |
285 | | - |
286 | | - |
287 | | -@pytest.mark.parametrize("ds", _COPERNICUS_DATASETS) |
288 | | -def test_fieldset_from_copernicusmarine_no_logs(ds, caplog): |
289 | | - ds = ds.copy() |
290 | | - zeros = xr.zeros_like(list(ds.data_vars.values())[0]) |
291 | | - ds["U"] = zeros |
292 | | - ds["V"] = zeros |
293 | | - |
294 | | - fieldset = FieldSet.from_copernicusmarine(ds) |
295 | | - assert "U" in fieldset.fields |
296 | | - assert "V" in fieldset.fields |
297 | | - assert "UV" in fieldset.fields |
298 | | - assert caplog.text == "" |
299 | | - |
300 | | - |
301 | | -def test_fieldset_from_copernicusmarine_with_W(caplog): |
302 | | - ds = datasets_circulation_models["ds_copernicusmarine"] |
303 | | - ds = ds.copy() |
304 | | - ds["wo"] = ds["uo"] |
305 | | - ds["wo"].attrs["standard_name"] = "vertical_sea_water_velocity" |
306 | | - |
307 | | - fieldset = FieldSet.from_copernicusmarine(ds) |
308 | | - assert "U" in fieldset.fields |
309 | | - assert "V" in fieldset.fields |
310 | | - assert "W" in fieldset.fields |
311 | | - assert "UV" in fieldset.fields |
312 | | - assert "UVW" in fieldset.fields |
313 | | - assert "renamed it to 'W'" in caplog.text |
314 | | - |
315 | | - |
316 | 245 | def test_fieldset_from_fesom2(): |
317 | 246 | ds = datasets_unstructured["stommel_gyre_delaunay"] |
318 | 247 | fieldset = FieldSet.from_fesom2(ds) |
|
0 commit comments