Skip to content

Commit 87277c7

Browse files
Add test with output; mark as xfail
This test is marked with xfail since the changes required to support particlefile will require a significant overhaul of the particlefile module which is out of scope for this PR
1 parent c6ea5c6 commit 87277c7

1 file changed

Lines changed: 49 additions & 2 deletions

File tree

tests/v4/test_particleset.py

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from datetime import timedelta
22

3+
import pytest
4+
35
from parcels import (
46
AdvectionEE,
57
Field,
@@ -13,7 +15,48 @@
1315
from parcels.uxgrid import UxGrid
1416

1517

16-
def test_uxstommel_gyre():
18+
@pytest.mark.parametrize("verbose_progress", [True, False])
19+
def test_uxstommelgyre_pset_execute(verbose_progress):
20+
ds = datasets_unstructured["stommel_gyre_delaunay"]
21+
grid = UxGrid(grid=ds.uxgrid, z=ds.coords["nz"])
22+
U = Field(
23+
name="U",
24+
data=ds.U,
25+
grid=grid,
26+
mesh_type="spherical",
27+
interp_method=UXPiecewiseConstantFace,
28+
)
29+
V = Field(
30+
name="V",
31+
data=ds.V,
32+
grid=grid,
33+
mesh_type="spherical",
34+
interp_method=UXPiecewiseConstantFace,
35+
)
36+
P = Field(
37+
name="P",
38+
data=ds.p,
39+
grid=grid,
40+
mesh_type="spherical",
41+
interp_method=UXPiecewiseConstantFace,
42+
)
43+
UV = VectorField(name="UV", U=U, V=V)
44+
fieldset = FieldSet([UV, UV.U, UV.V, P])
45+
pset = ParticleSet(
46+
fieldset,
47+
lon=[30.0],
48+
lat=[5.0],
49+
depth=[50.0],
50+
time=[0.0],
51+
pclass=Particle,
52+
)
53+
pset.execute(
54+
runtime=timedelta(minutes=10), dt=timedelta(seconds=60), pyfunc=AdvectionEE, verbose_progress=verbose_progress
55+
)
56+
57+
58+
@pytest.mark.xfail(reason="Output file not implemented yet")
59+
def test_uxstommelgyre_pset_execute_output():
1760
ds = datasets_unstructured["stommel_gyre_delaunay"]
1861
grid = UxGrid(grid=ds.uxgrid, z=ds.coords["nz"])
1962
U = Field(
@@ -47,4 +90,8 @@ def test_uxstommel_gyre():
4790
time=[0.0],
4891
pclass=Particle,
4992
)
50-
pset.execute(runtime=timedelta(minutes=10), dt=timedelta(seconds=60), pyfunc=AdvectionEE, verbose_progress=False)
93+
output_file = pset.ParticleFile(
94+
name="stommel_uxarray_particles.zarr", # the file name
95+
outputdt=timedelta(minutes=5), # the time step of the outputs
96+
)
97+
pset.execute(runtime=timedelta(minutes=10), dt=timedelta(seconds=60), pyfunc=AdvectionEE, output_file=output_file)

0 commit comments

Comments
 (0)