From 7fa813cf8de9dd5e41af0386041e1a8ec4ee67a6 Mon Sep 17 00:00:00 2001 From: Gui Castelao Date: Tue, 3 Oct 2023 21:16:49 -0600 Subject: [PATCH] Using python-CMR instead of builtin 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. --- OceanColor/cmr.py | 16 +++++++++------- pyproject.toml | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/OceanColor/cmr.py b/OceanColor/cmr.py index 55b5127..c4b4bc0 100644 --- a/OceanColor/cmr.py +++ b/OceanColor/cmr.py @@ -7,6 +7,7 @@ from numpy import datetime64, datetime_as_string import re import requests +from cmr import GranuleQuery module_logger = logging.getLogger(__name__) @@ -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): @@ -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": @@ -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": diff --git a/pyproject.toml b/pyproject.toml index 18b280f..a1c7622 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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",