Skip to content

Commit

Permalink
Fix reference picking for multi-burst input (#171)
Browse files Browse the repository at this point in the history
* Make reference tests fail for multi-burst

* Dedup the input dates before searching
  • Loading branch information
scottstanie authored Oct 15, 2024
1 parent 72e4070 commit 0a2810a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/disp_s1/pge_runconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ def _compute_reference_dates(
# Mark any files beginning with "compressed" as compressed
is_compressed = ["compressed" in str(Path(f).stem).lower() for f in cslc_file_list]
# Get the dates of the base phase (works for either compressed, or regular cslc)
input_dates = [get_dates(f)[0].date() for f in cslc_file_list]
input_dates = sorted({get_dates(f)[0].date() for f in cslc_file_list})

output_reference_idx: int = 0
extra_reference_date: datetime.datetime | None = None
reference_dates = sorted([d.date() for d in reference_datetimes])
reference_dates = sorted({d.date() for d in reference_datetimes})

for ref_date in reference_dates:
# Find the nearest index that is greater than or equal to the reference date
Expand Down
18 changes: 15 additions & 3 deletions tests/test_pge_runconfig.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import random
import sys
import warnings
from pathlib import Path
Expand Down Expand Up @@ -233,8 +234,13 @@ def test_reference_date_computation():
datetime.datetime(2020, 8, 21, 16, 13, 4),
datetime.datetime(2020, 9, 2, 16, 13, 5),
]
# burst id/real name doesn't matter, just date and "compressed" or not
cslc_file_list = [f"{d.strftime('%Y%m%d.tif')}" for d in sensing_time_list]
# Doesn't have to be the real name
cslc_file_list = [
f"OPERA_T042-088905-{swath}_{d.strftime('%Y%m%dT%H%M%S')}.h5"
for d in sensing_time_list
for swath in ["IW1", "IW2", "IW3"]
]
random.shuffle(cslc_file_list)

# Assume we nominally will reset the reference each august
reference_datetimes = [datetime.datetime(y, 8, 1) for y in range(2018, 2025)]
Expand Down Expand Up @@ -268,7 +274,13 @@ def test_reference_first_in_stack():
datetime.datetime(2017, 3, 26, 0, 0),
datetime.datetime(2017, 4, 7, 0, 0),
]
cslc_file_list = [f"{d.strftime('%Y%m%d.tif')}" for d in sensing_time_list]
cslc_file_list = [
f"OPERA_T042-088905-{swath}_{d.strftime('%Y%m%dT%H%M%S')}.h5"
for d in sensing_time_list
for swath in ["IW1", "IW2", "IW3"]
]
random.shuffle(cslc_file_list)

# Assume we nominally will reset the reference each august
reference_datetimes = [datetime.datetime(y, 8, 1) for y in range(2018, 2025)]
# "11114": [
Expand Down

0 comments on commit 0a2810a

Please sign in to comment.