Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/virtualship/expedition/ship_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions src/virtualship/expedition/simulate_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/virtualship/expedition/verify_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/virtualship/instruments/drifter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion src/virtualship/static/ship_config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/expedition/expedition_dir/ship_config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/expedition/test_simulate_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down