{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "4da9684d-260e-49f4-a9ae-164738c17f3d", "metadata": { "id": "4da9684d-260e-49f4-a9ae-164738c17f3d" }, "source": [ "# How to Access GES DISC Data Using Python\n", "\n", "### Overview\n", "\n", "There are multiple ways to work with GES DISC data resources using Python. For example, the data can accessed using [techniques that rely on a native Python code](https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html). \n", "\n", "Still, there are several third-party libraries that can further simplify the access. In the sections below, we demonstrate downloading and streaming granules to the notebook using these libraries.\n", "\n", "The examples will use a sample MERRA-2 granule, from the [M2T1NXSLV.5.12.4 collection](https://doi.org/10.5067/VJAFPLI1CSIV), to demonstrate data access.\n", "\n", "### Prerequisites\n", "\n", "
.ncml aggregation, like some provided through THREDDS, may be useful for quickly subsetting multiple granules into a single data array.\n",
"\n",
"This operation requires a .dodsrc file in your root and working directories, and a .netrc file in your root directory. Running `auth = earthaccess.login()` will create both of these files, and can be removed after the first run, or can be removed entirely if these files are already present.\n",
"\n",
"To find the THREDDS URLs, please visit the dataset landing page for your desired collection, and from the \"Web Services\" dropdown, select \"THREDDS Data\". The dataset landing page for the collection below can be found [here](https://disc.gsfc.nasa.gov/datasets/M2T1NXSLV_5.12.4/summary?keywords=M2T1NXSLV_5.12.4).\n",
"\n",
"**Warning:** Please use a reasonable spatiotemporal subset when calling from THREDDS servers. Subsets that are too large will cause data access errors, or rate limiting on your IP address.\n",
"\n",
"We recommend using the `xarray` library when interacting with THREDDS URLs, due to its built-in authentication and subsetting capabilities."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "89f27aa7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"