From 2de20d5d3e98cd64f43752117d1d200381612f05 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Thu, 19 Sep 2024 10:22:47 -0500 Subject: [PATCH] refactoring --- src/hyp3_srg/back_projection.py | 6 ++++-- src/hyp3_srg/dem.py | 4 +++- src/hyp3_srg/time_series.py | 4 +++- tests/test_dem.py | 3 +-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/hyp3_srg/back_projection.py b/src/hyp3_srg/back_projection.py index c1ab2c4..9ac63fc 100644 --- a/src/hyp3_srg/back_projection.py +++ b/src/hyp3_srg/back_projection.py @@ -118,7 +118,7 @@ def back_project( orbit_path = utils.download_orbit(granule, work_dir) bboxs.append(granule_bbox) granule_orbit_pairs.append((granule_path, orbit_path)) - if bounds == None: + if bounds is None: full_bbox = unary_union(bboxs).buffer(0.1) dem_path = dem.download_dem_for_srg(full_bbox, work_dir) else: @@ -150,7 +150,9 @@ def main(): parser.add_argument('--bucket', help='AWS S3 bucket HyP3 for upload the final product(s)') parser.add_argument('--bucket-prefix', default='', help='Add a bucket prefix to product(s)') parser.add_argument('--gpu', default=False, action='store_true', help='Use the GPU-based version of the workflow.') - parser.add_argument('--bounds', default=None, type=float, nargs=4, help='Bounds for DEM (max lat, min lat, min lon, max lon)') + parser.add_argument( + '--bounds', default=None, type=float, nargs=4, help='Bounds for DEM (max lat, min lat, min lon, max lon)' + ) parser.add_argument('granules', type=str.split, nargs='+', help='Level-0 S1 granule(s) to back-project.') args = parser.parse_args() args.granules = [item for sublist in args.granules for item in sublist] diff --git a/src/hyp3_srg/dem.py b/src/hyp3_srg/dem.py index 1556eb9..e559631 100644 --- a/src/hyp3_srg/dem.py +++ b/src/hyp3_srg/dem.py @@ -56,7 +56,9 @@ def download_dem_from_bounds(bounds: list[float], work_dir: Optional[Path]): The path to the downloaded DEM """ if (bounds[0] <= bounds[1] or bounds[2] >= bounds[3]): - raise ValueError("Improper bounding box formatting, should be [max latitude, min latitude, min longitude, max longitude].") + raise ValueError( + "Improper bounding box formatting, should be [max latitude, min latitude, min longitude, max longitude]." + ) dem_path = work_dir / 'elevation.dem' dem_rsc = work_dir / 'elevation.dem.rsc' diff --git a/src/hyp3_srg/time_series.py b/src/hyp3_srg/time_series.py index 64a39cf..6420022 100644 --- a/src/hyp3_srg/time_series.py +++ b/src/hyp3_srg/time_series.py @@ -310,7 +310,9 @@ def main(): S1A_IW_RAW__0SDV_20231229T134404_20231229T134436_051870_064437_5F38.geo """ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument('--bounds', default=None, type=float, nargs=4, help='Bounds for DEM (max lat, min lat, min lon, max lon)') + parser.add_argument( + '--bounds', default=None, type=float, nargs=4, help='Bounds for DEM (max lat, min lat, min lon, max lon)' + ) parser.add_argument('--bucket', help='AWS S3 bucket HyP3 for upload the final product(s)') parser.add_argument('--bucket-prefix', default='', help='Add a bucket prefix to product(s)') parser.add_argument('granules', type=str.split, nargs='+', help='GSLC granules.') diff --git a/tests/test_dem.py b/tests/test_dem.py index 4a35c0f..5d37af7 100644 --- a/tests/test_dem.py +++ b/tests/test_dem.py @@ -1,8 +1,7 @@ -import pytest - from pathlib import Path from unittest import mock +import pytest from shapely.geometry import box from hyp3_srg import dem, utils