Skip to content

opendap / dap4 support for pydap backend #10182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5258386
initial pydap4 commit
Mikejmnez Mar 28, 2025
4e463f2
update some links on documentation, and how to define opendap protoco…
Mikejmnez Mar 28, 2025
2861d2e
fix spacing
Mikejmnez Mar 28, 2025
bd7ffa8
update url
Mikejmnez Apr 9, 2025
19bbc7e
enable opening (remote) datatrees
Mikejmnez Apr 12, 2025
0fe174b
update testing
Mikejmnez Apr 12, 2025
e270471
initial tests on datatree
Mikejmnez Apr 12, 2025
e509464
another datatree test
Mikejmnez Apr 12, 2025
385f9a4
update pydap model for getting dimensions`s names
Mikejmnez Apr 13, 2025
bb9a644
pre-commit
Mikejmnez Apr 13, 2025
bae96c3
remove pydap/opendap specific attrs
Mikejmnez Apr 13, 2025
7e8f842
include `path` attribute to pydap dataset/group
Mikejmnez Apr 13, 2025
d475581
update engine ref
Mikejmnez Apr 13, 2025
7a473ae
add DeprecationWarning for `output_grid`
Mikejmnez Apr 15, 2025
881e771
pre-commit
Mikejmnez Apr 15, 2025
50c0311
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 15, 2025
a4b17e7
rebase
Mikejmnez Apr 15, 2025
ad6a72a
reverse ghost commits?
Mikejmnez Apr 16, 2025
22a3722
use latest `pydap` conda release compat with `3.10` as min dependency
Mikejmnez Apr 16, 2025
7fdc9b6
whoops set pydap to `3.5.5`
Mikejmnez Apr 16, 2025
ee10d8f
sets min version to `pydap==3.5.0`
Mikejmnez Apr 16, 2025
80354fe
Merge branch 'main' into pydap4
dcherian Apr 17, 2025
0da9c17
add description under `New Features`, as well as bump version on `Bre…
Mikejmnez Apr 17, 2025
56eaf2b
Merge branch 'main' into pydap4
Mikejmnez Apr 18, 2025
e0b29fc
add `pydap` as `T_DataTreeNetcdfEngine`
Mikejmnez Apr 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/requirements/min-all-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies:
- pandas=2.1
- pint=0.22
- pip
- pydap=3.4
- pydap=3.5.0
- pytest
- pytest-cov
- pytest-env
Expand Down
45 changes: 26 additions & 19 deletions doc/user-guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1245,37 +1245,44 @@ over the network until we look at particular values:

.. image:: ../_static/opendap-prism-tmax.png

Some servers require authentication before we can access the data. For this
purpose we can explicitly create a :py:class:`backends.PydapDataStore`
and pass in a `Requests`__ session object. For example for
HTTP Basic authentication::
Some servers require authentication before we can access the data. Pydap uses
a `Requests`__ session object (which the user can pre-define), and this
session object can recover `authentication`__` credentials from a locally stored
``.netrc`` file. For example, to connect to a server that requires NASA's
URS authentication, with the username/password credentials stored on a locally
accessible ``.netrc``, access to OPeNDAP data should be as simple as this::

import xarray as xr
import requests

session = requests.Session()
session.auth = ('username', 'password')
my_session = requests.Session()

store = xr.backends.PydapDataStore.open('http://example.com/data',
session=session)
ds = xr.open_dataset(store)
ds_url = 'https://gpm1.gesdisc.eosdis.nasa.gov/opendap/hyrax/example.nc'

`Pydap's cas module`__ has functions that generate custom sessions for
servers that use CAS single sign-on. For example, to connect to servers
that require NASA's URS authentication::
ds = xr.open_dataset(ds_url, session=my_session, engine="pydap")

import xarray as xr
from pydata.cas.urs import setup_session
Moreover, a bearer token header can be included in a `Requests`__ session
object, allowing for token-based authentication which OPeNDAP servers can use
to avoid some redirects.

ds_url = 'https://gpm1.gesdisc.eosdis.nasa.gov/opendap/hyrax/example.nc'

session = setup_session('username', 'password', check_url=ds_url)
store = xr.backends.PydapDataStore.open(ds_url, session=session)
Lastly, OPeNDAP servers may provide endpoint URLs for different OPeNDAP protocols,
DAP2 and DAP4. To specify which protocol between the two options to use, you can
replace the scheme of the url with the name of the protocol. For example::

ds = xr.open_dataset(store)
# dap2 url
ds_url = 'dap2://gpm1.gesdisc.eosdis.nasa.gov/opendap/hyrax/example.nc'

# dap4 url
ds_url = 'dap4://gpm1.gesdisc.eosdis.nasa.gov/opendap/hyrax/example.nc'

While most OPeNDAP servers implement DAP2, not all servers implement DAP4. It
is recommended to check if the URL you are using `supports DAP4`__ by checking the
URL on a browser.

__ https://docs.python-requests.org
__ https://www.pydap.org/en/latest/client.html#authentication
__ https://pydap.github.io/pydap/en/notebooks/Authentication.html
__ https://pydap.github.io/pydap/en/faqs/dap2_or_dap4_url.html

.. _io.pickle:

Expand Down
12 changes: 12 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,20 @@ New Features

- Added `scipy-stubs <https://github.com/scipy/scipy-stubs>`_ to the ``xarray[types]`` dependencies.
By `Joren Hammudoglu <https://github.com/jorenham>`_.
- Improved compatibility with OPeNDAP DAP4 data model for backend engine ``pydap``. This
includes ``datatree`` support, and removing slashes from dimension names. By
`Miguel Jimenez-Urias <https://github.com/Mikejmnez>`_.

Breaking changes
~~~~~~~~~~~~~~~~

- The minimum versions of some dependencies were changed

===================== ========= =======
Package Old New
===================== ========= =======
pydap 3.4 3.5.0
===================== ========= =======

Deprecations
~~~~~~~~~~~~
Expand All @@ -47,6 +57,8 @@ Documentation

- Fix references to core classes in docs (:issue:`10195`, :pull:`10207`).
By `Mattia Almansi <https://github.com/malmans2>`_.
- Fix references to point to updated pydap documentation (:pull:`10182`).
By `Miguel Jimenez-Urias <https://github.com/Mikejmnez>`_.

Internal Changes
~~~~~~~~~~~~~~~~
Expand Down
Loading
Loading