Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative Orbit Validation for SRG Time Series #2459

Merged
merged 9 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -38,7 +38,8 @@ SRG_TIME_SERIES:
example: -116.583
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)