Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 28 additions & 72 deletions binder/CMR_queries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,110 +5,66 @@
"id": "d0e31245-c554-4985-af28-705abe764ece",
"metadata": {},
"source": [
"<span style='color:#0066cc'> <span style='font-family:serif'> <font size=\"13\"> **Using CMR to Find OPeNDAP URLs (Earthdata specific)**<span style='color:#0066cc'>\n",
"# Discovering OPeNDAP URLs from NASA's Earthdata\n",
"\n",
"<font size=\"3\"><span style='color:Black'> The Common Metadata Repository (CMR) is a high-performance, high-quality, continuously evolving metadata system that catalogs Earth Science data and associated service metadata records. These metadata records are registered, modified, discovered, and accessed through programmatic interfaces leveraging standard protocols and APIs.\n",
"This tutorial demonstrates how to find OPeNDAP URLs from the [Common Metadata Repository](https://cmr.earthdata.nasa.gov/search) (CMR). The CMR is NASA's Earthdata API to query datasets available through many download and subset services, including OPeNDAP. The [CMR API](https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html) is complex and broad in scope, and with `pydap.client.get_cmr_urls` users can query and retrieve OPeNDAP urls.\n",
"\n",
"<font size=\"3\"><span style='color:Black'> For more information about the CMR API go to: https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html\n"
"**Requirements to run this notebook**\n",
"1. Have an Earth Data Login account\n",
"2. Knowledge of the Collection Concept ID (CCID), or Digital Object Identifier (DOI) of the collection of interest. \n",
"\n",
"**Objectives**\n",
" \n",
"Use [PyDAP](https://pydap.github.io/pydap/) to **discover all opendap urls in two simple case studies**\n",
"\n",
"1. Discover all possible OPeNDAP urls associated with a specific Collection Concept ID (and DOI).\n",
"2. Discover all possible OPeNDAP urls from a collection, that **match a time range and spatial bounding box of interest**. These parameters, and others, are widely used by the CMR (and Earthdata search) to filter the number of possible returns from querying the CMR, therefore narrowing the search.\n",
"\n",
"\n",
"`Author`: Miguel Jimenez-Urias, '25"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "adc54031-dc9f-4858-83be-a84c6ee4eef0",
"metadata": {},
"outputs": [],
"source": [
"from pydap.net import create_session\n",
"from pydap.client import get_cmr_urls"
"from pydap.client import get_cmr_urls\n",
"import pydap\n",
"import datetime as dt"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "f764fa2b-acc4-43ba-8762-b606dc4a96e4",
"metadata": {},
"outputs": [],
"source": [
"ecostress_ccid = \"C2076114664-LPCLOUD\""
"ecostress_ccid = \"C2076114664-LPCLOUD\"\n",
"time_range = [dt.datetime(2025, 3, 1), dt.datetime(2025, 3, 31)]\n",
"return_limit = 500 # How many urls to return. Default is 50"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "c4306a74-3848-42ec-9e57-e396f9f47b80",
"metadata": {},
"outputs": [],
"source": [
"urls = get_cmr_urls(ccid=ecostress_ccid, bounding_box=list((-130.8, 41, -124, 45)))"
"urls = get_cmr_urls(ccid=ecostress_ccid, bounding_box=list((-130.8, 41, -124, 45)), time_range=time_range, limit=return_limit)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "68aa026d-51d5-4bab-a642-2a5c04258712",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00152_003_20180716T130457_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00258_001_20180723T101233_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00289_001_20180725T100502_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00346_001_20180729T014458_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00346_002_20180729T014550_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00392_002_20180801T004543_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00392_003_20180801T004635_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00408_005_20180802T013113_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00423_001_20180803T003844_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00423_002_20180803T003936_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00438_002_20180803T234626_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00438_003_20180803T234718_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00441_002_20180804T043829_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00453_003_20180804T225449_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00457_005_20180805T052214_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00457_005_20180805T052214_0712_05',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00457_006_20180805T052306_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00457_007_20180805T052358_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00469_004_20180805T233925_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00469_004_20180805T233925_0712_05',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00469_005_20180805T234017_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00472_001_20180806T043039_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00472_002_20180806T043131_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00484_004_20180806T224658_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00484_004_20180806T224658_0712_05',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00484_005_20180806T224750_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00484_006_20180806T224842_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00487_002_20180807T033902_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00499_003_20180807T215521_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00499_004_20180807T215613_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00503_007_20180808T042338_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00503_008_20180808T042430_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00518_007_20180809T033122_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00518_008_20180809T033214_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00530_004_20180809T214742_0712_05',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00530_004_20180809T214742_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00530_005_20180809T214834_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00530_006_20180809T214926_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00533_005_20180810T023944_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00545_002_20180810T205606_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00545_003_20180810T205658_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00549_011_20180811T032420_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00549_011_20180811T032420_0712_03',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00576_004_20180812T204906_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00576_005_20180812T204958_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00579_008_20180813T013925_0712_03',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00579_008_20180813T013925_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00579_009_20180813T014017_0712_03',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00591_001_20180813T195545_0712_04',\n",
" 'https://opendap.earthdata.nasa.gov/collections/C2076114664-LPCLOUD/granules/ECOv002_L2_LSTE_00591_001_20180813T195545_0712_05']"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"urls"
]
Expand Down Expand Up @@ -138,7 +94,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.13"
"version": "3.12.11"
}
},
"nbformat": 4,
Expand Down
Loading