|
1 | 1 | from datetime import timedelta |
2 | 2 |
|
| 3 | +import pytest |
| 4 | + |
3 | 5 | from parcels import ( |
4 | 6 | AdvectionEE, |
5 | 7 | Field, |
|
13 | 15 | from parcels.uxgrid import UxGrid |
14 | 16 |
|
15 | 17 |
|
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(): |
17 | 60 | ds = datasets_unstructured["stommel_gyre_delaunay"] |
18 | 61 | grid = UxGrid(grid=ds.uxgrid, z=ds.coords["nz"]) |
19 | 62 | U = Field( |
@@ -47,4 +90,8 @@ def test_uxstommel_gyre(): |
47 | 90 | time=[0.0], |
48 | 91 | pclass=Particle, |
49 | 92 | ) |
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