From ee7de87230a4105d138775714663bc180a20c0c0 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 12:56:22 -0500 Subject: [PATCH 01/31] functions to validate burst names --- src/hyp3_isce2/burst.py | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index 56806749..933a399b 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -380,3 +380,62 @@ def get_burst_params(scene_name: str) -> BurstParams: polarization=results[0].properties['polarization'], burst_number=results[0].properties['burst']['burstIndex'], ) + + +def validate_burst_date(burst_name): + """Check whether the burst occurs after the date ASF began storing bursts. + + Args: + burst_name: The reference burst name. + + Returns: + None + """ + + # TODO: Get real date. + oldest_burst_date = '20200101' + burst_date = burst_name.split('_')[3][0:8] + + if burst_date < oldest_burst_date: + raise ValueError( + f'Bursts before {oldest_burst_date} are not currently available from ASF. {burst_name} isn\'t available.' + ) + + return None + + +def validate_bursts(reference_name, secondary_name): + """Check whether the reference and secondary bursts are valid. + + Args: + reference_scene: The reference burst name. + secondary_scene: The secondary burst name. + + Returns: + None + """ + + # TODO: Ensure COP30 DEM Coverage for the Bursts. + + validate_burst_date(reference_name) + validate_burst_date(secondary_name) + + 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 bursts do not share a common BurstID: {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}.' + ) + + return None From b793f5c1745601183445bfe7b0b9dc4701ae706c Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 12:56:34 -0500 Subject: [PATCH 02/31] validate burst names and dem coverage --- src/hyp3_isce2/insar_tops_burst.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hyp3_isce2/insar_tops_burst.py b/src/hyp3_isce2/insar_tops_burst.py index 5bf85a01..95942301 100644 --- a/src/hyp3_isce2/insar_tops_burst.py +++ b/src/hyp3_isce2/insar_tops_burst.py @@ -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 @@ -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')] From c1cd07fc2dfc4d25841abf142609a127634cfa08 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 12:56:48 -0500 Subject: [PATCH 03/31] function to validate dem coverage --- src/hyp3_isce2/dem.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/hyp3_isce2/dem.py b/src/hyp3_isce2/dem.py index fa3f9116..906b7726 100644 --- a/src/hyp3_isce2/dem.py +++ b/src/hyp3_isce2/dem.py @@ -15,7 +15,9 @@ import site import subprocess +import requests from pathlib import Path +from typing import Tuple import dem_stitcher import numpy as np @@ -75,6 +77,25 @@ def distance_meters_to_degrees(distance_meters, latitude): return (np.round(distance_degrees_lon, 15), np.round(distance_degrees_lat, 15)) +def validate_dem_coverage(extent: Tuple[float, float, float, float]): + """Check whether the DEM covers the area of interest. + + Args: + extent: The extent of the area of interest. (xmin, ymin, xmax, ymax) + + Returns: + None + """ + + xmin, ymin, xmax, ymax = extent + url = f'https://portal.opentopography.org/ajaxRasterJob?action=checkIntersect&opentopoID=OTSDEM.032021.4326.3&x1={xmin}&y1={ymin}&x2={xmax}&y2={ymax}' + res = requests.get(url=url) + if res.json()['intersect'] == False: + raise ValueError( + f'The extent {extent} is not covered by the COP30 DSM.' + ) + + def download_dem_for_isce2( extent: list, dem_name: str = 'glo_30', @@ -94,6 +115,9 @@ def download_dem_for_isce2( Returns: The path to the downloaded DEM. """ + + validate_dem_coverage(extent=extent) + dem_dir = dem_dir or Path('.') dem_dir.mkdir(exist_ok=True, parents=True) From fc8de44ef587c00473fd583aa1e114154b2d5ce1 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 13:11:48 -0500 Subject: [PATCH 04/31] fixes for flake8 --- src/hyp3_isce2/dem.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hyp3_isce2/dem.py b/src/hyp3_isce2/dem.py index 906b7726..08eef849 100644 --- a/src/hyp3_isce2/dem.py +++ b/src/hyp3_isce2/dem.py @@ -15,13 +15,13 @@ import site import subprocess -import requests from pathlib import Path from typing import Tuple import dem_stitcher import numpy as np import rasterio +import requests from lxml import etree from shapely.geometry import box @@ -88,9 +88,10 @@ def validate_dem_coverage(extent: Tuple[float, float, float, float]): """ xmin, ymin, xmax, ymax = extent - url = f'https://portal.opentopography.org/ajaxRasterJob?action=checkIntersect&opentopoID=OTSDEM.032021.4326.3&x1={xmin}&y1={ymin}&x2={xmax}&y2={ymax}' - res = requests.get(url=url) - if res.json()['intersect'] == False: + url = 'https://portal.opentopography.org/ajaxRasterJob' + query = f'?action=checkIntersect&opentopoID=OTSDEM.032021.4326.3&x1={xmin}&y1={ymin}&x2={xmax}&y2={ymax}' + res = requests.get(url=url+query) + if res.json()['intersect'] is False: raise ValueError( f'The extent {extent} is not covered by the COP30 DSM.' ) From 5aa44bb89d483df151c391c8728f581081fd4c6f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:13:00 +0000 Subject: [PATCH 05/31] update coverage image --- images/coverage.svg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/coverage.svg b/images/coverage.svg index dd6df127..9f708fe5 100644 --- a/images/coverage.svg +++ b/images/coverage.svg @@ -15,7 +15,7 @@ coverage coverage - 61% - 61% + 60% + 60% From 8cfd7cef683b59d87f92fd98545432dd4eb00f49 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 13:15:26 -0500 Subject: [PATCH 06/31] updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8403df5b..50b253dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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_bursts now checks if burst pairs are valid, and that they have COP30 coverage. ## [0.7.0] ### Added From 49503c950e3ca749a341e3cafe6575b16b59db78 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 13:34:58 -0500 Subject: [PATCH 07/31] added test for validate_dem_coverage --- tests/test_dem.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_dem.py b/tests/test_dem.py index 319b9950..5895a4cc 100644 --- a/tests/test_dem.py +++ b/tests/test_dem.py @@ -92,3 +92,14 @@ def test_distance_meters_to_degrees(): dem.distance_meters_to_degrees(20, 90) with raises(ZeroDivisionError): dem.distance_meters_to_degrees(20, -90) + + +def test_validate_dem_coverage(): + try: + dem.validate_dem_coverage([-100, 30, -101, 31]) # Valid extent over Texas + except Exception as e: + assert False, f'Unexpected exception for valid DEM extent: {e}' + with raises(ValueError): + dem.validate_dem_coverage([45, 40, 49, 41]) # Invalid extent over Azerbaijan + with raises(ValueError): + dem.validate_dem_coverage([-33, 28, -30, 29]) # Invalid extent over the Atlantic Ocean From 807478d958421d9e13df3b8a1ed05336528d74e1 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 13:46:21 -0500 Subject: [PATCH 08/31] added tests for burst validation --- tests/test_burst.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/test_burst.py b/tests/test_burst.py index 76da92c3..e43fd9a9 100644 --- a/tests/test_burst.py +++ b/tests/test_burst.py @@ -168,3 +168,32 @@ 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_burst_date(): + try: + burst.validate_burst_date('S1_030349_IW1_20230808T171601_VV_4A37-BURST') + except Exception as e: + assert False, f'Unexpected exception for valid date: {e}' + with pytest.raises(ValueError, match=r'.*not currently available from ASF.*'): + burst.validate_burst_date('S1_030349_IW1_20180808T171601_VV_4A37-BURST') + + +def test_validate_bursts(): + try: + burst.validate_bursts( # valid burst pair + 'S1_030349_IW1_20230808T171601_VV_4A37-BURST', + 'S1_030349_IW1_20230820T171602_VV_5AC3-BURST' + ) + except Exception as e: + assert False, f'Unexpected exception for valid burst pair: {e}' + with pytest.raises(ValueError, match=r'.*polarizations are not the same.*'): # different polarizations + burst.validate_bursts( + 'S1_215032_IW2_20230802T144608_VV_7EE2-BURST', + 'S1_215032_IW2_20230721T144607_VH_B3FA-BURST' + ) + with pytest.raises(ValueError, match=r'.*do not share a common BurstID.*'): # different burst ids + burst.validate_bursts( + 'S1_030349_IW1_20230808T171601_VV_4A37-BURST', + 'S1_030348_IW1_20230820T171602_VV_5AC3-BURST' + ) From 6f91fee17ce7c229269923f280642a68115504e2 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 13:46:36 -0500 Subject: [PATCH 09/31] added exception matchs for dem coverage validation --- tests/test_dem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_dem.py b/tests/test_dem.py index 5895a4cc..061e896c 100644 --- a/tests/test_dem.py +++ b/tests/test_dem.py @@ -99,7 +99,7 @@ def test_validate_dem_coverage(): dem.validate_dem_coverage([-100, 30, -101, 31]) # Valid extent over Texas except Exception as e: assert False, f'Unexpected exception for valid DEM extent: {e}' - with raises(ValueError): + with raises(ValueError, match=r'.*not covered by the COP30 DSM.*'): dem.validate_dem_coverage([45, 40, 49, 41]) # Invalid extent over Azerbaijan - with raises(ValueError): + with raises(ValueError, match=r'.*not covered by the COP30 DSM.*'): dem.validate_dem_coverage([-33, 28, -30, 29]) # Invalid extent over the Atlantic Ocean From 6f13b45033dfbe6f495713adfbc8121738246ec2 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 13:48:50 -0500 Subject: [PATCH 10/31] specified exceptions in tests --- tests/test_burst.py | 4 ++-- tests/test_dem.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_burst.py b/tests/test_burst.py index e43fd9a9..861d3bfe 100644 --- a/tests/test_burst.py +++ b/tests/test_burst.py @@ -173,7 +173,7 @@ def test_get_burst_params_multiple_results(): def test_validate_burst_date(): try: burst.validate_burst_date('S1_030349_IW1_20230808T171601_VV_4A37-BURST') - except Exception as e: + except ValueError as e: assert False, f'Unexpected exception for valid date: {e}' with pytest.raises(ValueError, match=r'.*not currently available from ASF.*'): burst.validate_burst_date('S1_030349_IW1_20180808T171601_VV_4A37-BURST') @@ -185,7 +185,7 @@ def test_validate_bursts(): 'S1_030349_IW1_20230808T171601_VV_4A37-BURST', 'S1_030349_IW1_20230820T171602_VV_5AC3-BURST' ) - except Exception as e: + except ValueError as e: assert False, f'Unexpected exception for valid burst pair: {e}' with pytest.raises(ValueError, match=r'.*polarizations are not the same.*'): # different polarizations burst.validate_bursts( diff --git a/tests/test_dem.py b/tests/test_dem.py index 061e896c..e0738683 100644 --- a/tests/test_dem.py +++ b/tests/test_dem.py @@ -97,7 +97,7 @@ def test_distance_meters_to_degrees(): def test_validate_dem_coverage(): try: dem.validate_dem_coverage([-100, 30, -101, 31]) # Valid extent over Texas - except Exception as e: + except ValueError as e: assert False, f'Unexpected exception for valid DEM extent: {e}' with raises(ValueError, match=r'.*not covered by the COP30 DSM.*'): dem.validate_dem_coverage([45, 40, 49, 41]) # Invalid extent over Azerbaijan From 3c0ce79e0c05f60b239b5f9919407be0dbb3a293 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:52:37 +0000 Subject: [PATCH 11/31] update coverage image --- images/coverage.svg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/coverage.svg b/images/coverage.svg index 9f708fe5..2fad913a 100644 --- a/images/coverage.svg +++ b/images/coverage.svg @@ -15,7 +15,7 @@ coverage coverage - 60% - 60% + 62% + 62% From f21807ab8dda6cf935654aba4b78e7a6efaf987a Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 14:07:37 -0500 Subject: [PATCH 12/31] added comment explaining dem coverage api --- src/hyp3_isce2/dem.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hyp3_isce2/dem.py b/src/hyp3_isce2/dem.py index 08eef849..ed10fa8c 100644 --- a/src/hyp3_isce2/dem.py +++ b/src/hyp3_isce2/dem.py @@ -80,6 +80,11 @@ def distance_meters_to_degrees(distance_meters, latitude): def validate_dem_coverage(extent: Tuple[float, float, float, float]): """Check whether the DEM covers the area of interest. + The API used comes from the coordinates section of this page: + https://portal.opentopography.org/raster?opentopoID=OTGMRT.112016.4326.1 + This API returns intersect == True if there is DEM coverage for ANY of the AOI, + and it returns intersect == False if there is no DEM coverage for ALL of the AOI. + Args: extent: The extent of the area of interest. (xmin, ymin, xmax, ymax) From 5cf14e356c23bd0338931f60983415b0881ce324 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 14:47:10 -0500 Subject: [PATCH 13/31] removed comment --- src/hyp3_isce2/burst.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index 933a399b..d32bf3f3 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -415,8 +415,6 @@ def validate_bursts(reference_name, secondary_name): None """ - # TODO: Ensure COP30 DEM Coverage for the Bursts. - validate_burst_date(reference_name) validate_burst_date(secondary_name) From 6cd2c8583102eed1c86d08fd5154034e4250e2ce Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Mon, 21 Aug 2023 14:52:00 -0500 Subject: [PATCH 14/31] removed trailing whitespace for flake8 --- src/hyp3_isce2/dem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyp3_isce2/dem.py b/src/hyp3_isce2/dem.py index ed10fa8c..1e9a82b3 100644 --- a/src/hyp3_isce2/dem.py +++ b/src/hyp3_isce2/dem.py @@ -80,7 +80,7 @@ def distance_meters_to_degrees(distance_meters, latitude): def validate_dem_coverage(extent: Tuple[float, float, float, float]): """Check whether the DEM covers the area of interest. - The API used comes from the coordinates section of this page: + The API used comes from the coordinates section of this page: https://portal.opentopography.org/raster?opentopoID=OTGMRT.112016.4326.1 This API returns intersect == True if there is DEM coverage for ANY of the AOI, and it returns intersect == False if there is no DEM coverage for ALL of the AOI. From 54a3b149fd48903e2211677371a317a03985bbc9 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 22 Aug 2023 12:42:19 -0500 Subject: [PATCH 15/31] removed unnecessary date and dem_coverage checking --- src/hyp3_isce2/burst.py | 25 ------------------------- src/hyp3_isce2/dem.py | 28 ---------------------------- tests/test_burst.py | 9 --------- tests/test_dem.py | 11 ----------- 4 files changed, 73 deletions(-) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index d32bf3f3..f6feb65d 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -382,28 +382,6 @@ def get_burst_params(scene_name: str) -> BurstParams: ) -def validate_burst_date(burst_name): - """Check whether the burst occurs after the date ASF began storing bursts. - - Args: - burst_name: The reference burst name. - - Returns: - None - """ - - # TODO: Get real date. - oldest_burst_date = '20200101' - burst_date = burst_name.split('_')[3][0:8] - - if burst_date < oldest_burst_date: - raise ValueError( - f'Bursts before {oldest_burst_date} are not currently available from ASF. {burst_name} isn\'t available.' - ) - - return None - - def validate_bursts(reference_name, secondary_name): """Check whether the reference and secondary bursts are valid. @@ -415,9 +393,6 @@ def validate_bursts(reference_name, secondary_name): None """ - validate_burst_date(reference_name) - validate_burst_date(secondary_name) - ref_split = reference_name.split('_') sec_split = secondary_name.split('_') diff --git a/src/hyp3_isce2/dem.py b/src/hyp3_isce2/dem.py index 1e9a82b3..a5c54359 100644 --- a/src/hyp3_isce2/dem.py +++ b/src/hyp3_isce2/dem.py @@ -21,7 +21,6 @@ import dem_stitcher import numpy as np import rasterio -import requests from lxml import etree from shapely.geometry import box @@ -77,31 +76,6 @@ def distance_meters_to_degrees(distance_meters, latitude): return (np.round(distance_degrees_lon, 15), np.round(distance_degrees_lat, 15)) -def validate_dem_coverage(extent: Tuple[float, float, float, float]): - """Check whether the DEM covers the area of interest. - - The API used comes from the coordinates section of this page: - https://portal.opentopography.org/raster?opentopoID=OTGMRT.112016.4326.1 - This API returns intersect == True if there is DEM coverage for ANY of the AOI, - and it returns intersect == False if there is no DEM coverage for ALL of the AOI. - - Args: - extent: The extent of the area of interest. (xmin, ymin, xmax, ymax) - - Returns: - None - """ - - xmin, ymin, xmax, ymax = extent - url = 'https://portal.opentopography.org/ajaxRasterJob' - query = f'?action=checkIntersect&opentopoID=OTSDEM.032021.4326.3&x1={xmin}&y1={ymin}&x2={xmax}&y2={ymax}' - res = requests.get(url=url+query) - if res.json()['intersect'] is False: - raise ValueError( - f'The extent {extent} is not covered by the COP30 DSM.' - ) - - def download_dem_for_isce2( extent: list, dem_name: str = 'glo_30', @@ -122,8 +96,6 @@ def download_dem_for_isce2( The path to the downloaded DEM. """ - validate_dem_coverage(extent=extent) - dem_dir = dem_dir or Path('.') dem_dir.mkdir(exist_ok=True, parents=True) diff --git a/tests/test_burst.py b/tests/test_burst.py index 861d3bfe..248358cc 100644 --- a/tests/test_burst.py +++ b/tests/test_burst.py @@ -170,15 +170,6 @@ def test_get_burst_params_multiple_results(): mock_search.assert_called_once_with(product_list=['there are multiple copies of this burst']) -def test_validate_burst_date(): - try: - burst.validate_burst_date('S1_030349_IW1_20230808T171601_VV_4A37-BURST') - except ValueError as e: - assert False, f'Unexpected exception for valid date: {e}' - with pytest.raises(ValueError, match=r'.*not currently available from ASF.*'): - burst.validate_burst_date('S1_030349_IW1_20180808T171601_VV_4A37-BURST') - - def test_validate_bursts(): try: burst.validate_bursts( # valid burst pair diff --git a/tests/test_dem.py b/tests/test_dem.py index e0738683..319b9950 100644 --- a/tests/test_dem.py +++ b/tests/test_dem.py @@ -92,14 +92,3 @@ def test_distance_meters_to_degrees(): dem.distance_meters_to_degrees(20, 90) with raises(ZeroDivisionError): dem.distance_meters_to_degrees(20, -90) - - -def test_validate_dem_coverage(): - try: - dem.validate_dem_coverage([-100, 30, -101, 31]) # Valid extent over Texas - except ValueError as e: - assert False, f'Unexpected exception for valid DEM extent: {e}' - with raises(ValueError, match=r'.*not covered by the COP30 DSM.*'): - dem.validate_dem_coverage([45, 40, 49, 41]) # Invalid extent over Azerbaijan - with raises(ValueError, match=r'.*not covered by the COP30 DSM.*'): - dem.validate_dem_coverage([-33, 28, -30, 29]) # Invalid extent over the Atlantic Ocean From be1eaca206a90aa6c47c25e993c40316df4c0f06 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 22 Aug 2023 12:50:33 -0500 Subject: [PATCH 16/31] ensure granules are VV or HH --- src/hyp3_isce2/burst.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index f6feb65d..469ead43 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -411,4 +411,9 @@ def validate_bursts(reference_name, secondary_name): 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.' + ) + return None From 4d54189ef688263d8ed5bac10c92a8e939bc5679 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 22 Aug 2023 12:54:58 -0500 Subject: [PATCH 17/31] added a test for ensuring supported polarizations --- tests/test_burst.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_burst.py b/tests/test_burst.py index 248358cc..27a53419 100644 --- a/tests/test_burst.py +++ b/tests/test_burst.py @@ -181,10 +181,15 @@ def test_validate_bursts(): with pytest.raises(ValueError, match=r'.*polarizations are not the same.*'): # different polarizations burst.validate_bursts( 'S1_215032_IW2_20230802T144608_VV_7EE2-BURST', - 'S1_215032_IW2_20230721T144607_VH_B3FA-BURST' + 'S1_215032_IW2_20230721T144607_HH_B3FA-BURST' ) with pytest.raises(ValueError, match=r'.*do not share a common BurstID.*'): # different burst ids 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.*'): # incorrect polarizations + burst.validate_bursts( + 'S1_030349_IW1_20230808T171601_VH_4A37-BURST', + 'S1_030349_IW1_20230820T171602_VH_5AC3-BURST' + ) \ No newline at end of file From b7bd217750ac09479ac71820d3b2b4190f1c29cf Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 22 Aug 2023 12:57:48 -0500 Subject: [PATCH 18/31] removed unused import --- src/hyp3_isce2/dem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hyp3_isce2/dem.py b/src/hyp3_isce2/dem.py index a5c54359..fd1490a7 100644 --- a/src/hyp3_isce2/dem.py +++ b/src/hyp3_isce2/dem.py @@ -16,7 +16,6 @@ import site import subprocess from pathlib import Path -from typing import Tuple import dem_stitcher import numpy as np From d19f9ba5ac5a86a6bff30638a6294b8f47c66abb Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Tue, 22 Aug 2023 12:57:57 -0500 Subject: [PATCH 19/31] added newline to eof --- tests/test_burst.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_burst.py b/tests/test_burst.py index 27a53419..82b18396 100644 --- a/tests/test_burst.py +++ b/tests/test_burst.py @@ -192,4 +192,4 @@ def test_validate_bursts(): burst.validate_bursts( 'S1_030349_IW1_20230808T171601_VH_4A37-BURST', 'S1_030349_IW1_20230820T171602_VH_5AC3-BURST' - ) \ No newline at end of file + ) From b628a5b9773bdec43ddfaab30a057ef95f8ee52a Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:26:30 -0500 Subject: [PATCH 20/31] Update src/hyp3_isce2/burst.py Co-authored-by: Jake Herrmann --- src/hyp3_isce2/burst.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index 469ead43..2e55d3e9 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -415,5 +415,3 @@ def validate_bursts(reference_name, secondary_name): raise ValueError( f'{ref_polarization} polarization is not currently supported, only VV and HH.' ) - - return None From 95a8ca5008af8a17dd7685d63ee841eab1cd3ae2 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:26:51 -0500 Subject: [PATCH 21/31] Update src/hyp3_isce2/burst.py Co-authored-by: Jake Herrmann --- src/hyp3_isce2/burst.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index 2e55d3e9..b77d05ed 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -382,7 +382,7 @@ def get_burst_params(scene_name: str) -> BurstParams: ) -def validate_bursts(reference_name, secondary_name): +def validate_bursts(reference_name: str, secondary_name: str) -> None: """Check whether the reference and secondary bursts are valid. Args: From 7fe1a6f5dacf7c6b3e6fc7c2d16276c0a58ca1c8 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:27:05 -0500 Subject: [PATCH 22/31] Update src/hyp3_isce2/burst.py Co-authored-by: Jake Herrmann --- src/hyp3_isce2/burst.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index b77d05ed..c7dbf619 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -403,7 +403,7 @@ def validate_bursts(reference_name: str, secondary_name: str) -> None: if ref_burst_id != sec_burst_id: raise ValueError( - f'The reference and secondary bursts do not share a common BurstID: {ref_burst_id} and {sec_burst_id}.' + f'The reference and secondary burst IDs are not the same: {ref_burst_id} and {sec_burst_id}.' ) if ref_polarization != sec_polarization: From dfb7b0697d0f419e37d13628f9662bae4ba034d0 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:27:29 -0500 Subject: [PATCH 23/31] Update src/hyp3_isce2/burst.py Co-authored-by: Jake Herrmann --- src/hyp3_isce2/burst.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index c7dbf619..f20c17d9 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -398,6 +398,7 @@ def validate_bursts(reference_name: str, secondary_name: str) -> None: ref_burst_id = ref_split[1] sec_burst_id = sec_split[1] + ref_polarization = ref_split[4] sec_polarization = sec_split[4] From ed07bce2e1927210b173606142a8ce8c94f8795d Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:27:48 -0500 Subject: [PATCH 24/31] Update src/hyp3_isce2/burst.py Co-authored-by: Jake Herrmann --- src/hyp3_isce2/burst.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hyp3_isce2/burst.py b/src/hyp3_isce2/burst.py index f20c17d9..ebaebccf 100644 --- a/src/hyp3_isce2/burst.py +++ b/src/hyp3_isce2/burst.py @@ -392,7 +392,6 @@ def validate_bursts(reference_name: str, secondary_name: str) -> None: Returns: None """ - ref_split = reference_name.split('_') sec_split = secondary_name.split('_') From c594c8b8ba221b36092df73bc06af6cc504b8751 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:27:57 -0500 Subject: [PATCH 25/31] Update src/hyp3_isce2/dem.py Co-authored-by: Jake Herrmann --- src/hyp3_isce2/dem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hyp3_isce2/dem.py b/src/hyp3_isce2/dem.py index fd1490a7..fa3f9116 100644 --- a/src/hyp3_isce2/dem.py +++ b/src/hyp3_isce2/dem.py @@ -94,7 +94,6 @@ def download_dem_for_isce2( Returns: The path to the downloaded DEM. """ - dem_dir = dem_dir or Path('.') dem_dir.mkdir(exist_ok=True, parents=True) From 8c8a0084e01cc628248d0748ea6343a53cde0a24 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:31:14 -0500 Subject: [PATCH 26/31] Update tests/test_burst.py Co-authored-by: Jake Herrmann --- tests/test_burst.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/test_burst.py b/tests/test_burst.py index 82b18396..b8fcf50d 100644 --- a/tests/test_burst.py +++ b/tests/test_burst.py @@ -171,13 +171,10 @@ def test_get_burst_params_multiple_results(): def test_validate_bursts(): - try: - burst.validate_bursts( # valid burst pair - 'S1_030349_IW1_20230808T171601_VV_4A37-BURST', - 'S1_030349_IW1_20230820T171602_VV_5AC3-BURST' - ) - except ValueError as e: - assert False, f'Unexpected exception for valid burst pair: {e}' + 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.*'): # different polarizations burst.validate_bursts( 'S1_215032_IW2_20230802T144608_VV_7EE2-BURST', From 88e7345133f6ead6deed947b7896bcb4d659f85e Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:31:30 -0500 Subject: [PATCH 27/31] Update tests/test_burst.py Co-authored-by: Jake Herrmann --- tests/test_burst.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_burst.py b/tests/test_burst.py index b8fcf50d..48ff6f2e 100644 --- a/tests/test_burst.py +++ b/tests/test_burst.py @@ -175,7 +175,7 @@ def test_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.*'): # different polarizations + 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' From 5be11ccb10168892d079e77ffff4b2380c7d3bf3 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:31:37 -0500 Subject: [PATCH 28/31] Update tests/test_burst.py Co-authored-by: Jake Herrmann --- tests/test_burst.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_burst.py b/tests/test_burst.py index 48ff6f2e..127f51f0 100644 --- a/tests/test_burst.py +++ b/tests/test_burst.py @@ -180,7 +180,7 @@ def test_validate_bursts(): 'S1_215032_IW2_20230802T144608_VV_7EE2-BURST', 'S1_215032_IW2_20230721T144607_HH_B3FA-BURST' ) - with pytest.raises(ValueError, match=r'.*do not share a common BurstID.*'): # different burst ids + 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' From e186dd61a771868d7a3b8674b2035a5ae4c898d6 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:31:43 -0500 Subject: [PATCH 29/31] Update tests/test_burst.py Co-authored-by: Jake Herrmann --- tests/test_burst.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_burst.py b/tests/test_burst.py index 127f51f0..7c789e1b 100644 --- a/tests/test_burst.py +++ b/tests/test_burst.py @@ -185,7 +185,7 @@ def test_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.*'): # incorrect polarizations + 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' From b2ca37aecc38a910f6756dd198ef99de42a704b7 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:45:17 -0500 Subject: [PATCH 30/31] Update CHANGELOG.md Co-authored-by: Jake Herrmann --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50b253dc..6ec705ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.7.1] ### Added -* insar_tops_bursts now checks if burst pairs are valid, and that they have COP30 coverage. +* insar_tops_bursts now validates burst pair granule names. ## [0.7.0] ### Added From 43eda7a5e3908a1409dca7ee52b6dcb0b0acd50c Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Wed, 23 Aug 2023 12:47:36 -0500 Subject: [PATCH 31/31] Update CHANGELOG.md Co-authored-by: Jake Herrmann --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ec705ec..ae927f8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.7.1] ### Added -* insar_tops_bursts now validates burst pair granule names. +* insar_tops_burst now validates burst pair granule names. ## [0.7.0] ### Added