Skip to content

Commit f2531bf

Browse files
[#2034] Add test for particleset.execute on unstructure stommel gyre
1 parent 1c1cbe3 commit f2531bf

2 files changed

Lines changed: 50 additions & 15 deletions

File tree

tests/v4/test_particleset.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from datetime import timedelta
2+
3+
from parcels import (
4+
AdvectionEE,
5+
Field,
6+
FieldSet,
7+
Particle,
8+
ParticleSet,
9+
UXPiecewiseConstantFace,
10+
VectorField,
11+
)
12+
from parcels._datasets.unstructured.generic import datasets as datasets_unstructured
13+
from parcels.uxgrid import UxGrid
14+
15+
16+
def test_uxstommel_gyre():
17+
ds = datasets_unstructured["stommel_gyre_delaunay"]
18+
grid = UxGrid(grid=ds.uxgrid, z=ds.coords["nz"])
19+
U = Field(
20+
name="U",
21+
data=ds.U,
22+
grid=grid,
23+
mesh_type="spherical",
24+
interp_method=UXPiecewiseConstantFace,
25+
)
26+
V = Field(
27+
name="V",
28+
data=ds.V,
29+
grid=grid,
30+
mesh_type="spherical",
31+
interp_method=UXPiecewiseConstantFace,
32+
)
33+
P = Field(
34+
name="P",
35+
data=ds.p,
36+
grid=grid,
37+
mesh_type="spherical",
38+
interp_method=UXPiecewiseConstantFace,
39+
)
40+
UV = VectorField(name="UV", U=U, V=V)
41+
fieldset = FieldSet([UV, UV.U, UV.V, P])
42+
pset = ParticleSet(
43+
fieldset,
44+
lon=[30.0],
45+
lat=[5.0],
46+
depth=[50.0],
47+
time=[0.0], # important otherwise initialization appears to take forever?
48+
pclass=Particle,
49+
)
50+
pset.execute(endtime=timedelta(minutes=10), dt=timedelta(seconds=60), pyfunc=AdvectionEE, verbose_progress=False)

tests/v4/test_uxarray_fieldset.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from datetime import timedelta
2-
31
import pytest
42
import uxarray as ux
53

@@ -104,19 +102,6 @@ def test_set_interp_methods(ds_fesom_channel, uv_fesom_channel):
104102
fieldset.V.interp_method = UXPiecewiseConstantFace
105103

106104

107-
@pytest.mark.skip(reason="ParticleSet.__init__ needs major refactoring")
108-
def test_fesom_channel(ds_fesom_channel, uvw_fesom_channel):
109-
fieldset = FieldSet([uvw_fesom_channel, uvw_fesom_channel.U, uvw_fesom_channel.V, uvw_fesom_channel.W])
110-
111-
# Check that the fieldset has the expected properties
112-
assert (fieldset.U == ds_fesom_channel.U).all()
113-
assert (fieldset.V == ds_fesom_channel.V).all()
114-
assert (fieldset.W == ds_fesom_channel.W).all()
115-
116-
pset = ParticleSet(fieldset, pclass=Particle)
117-
pset.execute(endtime=timedelta(days=1), dt=timedelta(hours=1))
118-
119-
120105
def test_fesom2_square_delaunay_uniform_z_coordinate_eval():
121106
"""
122107
Test the evaluation of a fieldset with a FESOM2 square Delaunay grid and uniform z-coordinate.

0 commit comments

Comments
 (0)