-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from umr-lops/s3protocol
S3protocol
- Loading branch information
Showing
7 changed files
with
88 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -19,3 +19,5 @@ __pycache__/ | |
.coverage.* | ||
.cache | ||
/docs/_build/ | ||
localconfig.yml | ||
.idea |
This file contains 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,13 @@ | ||
from safe_s1 import Sentinel1Reader, getconfig | ||
import time | ||
conf = getconfig.get_config() | ||
subswath = conf['nfs_iw_grd_path'] | ||
print(subswath) | ||
t0 = time.time() | ||
sub_reader = Sentinel1Reader(subswath) | ||
elapse_t = time.time()-t0 | ||
|
||
dt = sub_reader.datatree | ||
print('out of the reader') | ||
print(dt) | ||
print('time to read the SAFE through S3: %1.2f sec'%elapse_t) |
This file contains 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,36 @@ | ||
# see https://stackoverflow.com/questions/69624867/no-such-file-error-when-trying-to-create-local-cache-of-s3-object | ||
from safe_s1 import Sentinel1Reader,getconfig | ||
import pdb | ||
import os | ||
import time | ||
import logging | ||
import fsspec | ||
logging.basicConfig(level=logging.INFO) | ||
logging.info('test start') | ||
conf = getconfig.get_config() | ||
access_key = conf['access_key'] | ||
secret_key = conf['secret_key'] | ||
entrypoint_url = conf['entrypoint_url'] | ||
s3 = fsspec.filesystem("s3", anon=False, | ||
key=access_key, | ||
secret=secret_key, | ||
endpoint_url='https://'+entrypoint_url) | ||
|
||
# this syntaxe works we can get content xml files but I would have to precise which subswath I want to decode in case of SLC | ||
# safe2 = 's3:///eodata/Sentinel-1/SAR/SLC/2019/10/13/S1B_IW_SLC__1SDV_20191013T155948_20191013T160015_018459_022C6B_13A2.SAFE' | ||
safe2 = 's3:///eodata/Sentinel-1/SAR/IW_GRDH_1S/2024/04/18/S1A_IW_GRDH_1SSH_20240418T080141_20240418T080210_053485_067D74_C073.SAFE' | ||
# safe2 = conf['s3_iw_grd_path'] | ||
option = 'kwargs' | ||
if option == 'kwargs': | ||
storage_options = {"anon": False, "client_kwargs": {"endpoint_url": 'https://'+entrypoint_url, 'aws_access_key_id':access_key, | ||
'aws_secret_access_key':secret_key}} | ||
t0 = time.time() | ||
sub_reader = Sentinel1Reader(safe2,backend_kwargs={"storage_options": storage_options}) | ||
elapse_t = time.time()-t0 | ||
print('time to read the SAFE through S3: %1.2f sec'%elapse_t) | ||
else: | ||
# this solution is not supported. | ||
sub_reader = Sentinel1Reader(s3.get_mapper(safe2)) # botocore.errorfactory.NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: Unknown | ||
dt = sub_reader.datatree | ||
print('out of the reader') | ||
print(dt) |
This file contains 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,23 @@ | ||
import yaml | ||
import os | ||
import logging | ||
import safe_s1 | ||
from pathlib import Path | ||
# determine the config file we will use (config.yml by default, and a local config if one is present) and retrieve | ||
# the products names | ||
def get_config(): | ||
local_config_pontential_path = os.path.join(os.path.dirname(safe_s1.__file__), 'localconfig.yml') | ||
logging.info('potential local config: %s',local_config_pontential_path) | ||
#local_config_pontential_path = Path(os.path.join('~', 'xarray-safe-s1', 'localconfig.yml')).expanduser() | ||
if os.path.exists(local_config_pontential_path): | ||
logging.info('localconfig used') | ||
config_path = local_config_pontential_path | ||
with open(config_path) as config_content: | ||
conf = yaml.load(config_content, Loader=yaml.SafeLoader) | ||
else: | ||
logging.info('default config') | ||
config_path = Path(os.path.join(os.path.dirname(safe_s1.__file__), 'config.yml')) | ||
with open(config_path) as config_content: | ||
conf = yaml.load(config_content, Loader=yaml.SafeLoader) | ||
return conf | ||
|
This file contains 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 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 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