Skip to content

Commit

Permalink
Using python-CMR instead of builtin
Browse files Browse the repository at this point in the history
I created this module before python-CMR. Let's move to that one instead
of my builtin. The API keeps changing, so hopefully they will keep that
library up to date.
  • Loading branch information
castelao committed Oct 4, 2023
1 parent 53b79f9 commit 7fa813c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions OceanColor/cmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from numpy import datetime64, datetime_as_string
import re
import requests
from cmr import GranuleQuery

module_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -92,11 +93,12 @@ def granules_search(
"temporal": temporal,
"circle": circle,
}
for result in api_walk(url, **params):
# for r in result['umm']['RelatedUrls']:
for r in result["umm"]["DataGranule"]["Identifiers"]:
if r["IdentifierType"] == "ProducerGranuleId":
yield r["Identifier"]
api = GranuleQuery()
api.params = params
granules = api.downloadable().get()
print([g["producer_granule_id"] for g in granules])
for granule in api.get():
yield granule['producer_granule_id']


def search_criteria(**kwargs):
Expand Down Expand Up @@ -128,7 +130,7 @@ def search_criteria(**kwargs):
criteria = {
"short_name": "VIIRSN_L3m_CHL",
"provider": "OB_DAAC",
"search": "DAY_SNPP_CHL_chlor_a_4km",
"search": "DAY.SNPP.CHL.chlor_a.4km",
}
elif kwargs["sensor"] == "aqua":
if kwargs["dtype"] == "L2":
Expand All @@ -137,7 +139,7 @@ def search_criteria(**kwargs):
criteria = {
"short_name": "MODISA_L3m_CHL",
"provider": "OB_DAAC",
"search": "DAY_CHL_chlor_a_4km",
"search": "DAY.CHL.chlor_a.4km",
}
elif kwargs["sensor"] == "terra":
if kwargs["dtype"] == "L2":
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies = [
"netCDF4 >= 1.5.6",
"pandas >= 1.3",
"pyproj >= 3.0",
"python-cmr ~= 0.9.0",
"requests >= 2.27",
"xarray >= 0.19",
"fsspec >= 2022.1",
Expand Down

0 comments on commit 7fa813c

Please sign in to comment.