Skip to content

Commit

Permalink
check if bucket and bucket_prefix given in back_projection workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jtherrmann committed Oct 9, 2024
1 parent f06485c commit 0081c55
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/hyp3_srg/back_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def back_project(
earthdata_password: str = None,
bucket: str = None,
bucket_prefix: str = '',
use_gslc_prefix: bool = False,
work_dir: Optional[Path] = None,
gpu: bool = False,
):
Expand All @@ -104,9 +105,15 @@ def back_project(
earthdata_password: Password for NASA's EarthData service
bucket: AWS S3 bucket for uploading the final product(s)
bucket_prefix: Add a bucket prefix to the product(s)
use_gslc_prefix: Upload GSLCs to a subprefix
work_dir: Working directory for processing
gpu: Use the GPU-based version of the workflow
"""
if use_gslc_prefix:
if not (bucket and bucket_prefix):
raise ValueError('bucket and bucket_prefix must be given if use_gslc_prefix is True')
bucket_prefix += '/GSLC_granules'

utils.set_creds('EARTHDATA', earthdata_username, earthdata_password)
if work_dir is None:
work_dir = Path.cwd()
Expand Down Expand Up @@ -167,17 +174,12 @@ def main():
)
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]

if args.bounds is not None:
args.bounds = [float(item) for sublist in args.bounds for item in sublist]
if len(args.bounds) != 4:
parser.error('Bounds must have exactly 4 values: [min lon, min lat, max lon, max lat] in EPSG:4326.')

if args.use_gslc_prefix:
args.bucket_prefix += '/GSLC_granules'

back_project(**args.__dict__)


Expand Down

0 comments on commit 0081c55

Please sign in to comment.