Skip to content

Commit 5436136

Browse files
Adding unit test for meridional advection on curvilinear grid
To test that the spherical mesh conversion leads to the expected meridional velocity
1 parent 46ffe34 commit 5436136

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_advection.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,31 @@ def test_nemo_curvilinear_fieldset():
456456
np.testing.assert_allclose(pset.lat, latp, atol=1e-1)
457457

458458

459+
def test_nemo_curvilinear_with_vvel():
460+
"""Testing that a constant meridional velocity field in a NEMO curvilinear grid
461+
results in correct particle movement.
462+
Only works in Southern hemisphere (away from the tripolar rotated grid).
463+
"""
464+
data_folder = parcels.download_example_dataset("NemoCurvilinear_data")
465+
ds_fields = xr.open_mfdataset(
466+
data_folder.glob("*.nc4"),
467+
data_vars="minimal",
468+
coords="minimal",
469+
compat="override",
470+
)
471+
ds_fields = ds_fields.isel(time=0, z_a=0, z=0, drop=True)
472+
vvel = 0.5 # m/s
473+
ds_fields["V"].data[:] = vvel # set a constant meridional velocity
474+
fieldset = parcels.FieldSet.from_nemo(ds_fields)
475+
476+
lonp, latp = 30, -70
477+
pset = parcels.ParticleSet(fieldset, lon=lonp, lat=latp)
478+
pset.execute(AdvectionEE, runtime=np.timedelta64(10, "D"), dt=np.timedelta64(1, "D"))
479+
480+
v = (pset.lat - latp) / pset.time * 1852 * 60
481+
np.testing.assert_allclose(v, vvel, atol=1e-5)
482+
483+
459484
@pytest.mark.parametrize("kernel", [AdvectionRK4, AdvectionRK4_3D])
460485
def test_nemo_3D_curvilinear_fieldset(kernel):
461486
data_folder = parcels.download_example_dataset("NemoNorthSeaORCA025-N006_data")

0 commit comments

Comments
 (0)