Skip to content

Commit 17e9bb7

Browse files
committed
fix drifter depth test
1 parent a9af0da commit 17e9bb7

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

tests/instruments/test_drifter.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import numpy as np
77
import xarray as xr
8-
from parcels import FieldSet
98

9+
from parcels import FieldSet
1010
from virtualship.instruments.drifter import Drifter, DrifterInstrument
1111
from virtualship.models import Location, Spacetime
1212
from virtualship.models.expedition import Waypoint
@@ -111,15 +111,16 @@ def test_simulate_drifters(tmpdir) -> None:
111111

112112
def test_drifter_depths(tmpdir) -> None:
113113
CONST_TEMPERATURE = 1.0 # constant temperature in fieldset
114+
DEPTH_FACTOR = 3.0 # factor to multiply surface values by at depth for test
114115

115116
v = np.full((2, 2, 2, 2), 1.0)
116117
u = np.full((2, 2, 2, 2), 1.0)
117118
t = np.full((2, 2, 2, 2), CONST_TEMPERATURE)
118119

119120
# different values at depth (random)
120-
v[:, -1, :, :] = 1.0 * np.random.randint(0, 10)
121-
u[:, -1, :, :] = 1.0 * np.random.randint(0, 10)
122-
t[:, -1, :, :] = CONST_TEMPERATURE * np.random.randint(0, 10)
121+
v[:, -1, :, :] = 1.0 * DEPTH_FACTOR
122+
u[:, -1, :, :] = 1.0 * DEPTH_FACTOR
123+
t[:, -1, :, :] = CONST_TEMPERATURE * DEPTH_FACTOR
123124

124125
fieldset = FieldSet.from_data(
125126
{"V": v, "U": u, "T": t},
@@ -184,6 +185,9 @@ def test_drifter_depths(tmpdir) -> None:
184185
"Depth drifter depth should be constant"
185186
)
186187

188+
if not drifter_surface.temperature[0] != drifter_depth.temperature[0]:
189+
breakpoint()
190+
187191
assert drifter_surface.temperature[0] != drifter_depth.temperature[0], (
188192
"Surface and deeper drifter should have different temperature measurements"
189193
)

0 commit comments

Comments
 (0)