erddapy, xarray, and the ERDDAP™ showcase

13 views
Skip to first unread message

Roy Mendelssohn - NOAA Federal

unread,
Mar 26, 2026, 10:41:49 AM (6 days ago) Mar 26
to erDDAP Bob Simons via, 'Micah Wengren' via ioos_tech
If you missed the recent ERDDAP™ showcase and haven’t looked at the Jupyter notebook from Filipe’s talk, I want to highlight something new that he demonstrated, which is the integration of erddapy with xarray.

In the past, to access data from an ERDDAP™ server using xarray, you had to use fact that ERDDAP™ can act as an OPenDAP server, and use that feature of xarray. Because of this xarray can only work with griddap datasets. As I have written previously, to use ERDDAP™ as an OPeNDAP server, you give the dataset URL without the format type and any filters or subsetting, for example using an example in Filipe’s notebook:

https://cwcgom.aoml.noaa.gov/erddap/griddap/etopo180

You then use this in the open statement, and proceed as if it is a local file to do the desired subsetting using the various select methods in xarray. But now, you can use erddapy as the engine in the open statement and if you know the full ERDDAP™ URL (that is with all the constraints) if you pass that you do not need to do any further subsetting, From the notebook:

url = "https://cwcgom.aoml.noaa.gov/erddap/griddap/etopo180.nc?altitude%5B(-38):1:(-26)%5D%5B(-40):1:(-23)%5D"
ds = xr.open_dataset(url, engine="erddapy”)

(and remember many mail systems mess up double quotes, so best is to copy from the notebook). That will ingest the constrained data into xarray.

But it gets better (this is for you Rich Signell if you read these things because this is something you wanted a couple of years ago) you can now access tabledap datasets if the dataset is amenable to be returning in one of several netcdf file formats. Filipe gives two examples, one unfiltered and one filtered:

#Unfiltered
url = "https://gliders.ioos.us/erddap/tabledap/amelia-20180501T0000.ncCFMA"
xr.open_dataset(url, engine="erddapy”)

#Filtered
base = "https://gliders.ioos.us/erddap/tabledap/amelia-20180501T0000.ncCFMA"
filters = "trajectory%2Csalinity&time%3E=2018-05-07T00%3A00%3A00Z&time%3C=2018-05-14T12%3A29%3A12Z"
url = base + "?" + filters
xr.open_dataset(url, engine="erddapy”)


All of this is way cool, and you now have the option of working with erddapy or xarray to easily access a wide variety of data. This can be helpful for example if you are very familiar with xarray and have workflows using xarray, while erddapy is still a stand alone package for those who have workflows using erddapy. Many thanks to Filipe for working on this (and I hope he will chime in if I have said anything that is incorrect).

-Roy
Reply all
Reply to author
Forward
0 new messages