-
Notifications
You must be signed in to change notification settings - Fork 11
Adding raster compression option #106
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
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
71b3cc5
adding compression option
Antsalacia c7dbb65
Adding modification and verification in method
Antsalacia 7ac2f6c
Add argument in method
Antsalacia ba57e0c
rename and add docstring
Antsalacia a3ae236
Add `raster_compression` type in docstring
wehrad 5bbc9d5
fix None bug and rename
Antsalacia a706f43
Merge branch 'fix/34' of https://github.com/Antsalacia/earthspy into …
Antsalacia f584b99
change argument
Antsalacia 40366a1
CodeQL issue
Antsalacia 2c8c688
pre-commit issues
Antsalacia 37f5765
Address CodeQL alert
wehrad 3727118
test with pre-commit
Antsalacia 582b681
Merge branch 'fix/34' of https://github.com/Antsalacia/earthspy into …
Antsalacia a3d8c28
Merge branch 'main' into fix/34
wehrad e9c5cf2
change in metadata
Antsalacia 0a9d2cc
add pre-commit
Antsalacia ad78deb
resolve merge conflict
Antsalacia e34429c
pre-commit change
Antsalacia f65d35a
modify `get_raster_compression` docstring
wehrad 468020c
modify line length on docstring
wehrad d8512b1
Problem with self and variables env
Antsalacia d8cb87f
Adding conftest and test
Antsalacia 4ea9306
Merge branch 'main' into fix/34
wehrad 74cb8b0
rename filepath for authfile
wehrad bf94c1a
fix authfile fixture
wehrad 3f242d8
try and fix authfile writing in Github action
wehrad b6bc469
modify compression methods
wehrad f6acfc7
fix authfile
wehrad 9d722c2
fix authfile
wehrad 7ec7f3d
add assert for authentification
wehrad 2dd7d8a
remove assert
wehrad 533c2f9
change None check and add test for comp
Antsalacia 239bfb2
Add comments
Antsalacia 92c6479
comply with github_adv_sec
Antsalacia 0ebfcc6
fix typo
Antsalacia 7ade2d3
forgot pre-commit
wehrad 80b174b
add Antsalacia in author list
wehrad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,189 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
|
|
||
| @authors: Adrien Wehrlé (EO-IO), Antsalacia | ||
|
|
||
| """ | ||
|
|
||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
| import earthspy.earthspy as es | ||
|
|
||
|
|
||
| def pytest_addoption(parser): | ||
| """Add option to pass local path to authentication file""" | ||
| parser.addoption( | ||
| "--authfile", | ||
| action="store", | ||
| default="./auth.txt", | ||
| help="Full path to Sentinel Hub credential file containing ID and password", | ||
| ) | ||
|
|
||
|
|
||
| # if running in Github action | ||
| if os.getenv("CI") is not None: | ||
|
|
||
| @pytest.fixture(scope="session") | ||
| def SH_CLIENT_ID() -> None: | ||
| """Create local client id from environment variable""" | ||
| # check if variable in environment variables | ||
| SH_CLIENT_ID = os.environ["SH_CLIENT_ID"] | ||
| return SH_CLIENT_ID | ||
|
|
||
| @pytest.fixture(scope="session") | ||
| def SH_CLIENT_SECRET() -> None: | ||
| """Create local client secret from environment variable""" | ||
| # check if variable in environment variables | ||
| SH_CLIENT_SECRET = os.environ["SH_CLIENT_SECRET"] | ||
| return SH_CLIENT_SECRET | ||
|
|
||
| # path to credential file to be created | ||
| @pytest.fixture(scope="session") | ||
| def authfile(SH_CLIENT_ID, SH_CLIENT_SECRET): | ||
| """Set credential file name and create credential file | ||
| for testing""" | ||
| authfile = "auth.txt" | ||
| with open(authfile, "w") as out: | ||
| out.write(f"{SH_CLIENT_ID}\n{SH_CLIENT_SECRET}") | ||
|
||
| return authfile | ||
|
|
||
|
|
||
| # if running locally | ||
| else: | ||
|
|
||
| @pytest.fixture(scope="session") | ||
| def authfile(pytestconfig): | ||
| """Get option from command line call""" | ||
| return pytestconfig.getoption("authfile") | ||
|
|
||
| @pytest.fixture(scope="session") | ||
| def credentials(authfile): | ||
| """Read credentials stored in text file""" | ||
|
|
||
| with open(authfile) as file: | ||
| credentials = file.read().splitlines() | ||
| return credentials | ||
|
|
||
| @pytest.fixture(scope="session") | ||
| def SH_CLIENT_ID(credentials) -> None: | ||
| """Extract client id from line""" | ||
| SH_CLIENT_ID = credentials[0] | ||
| return SH_CLIENT_ID | ||
|
|
||
| @pytest.fixture(scope="session") | ||
| def SH_CLIENT_SECRET(credentials) -> None: | ||
| """Extract client secret from line""" | ||
| SH_CLIENT_SECRET = credentials[1] | ||
| return SH_CLIENT_SECRET | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def test_evalscript(): | ||
| """Set a test evalscript for Sentinel-2""" | ||
| test_evalscript = """ | ||
| //VERSION=3 | ||
| function setup(){ | ||
| return{ | ||
| input: ["B02", "B03", "B04", "dataMask"], | ||
| output: {bands: 4} | ||
| } | ||
| } | ||
| function evaluatePixel(sample){ | ||
| // Set gain for visualisation | ||
| let gain = 2.5; | ||
| // Return RGB | ||
| return [sample.B04 * gain, sample.B03 * gain, sample.B02 * gain, | ||
| sample.dataMask]; | ||
| } | ||
| """ | ||
| return test_evalscript | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def test_url(): | ||
| """Set a test evalscript pointing to Sentinel-2 True Color""" | ||
| test_url = ( | ||
| "https://custom-scripts.sentinel-hub.com/custom-scripts/" | ||
| + "sentinel-2/true_color/script.js" | ||
| ) | ||
| return test_url | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def test_collection(): | ||
| """Set a test data collection""" | ||
| test_collection = "SENTINEL2_L2A" | ||
| return test_collection | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def test_bounding_box(): | ||
| """Set a test footprint area (bounding box)""" | ||
| test_bounding_box = [-51.13, 69.204, -51.06, 69.225] | ||
| return test_bounding_box | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def test_area_name(): | ||
| """Set a test area available as geojson file""" | ||
| test_area_name = "Ilulissat" | ||
| return test_area_name | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def t1(authfile, test_evalscript, test_collection, test_bounding_box): | ||
| """Set a test query with default parameters""" | ||
| t1 = es.EarthSpy(authfile) | ||
| t1.set_query_parameters( | ||
| bounding_box=test_bounding_box, | ||
| time_interval=["2019-08-23"], | ||
| evaluation_script=test_evalscript, | ||
| data_collection=test_collection, | ||
| download_mode="SM", | ||
| ) | ||
| return t1 | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def t2(authfile, test_evalscript, test_collection, test_area_name): | ||
| """Set a test query with area name""" | ||
| t2 = es.EarthSpy(authfile) | ||
| t2.set_query_parameters( | ||
| bounding_box=test_area_name, | ||
| time_interval=["2019-08-23"], | ||
| evaluation_script=test_evalscript, | ||
| data_collection=test_collection, | ||
| download_mode="SM", | ||
| ) | ||
| return t2 | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def t3(authfile, test_evalscript, test_collection, test_bounding_box): | ||
| """Set a test query with direct download mode""" | ||
| t3 = es.EarthSpy(authfile) | ||
| t3.set_query_parameters( | ||
| bounding_box=test_bounding_box, | ||
| time_interval=["2019-08-23"], | ||
| evaluation_script=test_evalscript, | ||
| data_collection=test_collection, | ||
| download_mode="D", | ||
| ) | ||
| return t3 | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def t4(authfile, test_evalscript, test_collection, test_bounding_box): | ||
| """Set a test query with LZW raster compression""" | ||
| t4 = es.EarthSpy(authfile) | ||
| t4.set_query_parameters( | ||
| bounding_box=test_bounding_box, | ||
| time_interval=["2019-08-23"], | ||
| evaluation_script=test_evalscript, | ||
| data_collection=test_collection, | ||
| download_mode="SM", | ||
| raster_compression="LZW", | ||
| ) | ||
| return t4 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.