Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPlayer3 committed Sep 19, 2024
1 parent 7358e60 commit 2de20d5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/hyp3_srg/back_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion src/hyp3_srg/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion src/hyp3_srg/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down
3 changes: 1 addition & 2 deletions tests/test_dem.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 2de20d5

Please sign in to comment.