From d3767f18ecf298bbe989f0cca4a146b7bce1ce73 Mon Sep 17 00:00:00 2001 From: Yuan-Kai Liu Date: Sat, 19 Sep 2026 16:14:54 -0700 Subject: [PATCH 1/2] Only skip a scene when an orbit for the same mission exists find_scenes_to_download() decided a scene already had its orbit by testing time containment alone: if any(parsed_file.start_time in orbit for orbit in current_eofs): Orbit validity windows are near-identical across missions, so an orbit for a *different* mission covering the same window silently satisfies the check. An S1B POEORB covering V20180720T225942_20180722T005942 makes an S1A scene from 2018-07-21T22:57 look already-downloaded, and its S1A orbit is never fetched. Nothing errors -- the scene is simply logged as "already have EOF file", and the gap only surfaces later in a downstream processor that looks for a same-mission orbit and finds none. On one Sentinel-1 stack (2789 scenes, S1A/S1B/S1C mixed) this left 206 acquisition dates with no correct-mission orbit. Also require the mission to match. Co-Authored-By: Claude Opus 5 (1M context) --- eof/download.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eof/download.py b/eof/download.py index b60407b..515184c 100644 --- a/eof/download.py +++ b/eof/download.py @@ -256,7 +256,10 @@ def find_scenes_to_download(search_path="./", save_dir="./"): if parsed_file.start_time in orbit_dts: # start_time is a datetime, already found continue - if any(parsed_file.start_time in orbit for orbit in current_eofs): + if any( + parsed_file.start_time in orbit and orbit.mission == parsed_file.mission + for orbit in current_eofs + ): logger.info( "Skipping {}, already have EOF file".format( os.path.splitext(parsed_file.filename)[0] From 665ff4bbc5dffbf0bdad16d31d92dcb731664359 Mon Sep 17 00:00:00 2001 From: Scott Staniewicz Date: Mon, 21 Sep 2026 10:05:51 -0400 Subject: [PATCH 2/2] Key the already-found check on mission too, add regression tests The skip-if-already-downloaded check now requires a matching mission, but the de-duplication of already-seen scenes a few lines above still keyed on the start time alone. Two scenes from different platforms sharing a start second would drop one mission from `missions`, which `download_eofs` zips against `orbit_dts` -- the same silently-missing-orbit failure. `find_scenes_to_download` had no coverage of the skip branch at all, since the existing test never puts an .EOF in the save directory. Tests now cover another mission's orbit not suppressing a scene, a matching mission's orbit still suppressing it, and two missions sharing a start time both surviving. Co-Authored-By: Claude Opus 5 --- eof/download.py | 8 ++++-- eof/tests/test_eof.py | 66 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/eof/download.py b/eof/download.py index 515184c..5a068ba 100644 --- a/eof/download.py +++ b/eof/download.py @@ -250,11 +250,14 @@ def find_scenes_to_download(search_path="./", save_dir="./"): missions = [] # Check for already-downloaded orbit files, skip ones we have current_eofs = find_current_eofs(save_dir) + # Keyed on the mission as well: POEORB validity windows are day-aligned + # identically for every S1 platform, so a start time alone does not say + # which scene's orbit has already been accounted for. + scenes_found = set() # Now loop through each Sentinel scene in search_path for parsed_file in find_unique_safes(search_path): - if parsed_file.start_time in orbit_dts: - # start_time is a datetime, already found + if (parsed_file.start_time, parsed_file.mission) in scenes_found: continue if any( parsed_file.start_time in orbit and orbit.mission == parsed_file.mission @@ -272,6 +275,7 @@ def find_scenes_to_download(search_path="./", save_dir="./"): parsed_file.mission, parsed_file.start_time.strftime("%Y-%m-%d") ) ) + scenes_found.add((parsed_file.start_time, parsed_file.mission)) orbit_dts.append(parsed_file.start_time) missions.append(parsed_file.mission) diff --git a/eof/tests/test_eof.py b/eof/tests/test_eof.py index 7650214..82843e0 100644 --- a/eof/tests/test_eof.py +++ b/eof/tests/test_eof.py @@ -33,6 +33,72 @@ def test_find_scenes_to_download(tmpdir): ] +def test_other_mission_orbit_does_not_skip_scene(tmp_path): + """Check that one mission's orbit does not suppress another mission's scene. + + POEORB validity windows are day-aligned identically for every S1 platform, so + a containment check on the start time alone treats an S1B orbit as covering an + S1A scene, and no S1A orbit is ever fetched. + """ + search_path, save_dir = tmp_path / "scenes", tmp_path / "orbits" + search_path.mkdir() + save_dir.mkdir() + scene = "S1A_IW_SLC__1SDV_20180721T225743_20180721T225813_022898_027BD5_F737.zip" + other_mission_orbit = ( + "S1B_OPER_AUX_POEORB_OPOD_20210313T235723_V20180720T225942_20180722T005942.EOF" + ) + (search_path / scene).write_text("") + (save_dir / other_mission_orbit).write_text("") + + orbit_dts, missions = download.find_scenes_to_download( + search_path=str(search_path), save_dir=str(save_dir) + ) + assert missions == ["S1A"] + assert orbit_dts == [datetime.datetime(2018, 7, 21, 22, 57, 43)] + + +def test_same_mission_orbit_skips_scene(tmp_path): + """Check that a matching-mission orbit still suppresses the download.""" + search_path, save_dir = tmp_path / "scenes", tmp_path / "orbits" + search_path.mkdir() + save_dir.mkdir() + scene = "S1A_IW_SLC__1SDV_20180721T225743_20180721T225813_022898_027BD5_F737.zip" + same_mission_orbit = ( + "S1A_OPER_AUX_POEORB_OPOD_20210313T235723_V20180720T225942_20180722T005942.EOF" + ) + (search_path / scene).write_text("") + (save_dir / same_mission_orbit).write_text("") + + orbit_dts, missions = download.find_scenes_to_download( + search_path=str(search_path), save_dir=str(save_dir) + ) + assert orbit_dts == [] + assert missions == [] + + +def test_same_start_time_different_missions_both_downloaded(tmp_path): + """Check that scenes sharing a start time are kept per mission. + + The de-duplication of already-seen scenes keys on ``(start_time, mission)``; + keying on the time alone would drop one of the two missions from the result. + """ + search_path = tmp_path / "scenes" + search_path.mkdir() + # Same start/stop time, different platform and product uid + ( + search_path + / "S1A_IW_SLC__1SDV_20180721T225743_20180721T225813_022898_027BD5_F737.zip" + ).write_text("") + ( + search_path + / "S1B_IW_SLC__1SDV_20180721T225743_20180721T225813_011036_014389_67D8.zip" + ).write_text("") + + orbit_dts, missions = download.find_scenes_to_download(search_path=str(search_path)) + assert sorted(missions) == ["S1A", "S1B"] + assert orbit_dts == [datetime.datetime(2018, 7, 21, 22, 57, 43)] * 2 + + @pytest.mark.vcr def test_download_eofs_errors(): orbit_dates = [datetime.datetime(2018, 5, 2, 4, 30, 26)]