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.

Accessing GDEX THREDDS Data with Siphon

Authors
Affiliations
NSF NCAR
NSF NCAR
NSF NCAR

Overview

Siphon is Unidata’s Python library for accessing data from THREDDS Data Servers. This notebook shows how to use Siphon to browse the GDEX catalog and retrieve data via NCSS, CDMRemote, and WMS.

  1. Navigate the GDEX TDS catalog with Siphon

  2. Submit an NCSS (NetCDF Subset Service) query

  3. Access remote arrays via CDMRemote

  4. Render a variable as a map image via WMS (Web Map Service)

Prerequisites

ConceptsImportanceNotes
tds_introNecessaryTHREDDS concepts and GDEX catalog URL
SiphonNecessary
xarrayHelpful
  • Time to learn: 20 minutes


Imports

Browsing the Catalog

Use TDSCatalog to navigate the GDEX TDS hierarchy and locate a specific dataset or file.

e5.oper.an.sfc.128_034_sstk.ll025sc.1943050100_1943053123.nc

NCSS Query

The NetCDF Subset Service lets you request a spatial/temporal subset and specific variables without downloading the whole file.

attribute type uint not understood. Keeping as String.
attribute type uint not understood. Keeping as String.
attribute type uint not understood. Keeping as String.
attribute type uint not understood. Keeping as String.
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
Cell In[3], line 12
      8 query.time_range(datetime.datetime(1943, 5, 2), datetime.datetime(1943, 5, 3))
      9 # The variable name in the dataset is uppercase, so we need to convert it here
     10 query.variables(variable_name.upper())
     11 # submit the query and get the data
---> 12 data = ncss.get_data(query)

File ~/micromamba/envs/gdex-cookbook/lib/python3.12/site-packages/siphon/ncss.py:114, in NCSS.get_data(self, query)
     93 def get_data(self, query):
     94     """Fetch parsed data from a THREDDS server using NCSS.
     95 
     96     Requests data from the NCSS endpoint given the parameters in `query` and
   (...)    112 
    113     """
--> 114     resp = self.get_query(query)
    115     return response_handlers(resp, self.unit_handler)

File ~/micromamba/envs/gdex-cookbook/lib/python3.12/site-packages/siphon/http_util.py:406, in HTTPEndPoint.get_query(self, query)
    386 """Make a GET request, including a query, to the endpoint.
    387 
    388 The path of the request is to the base URL assigned to the endpoint.
   (...)    403 
    404 """
    405 url = self._base[:-1] if self._base[-1] == '/' else self._base
--> 406 return self.get(url, query)

File ~/micromamba/envs/gdex-cookbook/lib/python3.12/site-packages/siphon/http_util.py:488, in HTTPEndPoint.get(self, path, params)
    486     else:
    487         text = resp.text
--> 488     raise requests.HTTPError(f'Error accessing {resp.request.url}\n'
    489                              f'Server Error ({resp.status_code: d}: {text})')
    490 return resp

HTTPError: Error accessing https://tds.gdex.ucar.edu/thredds/ncss/grid/files/d633000/e5.oper.an.sfc/194305/e5.oper.an.sfc.128_034_sstk.ll025sc.1943050100_1943053123.nc?var=SSTK&time_start=1943-05-02T00%3A00%3A00&time_end=1943-05-03T00%3A00%3A00&west=-30&east=40&south=20&north=60
Server Error ( 500: Internal Server Error)

CDMRemote Access

CDMRemote provides efficient remote access to the full dataset structure without downloading the entire file. Unlike NCSS which returns a spatial/temporal subset of actual data, CDMRemote exposes the complete Common Data Model (CDM) hierarchy of a dataset, allowing you to:

  • Browse the full dataset structure and metadata

  • Access specific variables and dimensions on-demand

  • Query array-level data directly from the server

  • Work with large datasets without local storage constraints

This is particularly useful when you need flexibility to explore different parts of a dataset or when you only have intermittent access to specific array slices.

WMS (Web Map Service)

WMS is an OGC standard protocol that lets a THREDDS server render a dataset variable as a georeferenced map image on the fly. Instead of downloading data arrays, you send an HTTP request describing:

  • Layer — the variable to render (e.g., SSTK)

  • Bounding box and CRS — the spatial extent and coordinate reference system

  • Time — a specific timestamp to render

  • Style and color scale — how values are mapped to colors

The server returns a PNG (or other image format) that can be overlaid on any map. This is useful for:

  • Quick visual inspection of a variable across space and time

  • Integrating GDEX data into GIS tools or web map applications

  • Avoiding any local data download when only a visual overview is needed

Fetching and Displaying the WMS Image

With the params dict defined above, this cell:

  1. Assembles the full GetMap URL by URL-encoding all parameters and appending them to the WMS base endpoint.

  2. Sends an HTTP GET request to the server, which renders the requested variable (SSTK) as a georeferenced PNG image server-side.

  3. Reads the raw PNG bytes into a NumPy array with matplotlib.image.imread.

  4. Displays the image inline using imshow, with the bounding box set to global extent ([-180, 180, -90, 90]) so axes are labeled in degrees longitude/latitude.


Summary

Siphon provides a Pythonic interface to GDEX THREDDS services:

  • NCSS — ideal for pulling targeted spatial/temporal subsets of data into local memory as a netCDF4.Dataset.

  • CDMRemote — gives full, lazy remote access to the dataset structure without a local download; useful for exploring metadata and on-demand array slices.

  • WMS — renders a dataset variable as a georeferenced PNG image server-side via standard OGC GetMap requests; no data arrays are transferred, making it ideal for quick visual inspection.

What’s next?

See tds_xarray.ipynb to open TDS data via OPeNDAP directly in xarray.