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

Implement simpler API signatures #167

Open
betolink opened this issue Oct 21, 2022 · 6 comments
Open

Implement simpler API signatures #167

betolink opened this issue Oct 21, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request question A question needs to be answered to proceed

Comments

@betolink
Copy link
Member

betolink commented Oct 21, 2022

The concept of collections vs granules and instantiating those classes can be confusing, especially for new users. Perhaps having a static method that can simplify things would be simpler to use e.g. (using the upcoming name)

import earthaccess
import xarray as xr

auth = earthaccess.login(strategy="netrc")

granules = earthaccess.get_granules(short_name="ATL06",
                                    cloud_hosted=True,
                                    polygon=((1,2),(3,4)... ),
                                    temporal=("2020-01-01","2020-12-31"))

ds = xr.open_mfdataset(earthaccess.open(granules, auth=auth))

This would be better suited for regional use cases since we'll be downloading the metadata from CMR in one go.
Workflows that may require bulk downloads could potentially use an iterator like

import earthaccess

auth = earthaccess.login(strategy="netrc")
query = earthaccess.search(short_name="ATL06",
                           cloud_hosted=True,
                           page_size=2000,
                           polygon=((1,2),(3,4)... ),
                           temporal=("2020-01-01","2020-12-31"))

for granules in query.items():
    # here granules is a resultset of up to 2000 granules.
    earthaccess.download(granules, "./data/ATL06/", auth=auth)
@betolink betolink added the enhancement New feature or request label Oct 21, 2022
@betolink betolink self-assigned this Oct 21, 2022
@andypbarrett
Copy link
Collaborator

I like this approach. However, this methods requires knowing the concept id or short name first. This is fine if you know your dataset or know to go to EarthData Search but we need to explain that step. Otherwise getting the shortname is "magic".

@betolink
Copy link
Member Author

betolink commented Oct 24, 2022

I totally agree @andypbarrett, we need to explain where this short_name is coming from and what's more, expose the other ways of finding data (search by DOI for example). These new methods would also abstract the fact that at granule level there is no way of querying using the cloud_hosted flag. New users unfamiliar with CMR would need to know the provider to make that distinction, i.e. NSIDC_ECS vs NSIDC_CPRD

@betolink betolink mentioned this issue Feb 16, 2023
@scottyhq
Copy link

I was wondering if the current search keyword arguments are based on the earthdata search API? Perhaps it'd be possible to use STAC-API standards for more consistency across libraries (at least for the main spatiotemporal ones?).

I know it's nitpicky and annoying to have breaking changes like this, but the user experience is nice coming from other libraries like pystac_client / nasa-cmr-stac. and perhaps the standard names and acceptable formats could have the benefit of re-using already implemented parsers in those other libraries.

https://github.com/radiantearth/stac-api-spec/tree/main/item-search#query-parameter-table
e.g.:

temporal -> datetime
polygon -> intersects
collections -> short_name?

@betolink
Copy link
Member Author

This is a great idea @scottyhq !! they don't have to be breaking changes, we can just add them as aliases to the class methods and will work the same way (without breaking the old names), the only thing that might need some work is processing the GeoGSON geometry for intersects. I definitely see value in using a standard. Down the road we can even use pystac under the hood and make this library more generic and not entirely tied to CMR.

@asteiker asteiker added the feedback requested We requested feedback from the reporter; if we don't hear back in X days the issue may be closed label Oct 29, 2024
Copy link

Closing after 10 days of waiting for feedback. If you feel this was in error, please re-open, @ a maintainer, or create new issues.

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in earthaccess project Oct 29, 2024
@asteiker asteiker added question A question needs to be answered to proceed and removed feedback requested We requested feedback from the reporter; if we don't hear back in X days the issue may be closed labels Oct 29, 2024
@asteiker
Copy link
Member

@betolink Is this still relevant with more recent earthaccess releases? What does this proposal achieve compared to what we currently support?

@asteiker asteiker reopened this Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question A question needs to be answered to proceed
Projects
Status: Done
Development

No branches or pull requests

4 participants