Skip to content

Commit

Permalink
Merge pull request #2459 from ASFHyP3/srg-validators
Browse files Browse the repository at this point in the history
Relative Orbit Validation for SRG Time Series
  • Loading branch information
AndrewPlayer3 authored Oct 16, 2024
2 parents 0ba47e3 + 15c7813 commit 11de54a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
17 changes: 17 additions & 0 deletions apps/api/src/hyp3_api/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@ def check_granules_intersecting_bounds(job, granule_metadata):
)


def check_same_relative_orbits(job, granule_metadata):
previous_relative_orbit = None
for granule in granule_metadata:
name_split = granule['name'].split('_')
absolute_orbit = name_split[7]
# "Relationship between relative and absolute orbit numbers": https://sentiwiki.copernicus.eu/web/s1-products
offset = 73 if name_split[0] == 'S1A' else 27
relative_orbit = ((int(absolute_orbit) - offset) % 175) + 1
if not previous_relative_orbit:
previous_relative_orbit = relative_orbit
if relative_orbit != previous_relative_orbit:
raise GranuleValidationError(
f'Relative orbit number for {granule["name"]} does not match that of the previous granules: '
f'{relative_orbit} is not {previous_relative_orbit}.'
)


def convert_single_burst_jobs(jobs: list[dict]) -> list[dict]:
jobs = deepcopy(jobs)
for job in jobs:
Expand Down
3 changes: 2 additions & 1 deletion job_spec/SRG_GSLC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ SRG_GSLC:
example: -116.583
validators: [
check_bounds_formatting,
check_granules_intersecting_bounds
check_granules_intersecting_bounds,
check_same_relative_orbits
]
cost_profiles:
DEFAULT:
Expand Down
3 changes: 2 additions & 1 deletion job_spec/SRG_TIME_SERIES.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ SRG_TIME_SERIES:
example: -124.41473278572731
validators: [
check_bounds_formatting,
check_granules_intersecting_bounds
check_granules_intersecting_bounds,
check_same_relative_orbits
]
cost_profiles:
DEFAULT:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_api/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,20 @@ def test_check_granules_intersecting_bounds():
validation.check_granules_intersecting_bounds(job_with_specified_bounds, invalid_granule_metadata)
with raises(validation.GranuleValidationError, match=error_pattern):
validation.check_granules_intersecting_bounds(job_with_default_bounds, invalid_granule_metadata)


def check_same_relative_orbits():
valid_granule_metadata = [
{'name': 'S1A_IW_RAW__0SDV_20201015T161622_20201015T161654_034809_040E95_AF3C'},
{'name': 'S1A_IW_RAW__0SDV_20200816T161620_20200816T161652_033934_03EFCE_5730'},
{'name': 'S1B_IW_RAW__0SDV_20200810T161537_20200810T161610_022863_02B66A_F7D7'},
{'name': 'S1B_IW_RAW__0SDV_20200623T161535_20200623T161607_022163_02A10F_7FD6'}
]
invalid_granule_metadata = valid_granule_metadata
invalid_granule_metadata.append(
{'name': 'S1B_IW_RAW__0SDV_20200623T161535_20200623T161607_012345_02A10F_7FD6'}
)
validation.check_same_relative_orbits({}, valid_granule_metadata)
error_pattern = r'.*23 is not 87.*'
with raises(validation.GranuleValidationError, match=error_pattern):
validation.check_same_relative_orbits({}, invalid_granule_metadata)

0 comments on commit 11de54a

Please sign in to comment.