Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.1.0 #4

Merged
merged 37 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f943172
working first version of browse imagery
forrestfwilliams May 29, 2024
d676583
update changelog
forrestfwilliams May 29, 2024
bac690a
mild refactoring
forrestfwilliams May 29, 2024
0ca0aec
fix main entrypoint
forrestfwilliams May 29, 2024
476f421
add auth tests
forrestfwilliams May 29, 2024
fe629ba
refactor for quicker debug
forrestfwilliams May 29, 2024
4661a46
add browse creation tests
forrestfwilliams May 29, 2024
e3b442b
update readme
forrestfwilliams May 29, 2024
1b30f8a
remove intermediate data
forrestfwilliams May 29, 2024
83f987b
Apply suggestions from code review
forrestfwilliams May 29, 2024
a29fff3
makes bounds configurable
forrestfwilliams May 29, 2024
f312889
remove unused earthdata arguments
forrestfwilliams May 29, 2024
c0fb7f5
fix broken test
forrestfwilliams May 29, 2024
10825ec
Merge pull request #1 from ASFHyP3/create_browse
forrestfwilliams May 30, 2024
04690a8
add todos
forrestfwilliams May 31, 2024
aad6f40
adjust threshold values
hjkristenson May 31, 2024
77210c5
remove TODOs
hjkristenson May 31, 2024
bf554fc
change thresholds in the test script
hjkristenson May 31, 2024
34fe6a5
Merge pull request #2 from ASFHyP3/thresholds
forrestfwilliams May 31, 2024
6c89bc0
update dependencies
forrestfwilliams Jun 4, 2024
1fe4ef1
Merge pull request #5 from ASFHyP3/deps
forrestfwilliams Jun 4, 2024
747668a
remove hyp3lib dependency in favor of boto3
asjohnston-asf Jun 4, 2024
be3c515
Merge branch 'develop' into no-hyp3lib
asjohnston-asf Jun 4, 2024
8aff710
Merge pull request #6 from ASFHyP3/no-hyp3lib
asjohnston-asf Jun 4, 2024
854ecfd
remove unused or uneeded functionality
forrestfwilliams Jun 4, 2024
e2c0bd3
update changelog
forrestfwilliams Jun 4, 2024
a1616e7
update pyproject
forrestfwilliams Jun 4, 2024
1474a86
use python 3.10 typehints instead of typing library
asjohnston-asf Jun 4, 2024
e3ce525
update python versions used for pytest
asjohnston-asf Jun 4, 2024
caa6d0e
remove issue templates
asjohnston-asf Jun 4, 2024
3114101
remove empty conftest.py
asjohnston-asf Jun 4, 2024
36f1c4e
Merge pull request #8 from ASFHyP3/remove
forrestfwilliams Jun 4, 2024
aea52bd
Merge pull request #9 from ASFHyP3/typing
asjohnston-asf Jun 4, 2024
ab3c4ca
Merge pull request #10 from ASFHyP3/rm-templates
asjohnston-asf Jun 4, 2024
9547e7d
Merge pull request #11 from ASFHyP3/rm-conftest
asjohnston-asf Jun 4, 2024
0d2a1db
fix suggestions from release review
forrestfwilliams Jun 4, 2024
cad6266
Merge pull request #12 from ASFHyP3/review
jtherrmann Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]
with:
release_prefix: HyP3 opera-rtc-s1-browse
release_prefix: opera-rtc-s1-browse
release_branch: main
develop_branch: develop
sync_pr_label: actions-bot
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ jobs:
uses: ASFHyP3/actions/.github/workflows/[email protected]
with:
local_package_name: opera_rtc_s1_browse
python_versions: >-
["3.10", "3.11", "3.12"]
1 change: 0 additions & 1 deletion .trufflehog.txt

This file was deleted.

8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +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).

## [0.1.0](opera-rtc-s1-browse/compare/v0.0.0...v0.1.0) -- unreleased
## [0.1.0]

### Added
* RTC granule download functionality
* Browse image creation functionality

### Removed
* Unused functionality created during HyP3-Cookiecutter setup
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
# opera-rtc-s1-browse

