diff --git a/CHANGELOG.md b/CHANGELOG.md index 5079f558..49449f59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ 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). +## [6.1.0] + +### Added +- A `--phase-filter-paameter` option has been added to the `__main__` (HyP3) and `ifm_sentinel.py` entry points to specify the adaptive phase filter parameter used when processing InSAR products. The provided value is ultimately passed to the `alpha` argument of the `adf` GAMMA function, which uses the algorithm with a constant exponent as described in https://doi.org/10.1029/1998GL900033. + ## [6.0.1] ### Fixed diff --git a/hyp3_gamma/__main__.py b/hyp3_gamma/__main__.py index 35d11884..0f1710fc 100644 --- a/hyp3_gamma/__main__.py +++ b/hyp3_gamma/__main__.py @@ -112,6 +112,13 @@ def rtc(): upload_file_to_s3(product_file, args.bucket, args.bucket_prefix) +def phase_filter_valid_range(x: str) -> float: + x = float(x) + if 0.0 < x <= 1.0: + return x + raise ValueError(f'{x} not in range (0.0, 1.0]') + + def insar(): parser = ArgumentParser() parser.add_argument('--username') @@ -126,6 +133,7 @@ def insar(): parser.add_argument('--include-inc-map', type=string_is_true, default=False) parser.add_argument('--apply-water-mask', type=string_is_true, default=False) parser.add_argument('--looks', choices=['20x4', '10x2'], default='20x4') + parser.add_argument('--phase-filter-parameter', type=phase_filter_valid_range, default=0.6) parser.add_argument('granules', type=str.split, nargs='+') args = parser.parse_args() @@ -160,6 +168,7 @@ def insar(): include_wrapped_phase=args.include_wrapped_phase, include_inc_map=args.include_inc_map, apply_water_mask=args.apply_water_mask, + phase_filter_parameter=args.phase_filter_parameter ) output_zip = make_archive(base_name=product_name, format='zip', base_dir=product_name) diff --git a/hyp3_gamma/insar/ifm_sentinel.py b/hyp3_gamma/insar/ifm_sentinel.py index 6c5b3a1e..7ac025e5 100755 --- a/hyp3_gamma/insar/ifm_sentinel.py +++ b/hyp3_gamma/insar/ifm_sentinel.py @@ -233,7 +233,8 @@ def move_output_files(output, reference, prod_dir, long_output, include_displace "{}_unw_phase".format(os.path.join(prod_dir, long_output)), use_nn=True) -def make_parameter_file(mydir, parameter_file_name, alooks, rlooks, dem_source, coords, ref_point_info): +def make_parameter_file(mydir, parameter_file_name, alooks, rlooks, dem_source, coords, + ref_point_info, phase_filter_parameter): res = 20 * int(alooks) reference_date = mydir[:15] @@ -316,7 +317,7 @@ def make_parameter_file(mydir, parameter_file_name, alooks, rlooks, dem_source, f.write('Range looks: %s\n' % rlooks) f.write('Azimuth looks: %s\n' % alooks) f.write('INSAR phase filter: adf\n') - f.write('Phase filter parameter: 0.6\n') + f.write('Phase filter parameter: %s\n' % phase_filter_parameter) f.write('Resolution of output (m): %s\n' % res) f.write('Range bandpass filter: no\n') f.write('Azimuth bandpass filter: no\n') @@ -336,7 +337,7 @@ def make_parameter_file(mydir, parameter_file_name, alooks, rlooks, dem_source, def insar_sentinel_gamma(reference_file, secondary_file, rlooks=20, alooks=4, include_look_vectors=False, include_displacement_maps=False, include_wrapped_phase=False, include_inc_map=False, - include_dem=False, apply_water_mask=False): + include_dem=False, apply_water_mask=False, phase_filter_parameter=0.6): log.info("\n\nSentinel-1 differential interferogram creation program\n") wrk = os.getcwd() @@ -419,7 +420,7 @@ def insar_sentinel_gamma(reference_file, secondary_file, rlooks=20, alooks=4, in log.info("Starting phase unwrapping and geocoding") coords, ref_point_info = unwrapping_geocoding(reference, secondary, step="man", rlooks=rlooks, alooks=alooks, - apply_water_mask=apply_water_mask) + alpha=phase_filter_parameter, apply_water_mask=apply_water_mask) # Generate metadata log.info("Collecting metadata and output files") @@ -454,7 +455,7 @@ def insar_sentinel_gamma(reference_file, secondary_file, rlooks=20, alooks=4, in execute(f"base_init {reference}.slc.par {secondary}.slc.par - - base > baseline.log", uselogging=True) make_parameter_file(igramName, f'{product_name}/{product_name}.txt', alooks, rlooks, - dem_source, coords, ref_point_info) + dem_source, coords, ref_point_info, phase_filter_parameter) log.info("Done!!!") return product_name @@ -476,6 +477,8 @@ def main(): parser.add_argument("-s", action="store_true", help="Create both line of sight and vertical displacement files") parser.add_argument("-w", action="store_true", help="Create wrapped phase file") parser.add_argument("-m", action="store_true", help="Apply water mask") + parser.add_argument("-p", "--phase-filter-parameter", default=0.6, help="Adaptive phase filter parameter") + args = parser.parse_args() logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', @@ -484,7 +487,8 @@ def main(): insar_sentinel_gamma(args.reference, args.secondary, rlooks=args.rlooks, alooks=args.alooks, include_look_vectors=args.l, include_displacement_maps=args.s, include_wrapped_phase=args.w, include_inc_map=args.i, - include_dem=args.d, apply_water_mask=args.m) + include_dem=args.d, apply_water_mask=args.m, + phase_filter_parameter=args.phase_filter_parameter) if __name__ == "__main__":