Skip to content

Commit 6c7189c

Browse files
committed
throw error where waypoint is too shallow for Argo
1 parent 8c2dbce commit 6c7189c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/virtualship/instruments/argo_float.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ def simulate(self, measurements, out_path) -> None:
187187
OUTPUT_DT = timedelta(minutes=5)
188188
ENDTIME = None
189189

190-
# TODO: insert checker that none of the waypoints are under 50m depth; if so, raise error.
191-
192190
if len(measurements) == 0:
193191
print(
194192
"No Argo floats provided. Parcels currently crashes when providing an empty particle set, so no argo floats simulation will be done and no files will be created."
@@ -198,6 +196,24 @@ def simulate(self, measurements, out_path) -> None:
198196

199197
fieldset = self.load_input_data()
200198

199+
breakpoint()
200+
201+
shallow_waypoints = {}
202+
for i, m in enumerate(measurements):
203+
loc_bathy = fieldset.bathymetry.eval(
204+
time=0,
205+
z=0,
206+
y=m.spacetime.location.lat,
207+
x=m.spacetime.location.lon,
208+
)
209+
if abs(loc_bathy) < 50.0:
210+
shallow_waypoints[f"Waypoint {i + 1}"] = f"{abs(loc_bathy):.2f}m depth"
211+
212+
if len(shallow_waypoints) > 0:
213+
raise ValueError(
214+
f"{self.__class__.__name__} cannot be deployed in waters shallower than 50m. The following waypoints are too shallow: {shallow_waypoints}."
215+
)
216+
201217
# define parcel particles
202218
argo_float_particleset = ParticleSet(
203219
fieldset=fieldset,

0 commit comments

Comments
 (0)