Skip to content

Commit 51bb7f5

Browse files
authored
Correct the overlapping check to account for reference date not the whole range (#700)
1 parent a1571fc commit 51bb7f5

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/dolphin/stack.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,18 @@ def _check_no_date_overlap(self):
9696
9797
The "last" compressed SLC is the one with the most recent end date.
9898
"""
99-
# Extract (start_date, end_date) for compressed SLCs with 3+ dates
99+
# Extract (reference_date, start_date, end_date) for
100+
# compressed SLCs with 3+ dates
100101
compressed_ranges = [
101-
(dates[1], dates[2])
102+
(dates[0], dates[1], dates[2])
102103
for dates, is_comp in zip(self.dates, self.is_compressed, strict=False)
103104
if is_comp and len(dates) >= 3
104105
]
105106
if not compressed_ranges:
106107
return
107108

108-
# Get the range with the most recent end date
109-
start_date, end_date = max(compressed_ranges, key=lambda x: x[1])
109+
# Get the most recent compressed SLC by end date
110+
ref_date, start_date, end_date = max(compressed_ranges, key=lambda x: x[2])
110111

111112
# Get all real SLC dates
112113
real_slc_dates = [
@@ -115,13 +116,14 @@ def _check_no_date_overlap(self):
115116
if not is_comp
116117
]
117118

118-
# Check for overlaps
119-
overlapping = [d for d in real_slc_dates if start_date <= d <= end_date]
119+
# Check for overlaps with the reference date only
120+
overlapping = [d for d in real_slc_dates if d == ref_date]
120121
if overlapping:
121122
msg = (
122-
f"SLC date {overlapping[0]} overlaps with compressed SLC date range "
123-
f"[{start_date}, {end_date}]. Real SLCs cannot have dates within "
124-
"the date range of the most recent compressed SLC."
123+
f"SLC date {overlapping[0]} overlaps with compressed SLC reference date"
124+
f" {ref_date} (date range [{start_date}, {end_date}]). Real SLCs cannot"
125+
" have the same date as the reference date of the most recent"
126+
" compressed SLC."
125127
)
126128
raise ValueError(msg)
127129

0 commit comments

Comments
 (0)