Handle Sentinel-1D ReferenceGranule in HyP3 metadata#1501
Conversation
|
💖 Thanks for opening this pull request! Please check out our contributing guidelines. 💖 |
Reviewer's GuideExtend HyP3 Sentinel-1 metadata handling to fully support Sentinel-1D INSAR_GAMMA products, including product-name parsing and relative orbit computation for reference granules, and add tests to guard the new behavior. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- In
add_hyp3_metadata, the new Sentinel‑1D handling introduces a duplicateelseat the same indentation level; this should be an explicitelif ref_granule.startswith('S1D'):(or similar) so theValueErrorpath is preserved and the code remains syntactically valid. - The new test
test_add_hyp3_metadata_insar_gamma_s1d_reference_granuleappears to be indented relative to the module level, which will either nest it inside the previous test or cause syntax/style issues; align thedefwith the other top‑level tests.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `add_hyp3_metadata`, the new Sentinel‑1D handling introduces a duplicate `else` at the same indentation level; this should be an explicit `elif ref_granule.startswith('S1D'):` (or similar) so the `ValueError` path is preserved and the code remains syntactically valid.
- The new test `test_add_hyp3_metadata_insar_gamma_s1d_reference_granule` appears to be indented relative to the module level, which will either nest it inside the previous test or cause syntax/style issues; align the `def` with the other top‑level tests.
## Individual Comments
### Comment 1
<location path="src/mintpy/prep_hyp3.py" line_range="158-160" />
<code_context>
meta['relative_orbit'] = ((abs_orbit - 172) % 175) + 1
else:
- # add equation for Sentinel-D in the future
+ meta['relative_orbit'] = ((abs_orbit - 42) % 175) + 1
+ else:
raise ValueError(f'Un-recognized Sentinel-1 satellite from {ref_granule}!')
# first/last_frame [to be completed]
</code_context>
<issue_to_address>
**issue (bug_risk):** The control flow now has two consecutive `else` clauses, which is syntactically invalid and breaks the `if`/`elif` chain.
The new Sentinel‑1D `meta['relative_orbit']` assignment was added under an `else` that previously only had a TODO, but the original `else` with `ValueError` is still there. This creates an `elif ... else ... else` structure, which is invalid Python and also makes the S1D branch unreachable. Please restructure so S1D has its own explicit `elif` and there is only a single `else` for unknown platforms, e.g.:
```python
elif ref_granule.startswith('S1D'):
meta['relative_orbit'] = ((abs_orbit - 42) % 175) + 1
else:
raise ValueError(...)
```
</issue_to_address>
### Comment 2
<location path="tests/test_prep_hyp3.py" line_range="192-201" />
<code_context>
+ def test_add_hyp3_metadata_insar_gamma_s1d_reference_granule(tmp_path):
</code_context>
<issue_to_address>
**issue (testing):** The new Sentinel-1D reference granule test is incorrectly indented and will likely cause an ImportError or prevent pytest from discovering it.
This test function is indented at module scope, which risks it being nested inside a previous block and not discovered by pytest. Please unindent the `def` so it aligns with the other top-level tests.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| def test_add_hyp3_metadata_insar_gamma_s1d_reference_granule(tmp_path): | ||
| product_name = 'S1DD_20260610T042337_20260622T042338_VVR012_INT80_G_weF_0B7B' | ||
| (tmp_path / f'{product_name}.txt').write_text( | ||
| '\n'.join([ | ||
| 'UTC time: 15817.0', | ||
| 'Azimuth looks: 4', | ||
| 'Range looks: 20', | ||
| 'Earth radius at nadir: 6337286.638938101', | ||
| 'Spacecraft height: 693000.0', | ||
| 'Slant range near: 846099.1914484155', |
There was a problem hiding this comment.
issue (testing): The new Sentinel-1D reference granule test is incorrectly indented and will likely cause an ImportError or prevent pytest from discovering it.
This test function is indented at module scope, which risks it being nested inside a previous block and not discovered by pytest. Please unindent the def so it aligns with the other top-level tests.
e2f3995 to
e5972d8
Compare
e5972d8 to
9e36a95
Compare
This PR is stacked on top of #1496 and fixes one remaining Sentinel-1D HyP3 parsing issue.
The current Sentinel-1D product-name parsing handles S1DD-style HyP3 Gamma product names, but add_hyp3_metadata() can still fail when the HyP3 metadata contains a ReferenceGranule starting with S1D_IW_SLC__.
Example failure:
ValueError: Un-recognized Sentinel-1 satellite from S1D_IW_SLC__1SDV_20260610T042337_20260610T042418_003169_005832_1158
This patch adds the Sentinel-1D relative orbit equation and a corresponding test.
Summary by Sourcery
Handle Sentinel-1D HyP3 INSAR_GAMMA products and reference granules in metadata parsing.
Bug Fixes:
Enhancements:
Tests: