Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ce39e31
large refactor of simulator logic
j-atkins Aug 14, 2026
a10c2d4
start fixing public waypoint number comms, tidy up some var names
j-atkins Aug 17, 2026
d4ccffe
refactor getting public facing wp number to utils method
j-atkins Aug 17, 2026
77c69a7
next steps of adapting public facing wp numbers
j-atkins Aug 17, 2026
b624382
continue refactor work + using waypoint index for in-port problems
j-atkins Aug 17, 2026
73e5204
refactor: separate problem-specific checkpoint verification logic fro…
j-atkins Aug 18, 2026
24dc97c
user messaging fix when failed wp is port of arrival
j-atkins Aug 18, 2026
b739845
fix check for unique expedition
j-atkins Aug 18, 2026
69877ab
remove duplicate problem_wp_i declaration
j-atkins Aug 18, 2026
99e7df3
large refactor of simulator logic
j-atkins Aug 14, 2026
0e0eee5
start fixing public waypoint number comms, tidy up some var names
j-atkins Aug 17, 2026
240cc9d
refactor getting public facing wp number to utils method
j-atkins Aug 17, 2026
9e39bae
next steps of adapting public facing wp numbers
j-atkins Aug 17, 2026
8c0eda0
continue refactor work + using waypoint index for in-port problems
j-atkins Aug 17, 2026
d6bf082
refactor: separate problem-specific checkpoint verification logic fro…
j-atkins Aug 18, 2026
05b8ca8
user messaging fix when failed wp is port of arrival
j-atkins Aug 18, 2026
71d86c7
fix check for unique expedition
j-atkins Aug 18, 2026
e4fe04c
remove duplicate problem_wp_i declaration
j-atkins Aug 18, 2026
1e1f677
heavy refactor of _run.py; move more problems simulation logic into s…
j-atkins Aug 19, 2026
62a03b6
move to using ScheduledProblem object and its `.resolved` field as th…
j-atkins Aug 19, 2026
8aa5bc2
small fixes
j-atkins Aug 19, 2026
abb9750
further fixes: mark has_contingency problems with resolved and do not…
j-atkins Aug 19, 2026
6cd0b5f
remove redundant parameter
j-atkins Aug 20, 2026
4dae212
Merge branch 'refactor-problem-sim' of github.com:OceanParcels/virtua…
j-atkins Aug 27, 2026
7557bee
Merge branch 'cruise-data' into refactor-problem-sim
j-atkins Aug 28, 2026
8da7720
fix imports
j-atkins Aug 31, 2026
95500d6
update public wp numbering now there are port waypoints
j-atkins Aug 31, 2026
4f682bb
add note for separate PR work
j-atkins Aug 31, 2026
8d81135
move original expedition caching so that comes before
j-atkins Aug 31, 2026
0525896
fix: in memory self.problems
j-atkins Aug 31, 2026
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
379 changes: 158 additions & 221 deletions src/virtualship/cli/_run.py

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions src/virtualship/expedition/simulate_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Spacetime,
Waypoint,
)
from virtualship.utils import _calc_sail_time
from virtualship.utils import _calc_sail_time, _get_public_wp


@dataclass
Expand All @@ -36,7 +36,7 @@ class ScheduleProblem:
"""Result of schedule that could not be fully completed."""

time: datetime
failed_waypoint_i: int
failed_wp: int


@dataclass
Expand Down Expand Up @@ -103,7 +103,7 @@ def __init__(self, projection: pyproj.Geod, expedition: Expedition) -> None:
self._expedition = expedition

assert self._expedition.schedule.waypoints[0].time is not None, (
"First waypoint must have a time. This should have been verified before calling this function."
"Departure port must have a time."
)
self._time = expedition.schedule.waypoints[0].time
self._location = expedition.schedule.waypoints[0].location
Expand All @@ -122,9 +122,12 @@ def simulate(self) -> ScheduleOk | ScheduleProblem:

# check if waypoint was reached in time
# TODO: already tested in schedule.verify(), re-check here for robustness but could be removed if deemed redundant
#! TODO: however, schedule.verify() does not account for stationkeeping time, so move that to schedule.verify() as well
#! TODO: then can also address #249 properly with a depth/bathymetry lookup and enhanced messaging explaining that the schedule is infeasible due to stationkeeping time, not sailing time
if waypoint.time is not None and self._time > waypoint.time:
public_wp = _get_public_wp(wp_i, self._expedition.schedule.waypoints)
print(
f"\nWaypoint {wp_i + 1} could not be reached in time. Current time: {self._time}. Waypoint time: {waypoint.time}."
f"\nWaypoint {public_wp} could not be reached in time. Current time: {self._time}. Waypoint time: {waypoint.time}."
"\n\nHave you ensured that your schedule includes sufficient time for taking measurements, e.g. CTD casts (in addition to the time it takes to sail between waypoints)?\n"
)
return ScheduleProblem(self._time, wp_i)
Expand Down
4 changes: 2 additions & 2 deletions src/virtualship/instruments/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
_find_files_in_timerange,
_find_nc_file_with_variable,
_get_bathy_data,
_get_clean_encoding,
_get_waypoint_latlons,
_select_product_id,
get_clean_encoding,
ship_spinner,
)

Expand Down Expand Up @@ -321,7 +321,7 @@ def _get_local_ds(self, files: list[Path]) -> xr.Dataset:
@staticmethod
def _via_tmp_ds(ds: xr.Dataset) -> xr.Dataset:
"""Create and re-load a temporary local dataset."""
encoding = get_clean_encoding(ds)
encoding = _get_clean_encoding(ds)

with tempfile.TemporaryDirectory() as tmpdir:
tmp_fpath = Path(tmpdir) / "tmp.nc"
Expand Down
Loading
Loading