Skip to content

Commit 597c70a

Browse files
Removing NestedField tests and updating migration guide
1 parent a2706ce commit 597c70a

File tree

2 files changed

+1
-77
lines changed

2 files changed

+1
-77
lines changed

docs/user_guide/v4-migration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Version 4 of Parcels is unreleased at the moment. The information in this migrat
3939

4040
- `Field.eval()` returns an array of floats instead of a single float (related to the vectorization)
4141
- `Field.eval()` does not throw OutOfBounds or other errors
42+
- The `NestedField` class has been removed. See the Nested Grids how-to guide for how to set up Nested Grids in v4.
4243

4344
## GridSet
4445

tests-v3/test_fieldset_sampling.py

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
Geographic,
1515
Particle,
1616
ParticleSet,
17-
StatusCode,
1817
Variable,
1918
)
2019
from tests.utils import create_fieldset_global
@@ -796,82 +795,6 @@ def test_multiple_grid_addlater_error():
796795
assert fail
797796

798797

799-
@pytest.mark.v4alpha
800-
@pytest.mark.xfail(reason="Implementation of NestedFields is being reconsidered in v4.")
801-
def test_nestedfields():
802-
from parcels import NestedField
803-
804-
xdim = 10
805-
ydim = 20
806-
807-
U1 = Field(
808-
"U1",
809-
0.1 * np.ones((ydim, xdim), dtype=np.float32),
810-
lon=np.linspace(0.0, 1.0, xdim, dtype=np.float32),
811-
lat=np.linspace(0.0, 1.0, ydim, dtype=np.float32),
812-
)
813-
V1 = Field(
814-
"V1",
815-
0.2 * np.ones((ydim, xdim), dtype=np.float32),
816-
lon=np.linspace(0.0, 1.0, xdim, dtype=np.float32),
817-
lat=np.linspace(0.0, 1.0, ydim, dtype=np.float32),
818-
)
819-
U2 = Field(
820-
"U2",
821-
0.3 * np.ones((ydim, xdim), dtype=np.float32),
822-
lon=np.linspace(0.0, 2.0, xdim, dtype=np.float32),
823-
lat=np.linspace(0.0, 2.0, ydim, dtype=np.float32),
824-
)
825-
V2 = Field(
826-
"V2",
827-
0.4 * np.ones((ydim, xdim), dtype=np.float32),
828-
lon=np.linspace(0.0, 2.0, xdim, dtype=np.float32),
829-
lat=np.linspace(0.0, 2.0, ydim, dtype=np.float32),
830-
)
831-
U = NestedField("U", [U1, U2])
832-
V = NestedField("V", [V1, V2])
833-
fieldset = FieldSet(U, V)
834-
835-
P1 = Field(
836-
"P1",
837-
0.1 * np.ones((ydim, xdim), dtype=np.float32),
838-
lon=np.linspace(0.0, 1.0, xdim, dtype=np.float32),
839-
lat=np.linspace(0.0, 1.0, ydim, dtype=np.float32),
840-
)
841-
P2 = Field(
842-
"P2",
843-
0.2 * np.ones((ydim, xdim), dtype=np.float32),
844-
lon=np.linspace(0.0, 2.0, xdim, dtype=np.float32),
845-
lat=np.linspace(0.0, 2.0, ydim, dtype=np.float32),
846-
)
847-
P = NestedField("P", [P1, P2])
848-
fieldset.add_field(P)
849-
850-
def Recover(particle, fieldset, time): # pragma: no cover
851-
if particle.state == StatusCode.ErrorOutOfBounds:
852-
particle.dlon = 0
853-
particle.dlat = 0
854-
particle.ddepth = 0
855-
particle.lon = 0
856-
particle.lat = 0
857-
particle.p = 999
858-
particle.state = StatusCode.Evaluate
859-
860-
pset = ParticleSet(fieldset, pclass=pclass(), lon=[0], lat=[0.3])
861-
pset.execute(AdvectionRK4 + pset.Kernel(SampleP), runtime=2, dt=1)
862-
assert np.isclose(pset.lat[0], 0.5)
863-
assert np.isclose(pset.p[0], 0.1)
864-
pset = ParticleSet(fieldset, pclass=pclass(), lon=[0], lat=[1.1])
865-
pset.execute(AdvectionRK4 + pset.Kernel(SampleP), runtime=2, dt=1)
866-
assert np.isclose(pset.lat[0], 1.5)
867-
assert np.isclose(pset.p[0], 0.2)
868-
pset = ParticleSet(fieldset, pclass=pclass(), lon=[0], lat=[2.3])
869-
pset.execute(pset.Kernel(AdvectionRK4) + SampleP + Recover, runtime=1, dt=1)
870-
assert np.isclose(pset.lat[0], 0)
871-
assert np.isclose(pset.p[0], 999)
872-
assert np.allclose(fieldset.UV[0][0, 0, 0, 0], [0.1, 0.2])
873-
874-
875798
def test_fieldset_sampling_updating_order(tmp_zarrfile):
876799
def calc_p(t, y, x):
877800
return 10 * t + x + 0.2 * y

0 commit comments

Comments
 (0)