Skip to content

Ingest sea depth from MFP export - #412

Merged
j-atkins merged 48 commits into
mainfrom
mfp-sea-depth
Oct 20, 2026
Merged

j-atkins merged 48 commits into
mainfrom
mfp-sea-depth

Conversation

@j-atkins

Copy link
Copy Markdown
Collaborator

Note

This PR is part of a stack of three related PRs (#410, #411, #412). Each one builds on the one before it. I will request reviews for each in turn.

This PR implements logic so that virtualship init --from-mfp now fills sea_depth_meter from the MFP export's "Sea Depth" column.

Also updates docs and adds tests.

…ing whether schedule or instr config; use more helper functions
…ependent on depth); add winch_speed to CTD config
…nkeeping_time = deceleration + deployment + acceleration time across codebase
@j-atkins
j-atkins marked this pull request as ready for review October 20, 2026 12:17

@erikvansebille erikvansebille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - two comments below. Both may be beyond scope, though

- **Time (`time`)**: The scheduled time for reaching the waypoint, specifically in YYYY-MM-DD HH:MM:SS format.

- **Sea depth (`sea_depth_meter`)**: The estimated depth of the water column at the waypoint. This value matters because it determines how a long a deployment takes if there is a depth dependence, e.g. for a CTD that has to be lowered and raised. If you leave it as `null`, VirtualShip doesn't know how deep the water is and assumes the CTD descends all the way to its configured `max_depth_meter`. That is the slowest possible cast, so your schedule is verified against a worst case rather than an optimistic one in the simulations.
- **Sea depth (`sea_depth_meter`)**: The estimated depth of the water column at the waypoint. This value matters because it determines how a long a deployment takes if there is a depth dependence, e.g. for a CTD that has to be lowered and raised. If you leave it as `null`, VirtualShip doesn't know how deep the water is and assumes the CTD descends all the way to its configured `max_depth_meter`. That is the slowest possible cast, so your schedule is verified against a worst case rather than an optimistic one in the simulations. It will be automatically filled in by `virtualship init` if you use the `--from-mfp` flag.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find null a bit of a strange name here. I can imagine it may confuse users, who think that null == zero. Can we not change the code so users can leave it empty? Or otherwise use max?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My hesitation for using max_depth_meter is that that's only relevant when using CTDs at that waypoint.

Perhaps defaulting tosea_depth_meter being hidden in the expedition.yaml unless using --from-mfp would indeed be best though, to avoid confusion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there's no way to also test 'live' export from MFP (in case they change something on their portal)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm from a bit of scoping out, this would be quite an involved feature with quite a lot of custom logic for scraping the right things (which will be very fragile to changes on the MFP site itself). In that sense I do think it's out of scope of this PR and would also require quite a lot of maintenance.

The tests I've added for now should at least flag that something is wrong if the export changes.

@j-atkins

Copy link
Copy Markdown
Collaborator Author

The latest changes mean sea_depth_meter is only written to expedition.yaml when a depth is actually known (i.e. filled in by virtualship init --from-mfp, or added by hand), as discussed above. If it's left out, and CTDs are being deployed in the expedition, the CTD's max_depth_meter is assumed.

On a related note, I realise that making sea_depth_meter configurable in the YAML opens up a small ‘hack’ option. Users deploying CTDs could pass schedule verification with unrealistic timings by entering artificially shallow depth estimates. This is because the verification steps work out stationkeeping times from the estimated depths (or the CTD's max_depth_meter when there's no estimate), rather than building fieldsets/streaming data before the simulation stage and using the bathymetry from that. The simulation itself then uses the bathymetry fieldset, so the measurements are still simulated authentically.

I think this is acceptable for now. Someone would have to dig fairly deep into the code to work it out, and the field isn't exposed in user-facing features like virtualship plan anyway.

Base automatically changed from depth-dependent-stationkeeping to main October 20, 2026 13:49

@erikvansebille erikvansebille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Two questions below

- **Time (`time`)**: The scheduled time for reaching the waypoint, specifically in YYYY-MM-DD HH:MM:SS format.

- **Sea depth (`sea_depth_meter`)**: The estimated depth of the water column at the waypoint. This value matters because it determines how a long a deployment takes if there is a depth dependence, e.g. for a CTD that has to be lowered and raised. If you leave it as `null`, VirtualShip doesn't know how deep the water is and assumes the CTD descends all the way to its configured `max_depth_meter`. That is the slowest possible cast, so your schedule is verified against a worst case rather than an optimistic one in the simulations. It will be automatically filled in by `virtualship init` if you use the `--from-mfp` flag.
- **Sea depth (`sea_depth_meter`, optional)**: The estimated water depth at the waypoint, as a negative number of metres (e.g. `-1500.0`). It is filled in automatically by `virtualship init --from-mfp`, and can otherwise be added by hand. It is only used to estimate how long depth-dependent deployments (e.g. CTD casts) hold the ship at the waypoint. If it is left out, these are assumed to reach the instrument's configured maximum depth, so time taken at shallow-water waypoints could be overestimated if the configured max depth exceeds the actual depth. The simulated measurements are unaffected either way because the instruments will find and use the actual depth at simulation time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'left out' may be confusing. Do you mean 'left empty'? Or 'not provided'?

Comment thread src/virtualship/models/expedition.py Outdated
Comment on lines +254 to +255
if wp_data.get("sea_depth_meter") is None:
wp_data.pop("sea_depth_meter", None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this first line (if-statement) needed? Is the whole idea of pop not that the second argument is used if it doesn't exist? I.e. can we not just use the second line here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the if-statement because using pop alone will remove sea_depth_meter in all cases, even when it's supposed to be there (e.g. after using --from-mfp).

That said, this has highlighted that the None second argument in pop is largely redundant here because sea_depth_meter should always be present in the Expedition model, even if set to None. I will change it to a version which assumes it is always present and errors out if not, which is probably what we want.

@j-atkins
j-atkins merged commit 49a996d into main Oct 20, 2026
12 checks passed
@j-atkins
j-atkins deleted the mfp-sea-depth branch October 20, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants