|
6 | 6 | import pytest |
7 | 7 | import xarray as xr |
8 | 8 |
|
9 | | -from parcels import Field, VectorField, XGrid |
| 9 | +from parcels import Field, ParticleFile, ParticleSet, VectorField, XGrid |
10 | 10 | from parcels._core.fieldset import CalendarError, FieldSet, _datetime_to_msg |
11 | 11 | from parcels._datasets.structured.circulation_models import datasets as datasets_circulation_models |
12 | 12 | from parcels._datasets.structured.generic import T as T_structured |
@@ -94,6 +94,21 @@ def test_fieldset_gridset(fieldset): |
94 | 94 | assert len(fieldset.gridset) == 2 |
95 | 95 |
|
96 | 96 |
|
| 97 | +def test_fieldset_no_UV(tmp_zarrfile): |
| 98 | + grid = XGrid.from_dataset(ds, mesh="flat") |
| 99 | + fieldset = FieldSet([Field("P", ds["U_A_grid"], grid)]) |
| 100 | + |
| 101 | + def SampleP(particles, fieldset): |
| 102 | + particles.dlon += fieldset.P[particles] |
| 103 | + |
| 104 | + pset = ParticleSet(fieldset, lon=0, lat=0) |
| 105 | + ofile = ParticleFile(tmp_zarrfile, outputdt=np.timedelta64(1, "s")) |
| 106 | + pset.execute(SampleP, runtime=np.timedelta64(1, "s"), dt=np.timedelta64(1, "s"), output_file=ofile) |
| 107 | + |
| 108 | + ds_out = xr.open_zarr(tmp_zarrfile) |
| 109 | + assert ds_out["lon"].shape == (1, 2) |
| 110 | + |
| 111 | + |
97 | 112 | @pytest.mark.parametrize("ds", [pytest.param(ds, id=k) for k, ds in datasets_structured.items()]) |
98 | 113 | def test_fieldset_from_structured_generic_datasets(ds): |
99 | 114 | grid = XGrid.from_dataset(ds, mesh="flat") |
|
0 commit comments