Skip to content

Commit

Permalink
Merge pull request #133 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release 0.7.1
  • Loading branch information
AndrewPlayer3 authored Aug 23, 2023
2 parents 6634d50 + 1cd5094 commit 565259f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.1]
### Added
* insar_tops_burst now validates burst pair granule names.

## [0.7.0]
### Added
Expand Down
4 changes: 2 additions & 2 deletions images/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions src/hyp3_isce2/burst.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,38 @@ def get_burst_params(scene_name: str) -> BurstParams:
polarization=results[0].properties['polarization'],
burst_number=results[0].properties['burst']['burstIndex'],
)


def validate_bursts(reference_name: str, secondary_name: str) -> None:
"""Check whether the reference and secondary bursts are valid.
Args:
reference_scene: The reference burst name.
secondary_scene: The secondary burst name.
Returns:
None
"""
ref_split = reference_name.split('_')
sec_split = secondary_name.split('_')

ref_burst_id = ref_split[1]
sec_burst_id = sec_split[1]

ref_polarization = ref_split[4]
sec_polarization = sec_split[4]

if ref_burst_id != sec_burst_id:
raise ValueError(
f'The reference and secondary burst IDs are not the same: {ref_burst_id} and {sec_burst_id}.'
)

if ref_polarization != sec_polarization:
raise ValueError(
f'The reference and secondary polarizations are not the same: {ref_polarization} and {sec_polarization}.'
)

if ref_polarization != "VV" and ref_polarization != "HH":
raise ValueError(
f'{ref_polarization} polarization is not currently supported, only VV and HH.'
)
2 changes: 2 additions & 0 deletions src/hyp3_isce2/insar_tops_burst.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
get_isce2_burst_bbox,
get_product_name,
get_region_of_interest,
validate_bursts
)
from hyp3_isce2.dem import download_dem_for_isce2
from hyp3_isce2.logging import configure_root_logger
Expand Down Expand Up @@ -416,6 +417,7 @@ def main():
log.info('Begin ISCE2 TopsApp run')

reference_scene, secondary_scene = oldest_granule_first(args.granules[0], args.granules[1])
validate_bursts(reference_scene, secondary_scene)
swath_number = int(reference_scene[12])
range_looks, azimuth_looks = [int(looks) for looks in args.looks.split('x')]

Expand Down
22 changes: 22 additions & 0 deletions tests/test_burst.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,25 @@ def test_get_burst_params_multiple_results():
with pytest.raises(ValueError, match=r'.*found multiple results.*'):
burst.get_burst_params('there are multiple copies of this burst')
mock_search.assert_called_once_with(product_list=['there are multiple copies of this burst'])


def test_validate_bursts():
burst.validate_bursts(
'S1_030349_IW1_20230808T171601_VV_4A37-BURST',
'S1_030349_IW1_20230820T171602_VV_5AC3-BURST'
)
with pytest.raises(ValueError, match=r'.*polarizations are not the same.*'):
burst.validate_bursts(
'S1_215032_IW2_20230802T144608_VV_7EE2-BURST',
'S1_215032_IW2_20230721T144607_HH_B3FA-BURST'
)
with pytest.raises(ValueError, match=r'.*burst IDs are not the same.*'):
burst.validate_bursts(
'S1_030349_IW1_20230808T171601_VV_4A37-BURST',
'S1_030348_IW1_20230820T171602_VV_5AC3-BURST'
)
with pytest.raises(ValueError, match=r'.*only VV and HH.*'):
burst.validate_bursts(
'S1_030349_IW1_20230808T171601_VH_4A37-BURST',
'S1_030349_IW1_20230820T171602_VH_5AC3-BURST'
)

0 comments on commit 565259f

Please sign in to comment.