diff --git a/CHANGELOG.md b/CHANGELOG.md index d2fd8321..6e276393 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). +## [9.0.0] +### Changed +- Orbit files are now retrieved using the [s1-orbits](https://github.com/ASFHyP3/sentinel1-orbits-py) library. +### Removed +- Removed support for the `--esa-username` and `--esa-password` command-line options and the `ESA_USERNAME` and `ESA_PASSWORD` environment variables. ## [8.2.0] ### Changed diff --git a/README.md b/README.md index 48669544..28c635f8 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ rtc_sentinel.py S1A_IW_SLC__1SSV_20150621T120220_20150621T120232_006471_008934_7 To run the RTC process through the HyP3 interface: ``` hyp3_gamma ++process rtc --help -hyp3_gamma ++process rtc --username ${EDL_USERNAME} --password ${EDL_PASSWORD} --esa-username ${ESA_USERNAME} --esa-password ${ESA_PASSWORD} \ +hyp3_gamma ++process rtc --username ${EDL_USERNAME} --password ${EDL_PASSWORD} \ S1A_IW_SLC__1SSV_20150621T120220_20150621T120232_006471_008934_72D8 ``` @@ -59,7 +59,7 @@ ifm_sentinel.py \ To run the InSAR process through the HyP3 interface: ``` hyp3_gamma ++process insar --help -hyp3_gamma ++process insar --username ${EDL_USERNAME} --password ${EDL_PASSWORD} --esa-username ${ESA_USERNAME} --esa-password ${ESA_PASSWORD} \ +hyp3_gamma ++process insar --username ${EDL_USERNAME} --password ${EDL_PASSWORD} \ S1A_IW_SLC__1SDV_20200203T172103_20200203T172122_031091_03929B_3048 \ S1A_IW_SLC__1SDV_20200110T172104_20200110T172123_030741_03864E_A996 ``` diff --git a/hyp3_gamma/__main__.py b/hyp3_gamma/__main__.py index e5817378..0e35bd8f 100644 --- a/hyp3_gamma/__main__.py +++ b/hyp3_gamma/__main__.py @@ -9,7 +9,6 @@ from importlib.metadata import entry_points from pathlib import Path from shutil import make_archive -from typing import Optional from hyp3lib.aws import upload_file_to_s3 from hyp3lib.fetch import write_credentials_to_netrc_file @@ -60,30 +59,10 @@ def check_earthdata_credentials(username, password): return username, password -def check_esa_credentials(username: Optional[str], password: Optional[str]) -> None: - if username is not None: - os.environ['ESA_USERNAME'] = username - elif 'ESA_USERNAME' not in os.environ: - raise ValueError( - 'Please provide Copernicus Data Space Ecosystem (CDSE) username via the --esa-username option ' - 'or the ESA_USERNAME environment variable.' - ) - - if password is not None: - os.environ['ESA_PASSWORD'] = password - elif 'ESA_PASSWORD' not in os.environ: - raise ValueError( - 'Please provide Copernicus Data Space Ecosystem (CDSE) password via the --esa-password option ' - 'or the ESA_PASSWORD environment variable.' - ) - - def rtc(): parser = ArgumentParser() parser.add_argument('--username') parser.add_argument('--password') - parser.add_argument('--esa-username') - parser.add_argument('--esa-password') parser.add_argument('--bucket') parser.add_argument('--bucket-prefix', default='') parser.add_argument('--resolution', type=float, choices=[10.0, 20.0, 30.0], default=30.0) @@ -100,7 +79,6 @@ def rtc(): args = parser.parse_args() username, password = check_earthdata_credentials(args.username, args.password) - check_esa_credentials(args.esa_username, args.esa_password) logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO) @@ -146,8 +124,6 @@ def insar(): parser = ArgumentParser() parser.add_argument('--username') parser.add_argument('--password') - parser.add_argument('--esa-username') - parser.add_argument('--esa-password') parser.add_argument('--bucket') parser.add_argument('--bucket-prefix', default='') parser.add_argument('--include-dem', type=string_is_true, default=False) @@ -163,7 +139,6 @@ def insar(): args = parser.parse_args() username, password = check_earthdata_credentials(args.username, args.password) - check_esa_credentials(args.esa_username, args.esa_password) # TODO: Remove `--include-los-displacement` and this logic once it's no longer supported by the HyP3 API args.include_displacement_maps = args.include_displacement_maps | args.include_los_displacement diff --git a/hyp3_gamma/insar/ifm_sentinel.py b/hyp3_gamma/insar/ifm_sentinel.py index 3e964902..35c40420 100755 --- a/hyp3_gamma/insar/ifm_sentinel.py +++ b/hyp3_gamma/insar/ifm_sentinel.py @@ -15,11 +15,11 @@ from hyp3lib.SLC_copy_S1_fullSW import SLC_copy_S1_fullSW from hyp3lib.execute import execute from hyp3lib.getParameter import getParameter -from hyp3lib.get_orb import downloadSentinelOrbitFile from hyp3lib.makeAsfBrowse import makeAsfBrowse from hyp3lib.par_s1_slc_single import par_s1_slc_single from hyp3lib.system import gamma_version from lxml import etree, objectify +from s1_orbits import fetch_for_scene import hyp3_gamma from hyp3_gamma.insar.getDemFileGamma import get_dem_file_gamma @@ -342,7 +342,6 @@ def insar_sentinel_gamma(reference_file, secondary_file, rlooks=20, alooks=4, in include_dem=False, apply_water_mask=False, phase_filter_parameter=0.6): log.info("\n\nSentinel-1 differential interferogram creation program\n") - esa_credentials = (os.environ['ESA_USERNAME'], os.environ['ESA_PASSWORD']) wrk = os.getcwd() reference_date = reference_file[17:32] reference = reference_file[17:25] @@ -363,8 +362,8 @@ def insar_sentinel_gamma(reference_file, secondary_file, rlooks=20, alooks=4, in orbit_files = [] for granule in (reference_file, secondary_file): log.info(f'Downloading orbit file for {granule}') - orbit_file, provider = downloadSentinelOrbitFile(granule, esa_credentials=esa_credentials) - log.info(f'Got orbit file {orbit_file} from provider {provider}') + orbit_file = str(fetch_for_scene(granule)) + log.info(f'Got orbit file {orbit_file} from s1_orbits') par_s1_slc_single(granule, pol, os.path.abspath(orbit_file)) orbit_files.append(orbit_file) diff --git a/hyp3_gamma/rtc/rtc_sentinel.py b/hyp3_gamma/rtc/rtc_sentinel.py index 9d0f4eb7..6f7c253e 100755 --- a/hyp3_gamma/rtc/rtc_sentinel.py +++ b/hyp3_gamma/rtc/rtc_sentinel.py @@ -14,19 +14,19 @@ from typing import List import numpy as np -from hyp3lib import DemError, ExecuteError, GranuleError, OrbitDownloadError +from hyp3lib import DemError, ExecuteError, GranuleError from hyp3lib import saa_func_lib as saa from hyp3lib.byteSigmaScale import byteSigmaScale from hyp3lib.createAmp import createAmp from hyp3lib.execute import execute from hyp3lib.getParameter import getParameter -from hyp3lib.get_orb import downloadSentinelOrbitFile from hyp3lib.makeAsfBrowse import makeAsfBrowse from hyp3lib.make_cogs import cogify_dir from hyp3lib.raster_boundary2shape import raster_boundary2shape from hyp3lib.rtc2color import rtc2color from hyp3lib.system import gamma_version from osgeo import gdal, gdalconst, ogr +from s1_orbits import OrbitNotFoundError, fetch_for_scene import hyp3_gamma from hyp3_gamma.dem import get_geometry_from_kml, prepare_dem_geotiff @@ -308,7 +308,6 @@ def rtc_sentinel_gamma(safe_dir: str, resolution: float = 30.0, radiometry: str product_name: Name of the output product directory """ - esa_credentials = (os.environ['ESA_USERNAME'], os.environ['ESA_PASSWORD']) safe_dir = safe_dir.rstrip('/') granule = os.path.splitext(os.path.basename(safe_dir))[0] granule_type = get_granule_type(granule) @@ -316,9 +315,9 @@ def rtc_sentinel_gamma(safe_dir: str, resolution: float = 30.0, radiometry: str try: log.info(f'Downloading orbit file for {granule}') - orbit_file, provider = downloadSentinelOrbitFile(granule, esa_credentials=esa_credentials) - log.info(f'Got orbit file {orbit_file} from provider {provider}') - except OrbitDownloadError as e: + orbit_file = str(fetch_for_scene(granule)) + log.info(f'Got orbit file {orbit_file} from s1-orbits.') + except OrbitNotFoundError as e: log.warning(e) log.warning(f'Proceeding using original predicted orbit data included with {granule}') orbit_file = None diff --git a/requirements.txt b/requirements.txt index 50b4314b..f5ba6591 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,3 +15,4 @@ pillow==10.4.0 pyproj==3.6.1 python-dateutil==2.9.0.post0 rtree==1.3.0 +s1_orbits==0.1.1