-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
While working on #127, I realised that the pydantic.field_serializer calls in ship_config.py are not picked up; the input (in minutes) in the ship_config.taml files are not automatically converted to seconds. See e.g.
https://github.com/OceanParcels/virtualship/blob/99955d7d231b76ef7dee9b51b776b5812c9fb6e4/src/virtualship/expedition/ship_config.py#L92-L98
Note that this may also affects main?
I have now added a unit test (99955d7) to show that this does not work well.
I've pasted a quick patch/workaround (by hardcoding the multiplication of the period values by 60 in the code), but of course it would be much nicer to make the pydantic.field_serializer calls work.
diff --git a/src/virtualship/expedition/simulate_measurements.py b/src/virtualship/expedition/simulate_measurements.py
index be38222..43bebe5 100644
--- a/src/virtualship/expedition/simulate_measurements.py
+++ b/src/virtualship/expedition/simulate_measurements.py
@@ -85,7 +85,7 @@ def simulate_measurements(
out_path=expedition_dir.joinpath("results", "drifters.zarr"),
fieldset=input_data.drifter_fieldset,
drifters=measurements.drifters,
- outputdt=ship_config.drifter_config.period,
+ outputdt=ship_config.drifter_config.period * 60, # NOTE pydantic serialiser doesn't work?,
dt=timedelta(minutes=5),
endtime=None,
)
diff --git a/src/virtualship/expedition/simulate_schedule.py b/src/virtualship/expedition/simulate_schedule.py
index 59250e4..00dcc8d 100644
--- a/src/virtualship/expedition/simulate_schedule.py
+++ b/src/virtualship/expedition/simulate_schedule.py
@@ -153,7 +153,7 @@ class _ScheduleSimulator:
)
self._next_adcp_time = (
- self._next_adcp_time + self._ship_config.adcp_config.period
+ self._next_adcp_time + self._ship_config.adcp_config.period * 60 # NOTE pydantic serialiser doesn't work?
)
# note all ship underwater ST measurements
@@ -180,7 +180,7 @@ class _ScheduleSimulator:
self._next_ship_underwater_st_time = (
self._next_ship_underwater_st_time
- + self._ship_config.ship_underwater_st_config.period
+ + self._ship_config.ship_underwater_st_config.period * 60 # NOTE pydantic serialiser doesn't work?
)
self._time = end_time
@@ -196,7 +196,7 @@ class _ScheduleSimulator:
Spacetime(self._location, self._next_adcp_time)
)
self._next_adcp_time = (
- self._next_adcp_time + self._ship_config.adcp_config.period
+ self._next_adcp_time + self._ship_config.adcp_config.period * 60 # NOTE pydantic serialiser doesn't work?Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working