From 317c602a593aa1358e8e0dce08b6c21bec13b41e Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Fri, 13 Oct 2023 12:07:37 -0800 Subject: [PATCH 1/6] Add `phase_filter_parameter` for InSAR jobs --- src/hyp3_sdk/hyp3.py | 17 +++++++++++++++-- tests/test_hyp3.py | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index 8cce8e9..16f6706 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -335,7 +335,8 @@ def submit_insar_job(self, include_dem: bool = False, include_wrapped_phase: bool = False, apply_water_mask: bool = False, - include_displacement_maps: bool = False) -> Batch: + include_displacement_maps: bool = False, + phase_filter_parameter: float = 0.6) -> Batch: """Submit an InSAR job Args: @@ -353,6 +354,9 @@ def submit_insar_job(self, apply_water_mask: Sets pixels over coastal waters and large inland waterbodies as invalid for phase unwrapping include_displacement_maps: Include displacement maps (line-of-sight and vertical) in the product package + phase_filter_parameter: Adaptive phase filter exponent (alpha). + Larger values result in more aggressive filtering. If zero, adaptive phase filter will be skipped. + We recommend against values less than 0.2, or values with more than two decimal places of precision. Returns: A Batch object containing the InSAR job @@ -374,7 +378,8 @@ def prepare_insar_job(cls, include_dem: bool = False, include_wrapped_phase: bool = False, apply_water_mask: bool = False, - include_displacement_maps: bool = False) -> dict: + include_displacement_maps: bool = False, + phase_filter_parameter: float = 0.6) -> dict: """Submit an InSAR job Args: @@ -392,9 +397,17 @@ def prepare_insar_job(cls, apply_water_mask: Sets pixels over coastal waters and large inland waterbodies as invalid for phase unwrapping include_displacement_maps: Include displacement maps (line-of-sight and vertical) in the product package + phase_filter_parameter: Adaptive phase filter exponent (alpha). + Larger values result in more aggressive filtering. If zero, adaptive phase filter will be skipped. + We recommend against values less than 0.2, or values with more than two decimal places of precision. + Returns: A dictionary containing the prepared InSAR job """ + # TODO do we actually need this, or do we normally allow the API to validate values? + if phase_filter_parameter < 0.0 or phase_filter_parameter > 1.0: + raise ValueError(f'Expected phase_filter_parameter in range [0.0, 1.0] but got {phase_filter_parameter}') + if include_los_displacement: warnings.warn('The include_los_displacement parameter has been deprecated in favor of ' 'include_displacement_maps, and will be removed in a future release.', FutureWarning) diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index 041f711..af23d0a 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -259,6 +259,7 @@ def test_prepare_rtc_job(): } +# TODO add phase_filter_parameter, including test for ValueError def test_prepare_insar_job(): assert HyP3.prepare_insar_job(granule1='my_granule1', granule2='my_granule2') == { 'job_type': 'INSAR_GAMMA', From 810a233f1b0a5726e77df2c2b4237012cbed52f5 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Thu, 19 Oct 2023 10:32:49 -0800 Subject: [PATCH 2/6] remove unnecessary value error --- src/hyp3_sdk/hyp3.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index 16f6706..583605a 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -404,10 +404,6 @@ def prepare_insar_job(cls, Returns: A dictionary containing the prepared InSAR job """ - # TODO do we actually need this, or do we normally allow the API to validate values? - if phase_filter_parameter < 0.0 or phase_filter_parameter > 1.0: - raise ValueError(f'Expected phase_filter_parameter in range [0.0, 1.0] but got {phase_filter_parameter}') - if include_los_displacement: warnings.warn('The include_los_displacement parameter has been deprecated in favor of ' 'include_displacement_maps, and will be removed in a future release.', FutureWarning) From f8be61f7ae5f8e8e2245f62f953cf5df029d85c9 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Thu, 19 Oct 2023 10:33:32 -0800 Subject: [PATCH 3/6] update todo --- tests/test_hyp3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index af23d0a..4e6388d 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -259,7 +259,7 @@ def test_prepare_rtc_job(): } -# TODO add phase_filter_parameter, including test for ValueError +# TODO add phase_filter_parameter def test_prepare_insar_job(): assert HyP3.prepare_insar_job(granule1='my_granule1', granule2='my_granule2') == { 'job_type': 'INSAR_GAMMA', From 69612086b0e065c8ece3e4e540745b11261d318e Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Thu, 19 Oct 2023 13:44:31 -0800 Subject: [PATCH 4/6] Add `phase_filter_parameter` to tests --- tests/test_hyp3.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_hyp3.py b/tests/test_hyp3.py index 4e6388d..b2305b2 100644 --- a/tests/test_hyp3.py +++ b/tests/test_hyp3.py @@ -259,7 +259,6 @@ def test_prepare_rtc_job(): } -# TODO add phase_filter_parameter def test_prepare_insar_job(): assert HyP3.prepare_insar_job(granule1='my_granule1', granule2='my_granule2') == { 'job_type': 'INSAR_GAMMA', @@ -273,12 +272,13 @@ def test_prepare_insar_job(): 'include_wrapped_phase': False, 'apply_water_mask': False, 'include_displacement_maps': False, + 'phase_filter_parameter': 0.6, } } assert HyP3.prepare_insar_job(granule1='my_granule1', granule2='my_granule2', name='my_name', looks='10x2', include_los_displacement=True, include_look_vectors=True, include_inc_map=True, include_dem=True, include_wrapped_phase=True, apply_water_mask=True, - include_displacement_maps=True) == { + include_displacement_maps=True, phase_filter_parameter=0.4) == { 'job_type': 'INSAR_GAMMA', 'name': 'my_name', 'job_parameters': { @@ -291,6 +291,7 @@ def test_prepare_insar_job(): 'include_wrapped_phase': True, 'apply_water_mask': True, 'include_displacement_maps': True, + 'phase_filter_parameter': 0.4, }, } From e282478d5022583f34b61fb7652b7b529ff96dfd Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Thu, 19 Oct 2023 13:48:11 -0800 Subject: [PATCH 5/6] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6251c83..63ffe51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ 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). +## [3.1.0] +### Added +* Added the `phase_filter_parameter` keyword argument for the `HyP3.submit_insar_job` and `HyP3.prepare_insar_job` methods. + ## [3.0.0] ### Removed * Removed the `Job.subscription_id` attribute in response to the Subscriptions feature being removed from HyP3. From 086fe4db3fab52fa6562c11a6ee38d8a3fcc196f Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Mon, 23 Oct 2023 12:16:50 -0800 Subject: [PATCH 6/6] update `phase_filter_parameter` docstrings --- src/hyp3_sdk/hyp3.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/hyp3_sdk/hyp3.py b/src/hyp3_sdk/hyp3.py index 583605a..1ccae8a 100644 --- a/src/hyp3_sdk/hyp3.py +++ b/src/hyp3_sdk/hyp3.py @@ -354,9 +354,10 @@ def submit_insar_job(self, apply_water_mask: Sets pixels over coastal waters and large inland waterbodies as invalid for phase unwrapping include_displacement_maps: Include displacement maps (line-of-sight and vertical) in the product package - phase_filter_parameter: Adaptive phase filter exponent (alpha). - Larger values result in more aggressive filtering. If zero, adaptive phase filter will be skipped. - We recommend against values less than 0.2, or values with more than two decimal places of precision. + phase_filter_parameter: Adaptive phase filter parameter. + Useful values fall in the range 0.2 to 1. + Larger values result in stronger filtering. + If zero, adaptive phase filter will be skipped. Returns: A Batch object containing the InSAR job @@ -397,9 +398,10 @@ def prepare_insar_job(cls, apply_water_mask: Sets pixels over coastal waters and large inland waterbodies as invalid for phase unwrapping include_displacement_maps: Include displacement maps (line-of-sight and vertical) in the product package - phase_filter_parameter: Adaptive phase filter exponent (alpha). - Larger values result in more aggressive filtering. If zero, adaptive phase filter will be skipped. - We recommend against values less than 0.2, or values with more than two decimal places of precision. + phase_filter_parameter: Adaptive phase filter parameter. + Useful values fall in the range 0.2 to 1. + Larger values result in stronger filtering. + If zero, adaptive phase filter will be skipped. Returns: A dictionary containing the prepared InSAR job