Skip to content

Commit fa0b431

Browse files
erikvansebilleammeddpre-commit-ci[bot]VeckoTheGecko
authored
speed and other little things (#127)
* speed and other little things * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Some fixes to config renaming * remove double timedelta * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixing smalll bug in creating list of costs * FIxing drifter measuring interval * Adding chunks to Drifter zarr output * Adding test for pydantic serialiser converstion from minutes to seconds * Fix serialisation and add Drifter validator * Update var name to stationkeeping_time * Remove drifter period changes --------- Co-authored-by: Emma Daniels <e.e.daniels1@uu.nl> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Vecko <36369090+VeckoTheGecko@users.noreply.github.com>
1 parent d8cd9d6 commit fa0b431

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

src/virtualship/expedition/ship_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ class XBTConfig(pydantic.BaseModel):
119119
class ShipConfig(pydantic.BaseModel):
120120
"""Configuration of the virtual ship."""
121121

122-
ship_speed_meter_per_second: float = pydantic.Field(gt=0.0)
122+
ship_speed_knots: float = pydantic.Field(gt=0.0)
123123
"""
124-
Velocity of the ship in meters per second.
124+
Velocity of the ship in knots.
125125
"""
126126

127127
argo_float_config: ArgoFloatConfig | None = None

src/virtualship/expedition/simulate_schedule.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ def _progress_time_traveling_towards(self, location: Location) -> None:
122122
lons2=location.lon,
123123
lats2=location.lat,
124124
)
125+
ship_speed_meter_per_second = self._ship_config.ship_speed_knots * 3600 / 1852
125126
azimuth1 = geodinv[0]
126127
distance_to_next_waypoint = geodinv[2]
127128
time_to_reach = timedelta(
128-
seconds=distance_to_next_waypoint
129-
/ self._ship_config.ship_speed_meter_per_second
129+
seconds=distance_to_next_waypoint / ship_speed_meter_per_second
130130
)
131131
end_time = self._time + time_to_reach
132132

@@ -137,8 +137,7 @@ def _progress_time_traveling_towards(self, location: Location) -> None:
137137
while self._next_adcp_time <= end_time:
138138
time_to_sail = self._next_adcp_time - time
139139
distance_to_move = (
140-
self._ship_config.ship_speed_meter_per_second
141-
* time_to_sail.total_seconds()
140+
ship_speed_meter_per_second * time_to_sail.total_seconds()
142141
)
143142
geodfwd: tuple[float, float, float] = self._projection.fwd(
144143
lons=location.lon,
@@ -164,8 +163,7 @@ def _progress_time_traveling_towards(self, location: Location) -> None:
164163
while self._next_ship_underwater_st_time <= end_time:
165164
time_to_sail = self._next_ship_underwater_st_time - time
166165
distance_to_move = (
167-
self._ship_config.ship_speed_meter_per_second
168-
* time_to_sail.total_seconds()
166+
ship_speed_meter_per_second * time_to_sail.total_seconds()
169167
)
170168
geodfwd: tuple[float, float, float] = self._projection.fwd(
171169
lons=location.lon,
@@ -250,7 +248,7 @@ def _make_measurements(self, waypoint: Waypoint) -> timedelta:
250248
max_depth=self._ship_config.ctd_config.max_depth_meter,
251249
)
252250
)
253-
time_costs.append(timedelta(minutes=20))
251+
time_costs.append(self._ship_config.ctd_config.stationkeeping_time)
254252
elif instrument is InstrumentType.DRIFTER:
255253
self._measurements_to_simulate.drifters.append(
256254
Drifter(

src/virtualship/expedition/verify_schedule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def verify_schedule(
9999
distance = geodinv[2]
100100

101101
time_to_reach = timedelta(
102-
seconds=distance / ship_config.ship_speed_meter_per_second
102+
seconds=distance / ship_config.ship_speed_knots * 3600 / 1852
103103
)
104104
arrival_time = time + time_to_reach
105105

src/virtualship/instruments/drifter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def simulate_drifters(
8181
)
8282

8383
# define output file for the simulation
84-
out_file = drifter_particleset.ParticleFile(name=out_path, outputdt=outputdt)
84+
out_file = drifter_particleset.ParticleFile(
85+
name=out_path, outputdt=outputdt, chunks=[len(drifter_particleset), 100]
86+
)
8587

8688
# get earliest between fieldset end time and provide end time
8789
fieldset_endtime = fieldset.time_origin.fulltime(fieldset.U.grid.time_full[-1])

src/virtualship/static/ship_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ship_speed_meter_per_second: 5.14
1+
ship_speed_knots: 10.0
22
adcp_config:
33
num_bins: 40
44
max_depth_meter: -1000.0

tests/expedition/expedition_dir/ship_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ship_speed_meter_per_second: 5.14
1+
ship_speed_knots: 10.0
22
adcp_config:
33
num_bins: 40
44
max_depth_meter: -1000.0

tests/expedition/test_simulate_schedule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_simulate_schedule_feasible() -> None:
1717

1818
projection = pyproj.Geod(ellps="WGS84")
1919
ship_config = ShipConfig.from_yaml("expedition_dir/ship_config.yaml")
20-
ship_config.ship_speed_meter_per_second = 5.14
20+
ship_config.ship_speed_knots = 10.0
2121
schedule = Schedule(
2222
waypoints=[
2323
Waypoint(location=Location(0, 0), time=base_time),

0 commit comments

Comments
 (0)