Created
December 2, 2021 17:48
-
-
Save rabernat/1851f1ed2de74849f509d85d8773dd01 to your computer and use it in GitHub Desktop.
Load NASA EarthData OPeNDAP via Xarray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first make sure lxml is installed | |
# pip install lxml | |
# browse to a Hyrax opendap link, e.g. | |
# https://acdisc.gesdisc.eosdis.nasa.gov/opendap/hyrax/CMS/GEOS_CASAGFED_D_FIRE.3/GEOSCarb_CASAGFED3v3_Fire.Daily.x720_y360.2003.nc.html | |
import xarray as xr | |
from pydap.client import open_url | |
from pydap.cas.urs import setup_session | |
username = "rabernat" # replace with your EarthData username | |
password = "SECRET!" # replace with your EarthData password | |
url = "https://acdisc.gesdisc.eosdis.nasa.gov/opendap/hyrax/CMS/GEOS_CASAGFED_D_FIRE.3/GEOSCarb_CASAGFED3v3_Fire.Daily.x720_y360.2003.nc" | |
session = setup_session(username, password, check_url=url) | |
pydap_ds = open_url(url, session=session) | |
store = xr.backends.PydapDataStore(pydap_ds) | |
ds = xr.open_dataset(store) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment