pydap3.5.1
Published
A pure python implementation of the Data Access Protocol.
pip install pydap
Package Downloads
Authors
Requires Python
>=3.10
Dependencies
- numpy
>=2.0
- requests
- scipy
- lxml
; extra == "cas"
- Sphinx
; extra == "docs"
- Pygments
; extra == "docs"
- pandoc
; extra == "docs"
- sphinx-rtd-theme
; extra == "docs"
- nbsphinx
; extra == "docs"
- numpydoc
; extra == "docs"
- gsw
==3.0.6; extra == "functions"
- coards
; extra == "functions"
- netCDF4
; extra == "netcdf"
- gunicorn
; extra == "server"
- PasteDeploy
; extra == "server"
- docopt-ng
; extra == "server"
- Webob
; extra == "server"
- Jinja2
; extra == "server"
- beautifulsoup4
; extra == "server"
- lxml
; extra == "server"
- pytest
>=3.6; extra == "tests"
- pytest-cov
; extra == "tests"
- pytest-attrib
; extra == "tests"
- requests-mock
; extra == "tests"
- WebTest
; extra == "tests"
- flake8
; extra == "tests"
- werkzeug
>=2.2.2; extra == "tests"
- gunicorn
; extra == "tests"
- cryptography
; extra == "tests"
- gsw
; extra == "tests"
- coards
; extra == "tests"
- docopt-ng
; extra == "tests"
- Webob
; extra == "tests"
- Jinja2
; extra == "tests"
- beautifulsoup4
; extra == "tests"
- lxml
; extra == "tests"
pydap
What is pydap?
pydap is an open-source implementation of the OPeNDAP protocol, written from scratch in pure python. You can use pydap to access scientific data available on the many OPeNDAP servers publically available through the internet. Because pydap supports remote and lazy evaluation, you can access the data without having to download it; instead, you work with special array and iterable objects that download data on-the-fly as necessary, saving bandwidth and time. The module also comes with a robust-but-lightweight OPeNDAP server, implemented as a WSGI application.
Why pydap?
Originally developed in the 2000s, pydap is one of the oldest open-source python projects available and it gets rutinely developed and maintained by the OPeNDAP community at large. In addition, pydap is a long-recognized backend engine (and dependency) for xarray and chances are you have used pydap in past without knowing.
Quickstart
pydap is a lighweight python package that you can use in either of the two modalities: a client and as a server. You can install the latest version using pip. After installing pip you can install pydap with this command:
$ pip install pydap
This will install pydap together with all the required dependencies.
pydap is also available through Anaconda. Below we install pydap and its required dependencies, along with common additional packages in a fresh conda environment named pydap:
$ conda create -n pydap -c conda-forge python=3.10 pydap numpy">=2.0" jupyterlab ipython netCDF4 scipy matplotlib
Now you simply activate the pydap environment:
conda activate pydap
(NOTE: if you have mamba
install, you can replace conda
in the commands with mamba
). You can now use pydap as a client and open any remotely served
dataset, and pydap will download the accessed data on-the-fly as needed. For example consider this dataset currently hosted on OPeNDAP's Hyrax data server
from pydap.client import open_url
pyds = open_url('http://test.opendap.org:8080/opendap/catalog/ghrsst/20210102090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc', protocol='dap4')
pyds.tree()
.20210102090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc
├──time
├──lat
├──lon
├──analysed_sst
├──analysis_error
├──mask
├──sea_ice_fraction
├──dt_1km_data
└──sst_anomaly
pyds['sst_anomaly'].shape
(1, 17999, 36000)
NOTE In the example above, no data was downloaded, it was all lazily evaluated using OPeNDAP's DMR (DAP4) metadata representation. For more information, please check the documentation on using pydap as a client.
pydap also comes with a simple server, implemented as a WSGI application. To use it, you first need to install the server and optionally a data handler:
$ pip install "pydap[server,netcdf]"
This will install the necessary dependencies for running pydap as a server, along with extra dependencies for handling netCDF4 dataset. Now create a directory for your server data.
To run the server just issue the command:
$ pydap --data ./myserver/data/ --port 8001 --workers 4 --threads 4
This will start a standalone server running on the default http://localhost:8001/,
serving netCDF files from ./myserver/data/
Since the server uses the
WSGI standard, pydap uses by default 1 worker and 1
thread, but these can be defined by the user like in the case above (4 workers
and 4 threads). Pydap can also easily be run behind Apache. The server
documentation has
more information on how to better deploy pydap.
Documentation
For more information, see the pydap documentation.
Help and Community
If you need any help with pydap, open an issue in this repository. You can also send an email to the mailing list. Finally, ff you have a broader OPeNDAP access question, you can reach the OPeNDAP team on the OPeNDAP Discourse!