Skip to content

Commit

Permalink
Merge branch 'develop' into rename
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestfwilliams committed Aug 12, 2024
2 parents 7624a5d + 5000d16 commit 32fb25e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 38 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ 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).

## [0.6.0]

### Changed
* Orbit files are now retrieved using `fetch_for_scene` from `s1_orbits`.
* ESA Credentials are no longer needed.

## [0.5.2]

### Fixed
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Then, run the docker container for your chosen workflow.
docker run -it --rm \
-e EARTHDATA_USERNAME=[YOUR_USERNAME_HERE] \
-e EARTHDATA_PASSWORD=[YOUR_PASSWORD_HERE] \
-e ESA_USERNAME=[YOUR_USERNAME_HERE] \
-e ESA_PASSWORD=[YOUR_PASSWORD_HERE] \
hyp3-srg:latest \
++process [WORKFLOW_NAME] \
[WORKFLOW_ARGS]
Expand All @@ -30,24 +28,25 @@ Here is an example command for the `back_projection` workflow:
docker run -it --rm \
-e EARTHDATA_USERNAME=[YOUR_USERNAME_HERE] \
-e EARTHDATA_PASSWORD=[YOUR_PASSWORD_HERE] \
<<<<<<< HEAD
-e ESA_USERNAME=[YOUR_USERNAME_HERE] \
-e ESA_PASSWORD=[YOUR_PASSWORD_HERE] \
hyp3-srg:latest \
=======
back-projection:latest \
>>>>>>> develop
++process back_projection \
S1A_IW_RAW__0SDV_20231229T134339_20231229T134411_051870_064437_4F42-RAW \
S1A_IW_RAW__0SDV_20231229T134404_20231229T134436_051870_064437_5F38-RAW
```

## Earthdata Login and ESA Credentials
## Earthdata Login

For all workflows, the user must provide their Earthdata Login credentials and ESA Copernicus Data Space Ecosystem (CDSE) credentials in order to download input data.
For all workflows, the user must provide their Earthdata Login credentials in order to download input data.

If you do not already have an Earthdata account, you can sign up [here](https://urs.earthdata.nasa.gov/home).

If you do not already have a CDSE account, you can sign up [here](https://dataspace.copernicus.eu).

Your credentials can be passed to the workflows via command-line options (`--esa-username` and `--esa-password`), environment variables
(`EARTHDATA_USERNAME`, `EARTHDATA_PASSWORD`, `ESA_USERNAME`, and `ESA_PASSWORD`), or via your `.netrc` file.
Your credentials can be passed to the workflows via environment variables (`EARTHDATA_USERNAME`, `EARTHDATA_PASSWORD`) or via your `.netrc` file.

If you haven't set up a `.netrc` file
before, check out this [guide](https://harmony.earthdata.nasa.gov/docs#getting-started) to get started.
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ dependencies:
- asf_search
# For running
- hyp3lib>=3,<4
- s1_orbits
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classifiers=[
dependencies = [
"hyp3lib>=3,<4",
"asf_search",
"s1_orbits",
]
dynamic = ["version", "readme"]

Expand Down
7 changes: 0 additions & 7 deletions src/hyp3_srg/back_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ def back_project(
granules: Iterable[str],
earthdata_username: str = None,
earthdata_password: str = None,
esa_username: str = None,
esa_password: str = None,
bucket: str = None,
bucket_prefix: str = '',
work_dir: Optional[Path] = None,
Expand All @@ -111,15 +109,12 @@ def back_project(
granules: List of Sentinel-1 level-0 granules to back-project
earthdata_username: Username for NASA's EarthData service
earthdata_password: Password for NASA's EarthData service
esa_username: Username for ESA's Copernicus Data Space Ecosystem
esa_password: Password for ESA's Copernicus Data Space Ecosystem
bucket: AWS S3 bucket for uploading the final product(s)
bucket_prefix: Add a bucket prefix to the product(s)
work_dir: Working directory for processing
gpu: Use the GPU-based version of the workflow
"""
utils.set_creds('EARTHDATA', earthdata_username, earthdata_password)
utils.set_creds('ESA', esa_username, esa_password)
if work_dir is None:
work_dir = Path.cwd()

Expand Down Expand Up @@ -158,8 +153,6 @@ def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--earthdata-username', default=None, help="Username for NASA's EarthData")
parser.add_argument('--earthdata-password', default=None, help="Password for NASA's EarthData")
parser.add_argument('--esa-username', default=None, help="Username for ESA's Copernicus Data Space Ecosystem")
parser.add_argument('--esa-password', default=None, help="Password for ESA's Copernicus Data Space Ecosystem")
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.')
Expand Down
25 changes: 2 additions & 23 deletions src/hyp3_srg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
from zipfile import ZipFile

import asf_search
from hyp3lib.get_orb import downloadSentinelOrbitFile
from s1_orbits import fetch_for_scene
from shapely.geometry import Polygon, shape


log = logging.getLogger(__name__)
ESA_HOST = 'dataspace.copernicus.eu'
EARTHDATA_HOST = 'urs.earthdata.nasa.gov'


Expand Down Expand Up @@ -95,26 +94,6 @@ def find_creds_in_netrc(service) -> Tuple[str, str]:
return None, None


def get_esa_credentials() -> Tuple[str, str]:
"""Get ESA credentials from the environment or netrc file.
Returns:
Tuple of the ESA username and password
"""
username, password = find_creds_in_env('ESA_USERNAME', 'ESA_PASSWORD')
if username and password:
return username, password

username, password = find_creds_in_netrc(ESA_HOST)
if username and password:
return username, password

raise ValueError(
'Please provide Copernicus Data Space Ecosystem (CDSE) credentials via the '
'ESA_USERNAME and ESA_PASSWORD environment variables, or your netrc file.'
)


def get_earthdata_credentials() -> Tuple[str, str]:
"""Get NASA EarthData credentials from the environment or netrc file.
Expand Down Expand Up @@ -186,7 +165,7 @@ def download_orbit(granule_name: str, output_dir: Path) -> Path:
Returns:
Path to the downloaded orbit file
"""
orbit_path, _ = downloadSentinelOrbitFile(granule_name, str(output_dir), esa_credentials=get_esa_credentials())
orbit_path = str(fetch_for_scene(granule_name, dir=output_dir))
return orbit_path


Expand Down

0 comments on commit 32fb25e

Please sign in to comment.