A tool for create OPERA RTC S1 browse images
A tool for creating OPERA RTC Sentinel-1 browse images for [NASA Worldview](https://worldview.earthdata.nasa.gov).

## Usage
Once installed (see below for details) you can run the tool using the command:
```bash
python -m opera_rtc_s1_browse OPERA_L2_RTC-S1_T035-073251-IW2_20240113T020816Z_20240113T113128Z_S1A_30_v1.0
```
Where you replace `OPERA_L2_RTC-S1_T035-073251-IW2_20240113T020816Z_20240113T113128Z_S1A_30_v1.0` with the name of OPERA RTC S1 product you want to create a browse image for.

To explore the available options, run:
```bash
python -m opera_rtc_s1_browse --help
```
These options allow you to specify an AWS S3 bucket path where the browse image will be uploaded.

## Setup
### Installation
1. Ensure that conda is installed on your system (we recommend using [mambaforge](https://github.com/conda-forge/miniforge#mambaforge) to reduce setup times).
2. Download a local version of the `opera-s1-rtc-browse` repository (`git clone https://github.com/ASFHyP3/opera_rtc_s1_browse.git`)
3. In the base directory for this project, call `mamba env create -f environment.yml` to create your Python environment and activate it (`mamba activate opera-s1-rtc-browse`)
4. Finally, install a development version of the package (`python -m pip install -e .`)

To run all commands in sequence use:
```bash
git clone https://github.com/ASFHyP3/opera-s1-rtc-browse.git
cd opera-s1-rtc-browse
mamba env create -f environment.yml
mamba activate opera-s1-rtc-browse
python -m pip install -e .
```

### Credentials
To use `opera_rtc_s1_browse`, you must provide your Earthdata Login credentials via two environment variables (`EARTHDATA_USERNAME` and `EARTHDATA_PASSWORD`), or via your `.netrc` file.

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

If you would like to set up Earthdata Login via your `.netrc` file, check out this [guide](https://harmony.earthdata.nasa.gov/docs#getting-started) to get started.

To use the S3 upload functionality, you will also need to have [AWS credentials configured](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) that have permission to write to the specified S3 bucket.

## License
`opera-rtc-s1-browse` is licensed under the BSD 2-Clause License. See the LICENSE file for more details.

## Contributing
Contributions to this project are welcome! If you would like to contribute, please submit a pull request on the GitHub repository.

## Contact Us
Want to talk about `opera-rtc-s1-browse`? We would love to hear from you!

Found a bug? Want to request a feature?
[open an issue](https://github.com/ASFHyP3/opera-rtc-s1-browse/issues/new)

General questions? Suggestions? Or just want to talk to the team?
[chat with us on gitter](https://gitter.im/ASFHyP3/community)
16 changes: 5 additions & 11 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ channels:
- conda-forge
- nodefaults
dependencies:
- python>=3.8
- python>=3.10
- pip
# For running
- asf_search
- boto3
- gdal
# For packaging, and testing
- flake8
- flake8-import-order
- flake8-blind-except
- flake8-builtins
- setuptools
- setuptools_scm
- wheel
- pytest
- pytest-console-scripts
- pytest-cov
# For running
- hyp3lib>=3,<4
18 changes: 8 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,29 @@ classifiers=[
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"hyp3lib>=3,<4",
# insert python dependencies as list here
"asf_search",
"boto3",
"gdal",
]
dynamic = ["version", "readme"]

[project.optional-dependencies]
develop = [
"flake8",
"flake8-import-order",
"flake8-blind-except",
"flake8-builtins",
"pytest",
"pytest-cov",
"pytest-console-scripts",
]

[project.urls]
Homepage = "opera-rtc-s1-browse"
Documentation = "https://hyp3-docs.asf.alaska.edu"
Documentation = "https://github.com/asfhyp3/opera-rtc-s1-browse#opera-rtc-s1-browse"

[project.scripts]
create_browse = "opera_rtc_s1_browse.create_browse:main"

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down
9 changes: 0 additions & 9 deletions src/opera_rtc_s1_browse/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
"""A tool for create OPERA RTC S1 browse images"""

from importlib.metadata import version

__version__ = version(__name__)

__all__ = [
'__version__',
]
44 changes: 0 additions & 44 deletions src/opera_rtc_s1_browse/__main__.py

This file was deleted.

77 changes: 77 additions & 0 deletions src/opera_rtc_s1_browse/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import netrc
import os
from pathlib import Path
from platform import system
from typing import Tuple


EARTHDATA_HOST = 'urs.earthdata.nasa.gov'


def get_netrc() -> Path:
"""Get the location of the netrc file.

Returns:
Path to the netrc file
"""
netrc_name = '_netrc' if system().lower() == 'windows' else '.netrc'
netrc_file = Path.home() / netrc_name
return netrc_file


def find_creds_in_env(username_name, password_name) -> Tuple[str, str]:
"""Find credentials for a service in the environment.

Args:
username_name: Name of the environment variable for the username
password_name: Name of the environment variable for the password

Returns:
Tuple of the username and password found in the environment
"""
if username_name in os.environ and password_name in os.environ:
username = os.environ[username_name]
password = os.environ[password_name]
return username, password

return None, None


def find_creds_in_netrc(service) -> Tuple[str, str]:
"""Find credentials for a service in the netrc file.

Args:
service: Service to find credentials for

Returns:
Tuple of the username and password found in the netrc file
"""
netrc_file = get_netrc()
if netrc_file.exists():
netrc_credentials = netrc.netrc(netrc_file)
if service in netrc_credentials.hosts:
username = netrc_credentials.hosts[service][0]
password = netrc_credentials.hosts[service][2]
return username, password

return None, None


def get_earthdata_credentials() -> Tuple[str, str]:
"""Get NASA EarthData credentials from the environment or netrc file.

Returns:
Tuple of the NASA EarthData username and password
"""
username, password = find_creds_in_env('EARTHDATA_USERNAME', 'EARTHDATA_PASSWORD')
if username and password:
return username, password

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

raise ValueError(
'Please provide NASA Earthdata credentials via the '
'EARTHDATA_USERNAME and EARTHDATA_PASSWORD environment variables, or your netrc file.'
)
Loading
Loading