Fix positions_hours_before undercounted for open gaps at window overlaps - #146
Merged
Merged
Conversation
Boundaries.last_boundary() picked whichever boundary starts latest, not whichever has the fullest lookback for the vessel's last message. When that message falls in the overlap of two sliding windows, the later-starting window's own history is shorter, truncating positions_hours_before(_sat) for the resulting open gap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Boundaries.last_boundary()picked whichever boundary starts latest, regardless of whether it had the fullest history for the vessel's actual last message. When that message falls in the ~12h overlap between two sliding windows, the later-starting window's own lookback is shorter, so the open gap created in Step three (eval_last) got a truncatedpositions_hours_before/positions_hours_before_sat.Boundaries.boundary_for_last_message(), which picks the earliest-starting boundary whose own last message matches the overall last message across all boundaries — i.e. the boundary with the fullest lookback, not just whichever window starts latest.gfw-int-ais-datalake.gaps_v1.raw_gaps_versioned): this recurs at every internal sliding-window boundary inside both the daily-incremental DAG and the yearly backfill runs (window period caps at 180 days perMAX_WINDOW_PERIOD_D), with undercounting sharply concentrated in the ~12h window right after each boundary and clean everywhere else.Test plan
one_ssvid_with_open_gap_at_window_overlap_boundaryadded totests/conftest.py'sTestCases.GAP_BETWEEN_DAYS, exercised by the existingtest_detect_gaps.pysuitepositions_hours_before_satcorrected from 3 to 16 for the reproduced case