Documentation for Store
Bases: object
Store class to access granules on-prem or in the cloud.
Store is the class to access data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
auth |
Any
|
Auth instance to download and access data. |
required |
Source code in earthaccess/store.py
get(granules, local_path=None, provider=None, threads=8)
Retrieves data granules from a remote storage system.
- If we run this in the cloud, we are moving data from S3 to a cloud compute instance (EC2, AWS Lambda).
- If we run it outside the us-west-2 region and the data granules are part of a cloud-based collection, the method will not get any files.
- If we request data granules from an on-prem collection, the data will be effectively downloaded to a local directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
granules |
Union[List[DataGranule], List[str]]
|
A list of granules(DataGranule) instances or a list of granule links (HTTP). |
required |
local_path |
Union[Path, str, None]
|
Local directory to store the remote data granules. |
None
|
threads |
int
|
Parallel number of threads to use to download the files; adjust as necessary, default = 8. |
8
|
Returns:
Type | Description |
---|---|
List[str]
|
List of downloaded files |
Source code in earthaccess/store.py
get_fsspec_session()
cached
Returns a fsspec HTTPS session with bearer tokens that are used by CMR. This HTTPS session can be used to download granules if we want to use a direct, lower level API.
Returns:
Type | Description |
---|---|
AbstractFileSystem
|
fsspec HTTPFileSystem (aiohttp client session) |
Source code in earthaccess/store.py
get_requests_session(bearer_token=True)
Returns a requests HTTPS session with bearer tokens that are used by CMR. This HTTPS session can be used to download granules if we want to use a direct, lower level API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bearer_token |
bool
|
if true, will be used for authenticated queries on CMR |
True
|
Returns:
Type | Description |
---|---|
Session
|
requests Session |
Source code in earthaccess/store.py
get_s3fs_session(daac=None, concept_id=None, provider=None, endpoint=None)
Returns a s3fs instance for a given cloud provider / DAAC.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
daac |
Optional[str]
|
any of the DAACs, e.g. NSIDC, PODAAC |
None
|
provider |
Optional[str]
|
a data provider if we know them, e.g. PODAAC -> POCLOUD |
None
|
endpoint |
Optional[str]
|
pass the URL for the credentials directly |
None
|
Returns:
Type | Description |
---|---|
S3FileSystem
|
a s3fs file instance |
Source code in earthaccess/store.py
open(granules, provider=None)
Returns a list of fsspec file-like objects that can be used to access files hosted on S3 or HTTPS by third party libraries like xarray.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
granules |
Union[List[str], List[DataGranule]]
|
a list of granules(DataGranule) instances or list of URLs, e.g. s3://some-granule |
required |
provider |
Optional[str]
|
an option |
None
|
Returns:
Type | Description |
---|---|
List[Any]
|
A list of s3fs "file pointers" to s3 files. |
Source code in earthaccess/store.py
set_requests_session(url, method='get', bearer_token=False)
Sets up a requests
session with bearer tokens that are used by CMR.
Mainly used to get the authentication cookies from different DAACs and URS.
This HTTPS session can be used to download granules if we want to use a direct,
lower level API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
used to test the credentials and populate the class auth cookies |
required |
method |
str
|
HTTP method to test, default: "GET" |
'get'
|
bearer_token |
bool
|
if true, will be used for authenticated queries on CMR |
False
|
Returns:
Type | Description |
---|---|
None
|
fsspec HTTPFileSystem (aiohttp client session) |