diff --git a/src/virtualship/expedition/ship_config.py b/src/virtualship/expedition/ship_config.py index 5609c182..8969f1c4 100644 --- a/src/virtualship/expedition/ship_config.py +++ b/src/virtualship/expedition/ship_config.py @@ -119,9 +119,9 @@ class XBTConfig(pydantic.BaseModel): class ShipConfig(pydantic.BaseModel): """Configuration of the virtual ship.""" - ship_speed_meter_per_second: float = pydantic.Field(gt=0.0) + ship_speed_knots: float = pydantic.Field(gt=0.0) """ - Velocity of the ship in meters per second. + Velocity of the ship in knots. """ argo_float_config: ArgoFloatConfig | None = None diff --git a/src/virtualship/expedition/simulate_schedule.py b/src/virtualship/expedition/simulate_schedule.py index bec54468..aee01509 100644 --- a/src/virtualship/expedition/simulate_schedule.py +++ b/src/virtualship/expedition/simulate_schedule.py @@ -122,11 +122,11 @@ def _progress_time_traveling_towards(self, location: Location) -> None: lons2=location.lon, lats2=location.lat, ) + ship_speed_meter_per_second = self._ship_config.ship_speed_knots * 3600 / 1852 azimuth1 = geodinv[0] distance_to_next_waypoint = geodinv[2] time_to_reach = timedelta( - seconds=distance_to_next_waypoint - / self._ship_config.ship_speed_meter_per_second + seconds=distance_to_next_waypoint / ship_speed_meter_per_second ) end_time = self._time + time_to_reach @@ -137,8 +137,7 @@ def _progress_time_traveling_towards(self, location: Location) -> None: while self._next_adcp_time <= end_time: time_to_sail = self._next_adcp_time - time distance_to_move = ( - self._ship_config.ship_speed_meter_per_second - * time_to_sail.total_seconds() + ship_speed_meter_per_second * time_to_sail.total_seconds() ) geodfwd: tuple[float, float, float] = self._projection.fwd( lons=location.lon, @@ -164,8 +163,7 @@ def _progress_time_traveling_towards(self, location: Location) -> None: while self._next_ship_underwater_st_time <= end_time: time_to_sail = self._next_ship_underwater_st_time - time distance_to_move = ( - self._ship_config.ship_speed_meter_per_second - * time_to_sail.total_seconds() + ship_speed_meter_per_second * time_to_sail.total_seconds() ) geodfwd: tuple[float, float, float] = self._projection.fwd( lons=location.lon, @@ -250,7 +248,7 @@ def _make_measurements(self, waypoint: Waypoint) -> timedelta: max_depth=self._ship_config.ctd_config.max_depth_meter, ) ) - time_costs.append(timedelta(minutes=20)) + time_costs.append(self._ship_config.ctd_config.stationkeeping_time) elif instrument is InstrumentType.DRIFTER: self._measurements_to_simulate.drifters.append( Drifter( diff --git a/src/virtualship/expedition/verify_schedule.py b/src/virtualship/expedition/verify_schedule.py index fcc77217..d3b01011 100644 --- a/src/virtualship/expedition/verify_schedule.py +++ b/src/virtualship/expedition/verify_schedule.py @@ -99,7 +99,7 @@ def verify_schedule( distance = geodinv[2] time_to_reach = timedelta( - seconds=distance / ship_config.ship_speed_meter_per_second + seconds=distance / ship_config.ship_speed_knots * 3600 / 1852 ) arrival_time = time + time_to_reach diff --git a/src/virtualship/instruments/drifter.py b/src/virtualship/instruments/drifter.py index 378af42f..2fd4180b 100644 --- a/src/virtualship/instruments/drifter.py +++ b/src/virtualship/instruments/drifter.py @@ -81,7 +81,9 @@ def simulate_drifters( ) # define output file for the simulation - out_file = drifter_particleset.ParticleFile(name=out_path, outputdt=outputdt) + out_file = drifter_particleset.ParticleFile( + name=out_path, outputdt=outputdt, chunks=[len(drifter_particleset), 100] + ) # get earliest between fieldset end time and provide end time fieldset_endtime = fieldset.time_origin.fulltime(fieldset.U.grid.time_full[-1]) diff --git a/src/virtualship/static/ship_config.yaml b/src/virtualship/static/ship_config.yaml index 729e4d75..494656c1 100644 --- a/src/virtualship/static/ship_config.yaml +++ b/src/virtualship/static/ship_config.yaml @@ -1,4 +1,4 @@ -ship_speed_meter_per_second: 5.14 +ship_speed_knots: 10.0 adcp_config: num_bins: 40 max_depth_meter: -1000.0 diff --git a/tests/expedition/expedition_dir/ship_config.yaml b/tests/expedition/expedition_dir/ship_config.yaml index c057d6b5..09f40c0a 100644 --- a/tests/expedition/expedition_dir/ship_config.yaml +++ b/tests/expedition/expedition_dir/ship_config.yaml @@ -1,4 +1,4 @@ -ship_speed_meter_per_second: 5.14 +ship_speed_knots: 10.0 adcp_config: num_bins: 40 max_depth_meter: -1000.0 diff --git a/tests/expedition/test_simulate_schedule.py b/tests/expedition/test_simulate_schedule.py index ef090b4e..6381b805 100644 --- a/tests/expedition/test_simulate_schedule.py +++ b/tests/expedition/test_simulate_schedule.py @@ -17,7 +17,7 @@ def test_simulate_schedule_feasible() -> None: projection = pyproj.Geod(ellps="WGS84") ship_config = ShipConfig.from_yaml("expedition_dir/ship_config.yaml") - ship_config.ship_speed_meter_per_second = 5.14 + ship_config.ship_speed_knots = 10.0 schedule = Schedule( waypoints=[ Waypoint(location=Location(0, 0), time=base_time),