Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

GDEX Download Workflow

Authors
Affiliations
NSF NCAR
NSF NCAR
NSF NCAR

Overview

This notebook demonstrates how to directly access a NetCDF file on GDEX over HTTPS with fsspec and run analysis on it, without downloading the file to disk.

  1. Find a file’s HTTPS URL

  2. Open it lazily with fsspec

  3. Load it with xarray and run analysis

Prerequisites

ConceptsImportanceNotes
download_introNecessaryFile listing and HTTP download
fsspecNecessaryRemote file access
xarrayNecessary
  • Time to learn: 15 minutes


Imports

Step 1 — Find a File’s HTTPS URL

From the GDEX web portal, we can identify the direct HTTPS link to the NetCDF file:

https://osdf-director.osg-htc.org/ncar/gdex/d651056/CESM2-LE/atm/proc/tseries/month_1/LHFLX/b.e21.BHISTcmip6.f09_g17.LE2-1001.001.cam.h0.LHFLX.185001-185912.nc

Opening this URL in a browser typically starts a file download.
In this workflow, we instead use the URL programmatically so the data can be accessed directly in memory (via fsspec/xarray) without first saving a local copy.

GDEX data file URL page

The direct file URL can be copied from the GDEX data access page.

Step 2 — Open the File Lazily with fsspec

fsspec’s HTTP filesystem opens a remote file as a Python file-like object backed by HTTP range requests, so only the bytes you access are transferred.

Step 3 — Load with xarray and Plot

Call .load() on a variable to fetch its data into memory, then visualize it with matplotlib.

Loading...
Loading...
/tmp/ipykernel_4755/3606810028.py:3: FutureWarning: In a future version of xarray to_datetimeindex will default to returning a 'us'-resolution DatetimeIndex instead of a 'ns'-resolution DatetimeIndex. This warning can be silenced by explicitly passing the `time_unit` keyword argument.
  time_dt = ds.indexes["time"].to_datetimeindex()
/tmp/ipykernel_4755/3606810028.py:3: RuntimeWarning: Converting a CFTimeIndex with dates from a non-standard calendar, 'noleap', to a pandas.DatetimeIndex, which uses dates from the standard calendar.  This may lead to subtle errors in operations that depend on the length of time between dates.
  time_dt = ds.indexes["time"].to_datetimeindex()
<Figure size 1000x400 with 1 Axes>

Summary

fsspec combined with xarray lets you open a remote NetCDF file directly over HTTPS and read only the data you need, without storing the file locally.

What’s next?

See globus_intro.ipynb to transfer files to an HPC system via Globus instead of HTTP access.