Skip to content

Commit fefcd54

Browse files
authored
Add S1D to SentinelOrbit regex to avoid error in RESORB download (#75)
* Add `S1D` to `SentinelOrbit` regex to avoid error in RESORB download ASF currently has a test S1D orbit file in the S3 bucket. This causes the RESORB search to error. Closes #74 * typo
1 parent 6c4a30d commit fefcd54

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

eof/products.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class Sentinel(Base):
123123
"""
124124

125125
FILE_REGEX = re.compile(
126-
r"(?P<mission>S1A|S1B|S1C)_"
126+
r"(?P<mission>S1A|S1B|S1C|S1D|S1E)_"
127127
r"(?P<beam>[\w\d]{2})_"
128128
r"(?P<product_type>[\w_]{3})"
129129
r"(?P<resolution_class>[FHM_])_"
@@ -250,6 +250,8 @@ def relative_orbit(self):
250250
return ((self.absolute_orbit - 27) % 175) + 1
251251
elif self.mission == "S1C":
252252
return ((self.absolute_orbit - 172) % 175) + 1
253+
else:
254+
raise ValueError(f"Unknown relative orbit for mission {self.mission}")
253255

254256
@property
255257
def path(self):
@@ -305,7 +307,7 @@ class SentinelOrbit(Base):
305307

306308
TIME_FMT = "%Y%m%dT%H%M%S"
307309
FILE_REGEX = (
308-
r"(?P<mission>S1A|S1B|S1C)_OPER_AUX_"
310+
r"(?P<mission>S1A|S1B|S1C|S1D|S1E)_OPER_AUX_"
309311
r"(?P<orbit_type>[\w_]{6})_OPOD_"
310312
r"(?P<created_datetime>[T\d]{15})_"
311313
r"V(?P<start_datetime>[T\d]{15})_"

eof/tests/test_eof.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,22 @@ def test_find_scenes_to_download(tmpdir):
1616
"S1B_IW_SLC__1SDV_20180502T043026_20180502T043054_021721_025793_5C18.zip"
1717
)
1818
name3 = "S1C_IW_SLC__1SDV_20250331T060116_20250331T060143_001681_002CD0_8D44"
19+
# Fake S1D name
20+
name4 = "S1D_IW_SLC__1SDV_20250731T060116_20250731T060143_001681_002CD0_8D44"
1921
open(name1, "w").close()
2022
open(name2, "w").close()
2123
open(name3, "w").close()
24+
open(name4, "w").close()
2225
orbit_dates, missions = download.find_scenes_to_download(search_path=".")
2326

27+
# S1D ignored for now
28+
assert sorted(missions) == ["S1A", "S1B", "S1C"]
2429
assert sorted(orbit_dates) == [
2530
datetime.datetime(2018, 4, 20, 4, 30, 26),
2631
datetime.datetime(2018, 5, 2, 4, 30, 26),
2732
datetime.datetime(2025, 3, 31, 6, 1, 16),
2833
]
2934

30-
assert sorted(missions) == ["S1A", "S1B", "S1C"]
31-
3235

3336
@pytest.mark.vcr
3437
def test_download_eofs_errors():

eof/tests/test_products.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,16 @@ def test_s1c():
6262
assert p.relative_orbit == 110
6363
assert p.polarization == "DV"
6464
assert p.mission == "S1C"
65+
66+
67+
def test_s1d_fake_orbit_issue_74():
68+
"""Tests ability to handle S1D: https://github.com/scottstanie/sentineleof/issues/74 ."""
69+
fname = (
70+
"S1D_OPER_AUX_RESORB_OPOD_20250703T092541_V20250703T045039_20250703T080809.EOF"
71+
)
72+
p = SentinelOrbit(fname)
73+
74+
assert p.filename == fname
75+
assert p.start_time == datetime(2025, 7, 3, 4, 50, 39)
76+
assert p.stop_time == datetime(2025, 7, 3, 8, 8, 9)
77+
assert p.mission == "S1D"

0 commit comments

Comments
 (0)