{"id":7555,"library":"pydap","title":"PyDAP","description":"PyDAP is a pure Python implementation of the Data Access Protocol (DAP, also known as OPeNDAP), enabling access to scientific data over the internet. It acts as both a client for accessing remote OPeNDAP servers and a server for making local data available via OPeNDAP. A key feature is lazy data evaluation, where data is downloaded on-the-fly as needed, conserving bandwidth and time. The library is actively developed and maintained by the OPeNDAP community.","status":"active","version":"3.5.9","language":"en","source_language":"en","source_url":"https://github.com/pydap/pydap","tags":["data access","scientific data","OPeNDAP","DAP","client","server","geospatial","netcdf"],"install":[{"cmd":"pip install pydap","lang":"bash","label":"Client Installation"},{"cmd":"pip install \"pydap[server]\"","lang":"bash","label":"Server Installation (includes core)"},{"cmd":"conda create -n pydap -c conda-forge python=3.11 pydap numpy jupyterlab ipython netCDF4 scipy matplotlib && conda activate pydap","lang":"bash","label":"Conda Installation (client with common extras)"}],"dependencies":[{"reason":"Fundamental for array handling in scientific datasets; often used with pydap's output.","package":"numpy","optional":false},{"reason":"Required for the 'pydap[handlers.netcdf]' extra to serve NetCDF files, and often used in client applications.","package":"netCDF4","optional":true},{"reason":"Required for the 'pydap[handlers.hdf5]' extra to serve HDF5 files.","package":"h5py","optional":true},{"reason":"Required for the 'pydap[handlers.sql]' extra to serve data from relational databases.","package":"SQLAlchemy","optional":true},{"reason":"Pydap is a recognized backend for xarray, enabling more powerful data analysis and integration.","package":"xarray","optional":true}],"imports":[{"note":"The primary function for accessing remote OPeNDAP datasets as a client.","symbol":"open_url","correct":"from pydap.client import open_url"},{"note":"Used for low-level interaction with DAP responses, typically for server implementations or advanced client use.","symbol":"DAPHandler","correct":"from pydap.handlers.dap import DAPHandler"},{"note":"The WSGI application for running pydap as a server. Installed when using `pydap[server]`.","symbol":"app","correct":"from pydap.wsgi import app"}],"quickstart":{"code":"from pydap.client import open_url\n\n# Example OPeNDAP URL for a publicly available dataset\ndataset_url = 'http://test.opendap.org/dap/data/nc/coads_climatology.nc'\n\ntry:\n    # Open the remote dataset\n    dataset = open_url(dataset_url)\n    print(f\"Dataset keys: {list(dataset.keys())}\")\n\n    # Access a variable lazily (no data downloaded yet)\n    sst_variable = dataset['SST']\n    print(f\"SST variable shape: {sst_variable.shape}\")\n    print(f\"SST variable data type: {sst_variable.dtype}\")\n\n    # Retrieve a small subset of data (data downloaded on-the-fly)\n    # Example: first time step, subset of latitude/longitude\n    data_subset = sst_variable[0, 10:14, 10:14]\n    print(\"\\nSubset of SST data (downloaded):\")\n    print(data_subset.data)\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to use PyDAP as a client to open a remote OPeNDAP dataset, inspect its variables, and retrieve a subset of data using lazy evaluation. Data is only downloaded when explicitly accessed or sliced."},"warnings":[{"fix":"If encountered, try reducing the requested subset further. If the issue persists with small requests, it might be a server-specific limitation or a fundamental difference in how pydap constructs requests compared to other clients. Consider reporting to the pydap issue tracker.","message":"When accessing certain OPeNDAP servers, requesting even a small data subset can result in a 'Request too big' error. This often indicates a server-side parsing issue where the request is misinterpreted as a full array download, or a quirk in pydap's request building logic for specific grid maps.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that any problematic parts of the URL are properly URL-encoded (e.g., using `urllib.parse.quote`) before passing them to `open_url`. Also, verify the encoding of your environment if possible.","message":"Some URLs, particularly those with complex query parameters or non-ASCII characters, may lead to a `UnicodeDecodeError` when used with `pydap.client.open_url`. This indicates an encoding problem during URL parsing or data retrieval.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always refer to the official PyDAP documentation linked from its main GitHub repository or PyPI page for the most up-to-date and accurate information. Update to Python 3.10+ for full compatibility.","message":"Older documentation, especially on third-party sites or unmaintained GitHub Pages, may contain outdated examples or instructions. Pydap has undergone updates, including dropping Python 2.7 support (and thus the `six` dependency).","severity":"deprecated","affected_versions":"<3.3.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade your `xarray` library to a version compatible with `pydap` 3.x. Ensure both libraries are kept up-to-date to maintain compatibility. This issue is largely resolved in recent `xarray` releases.","cause":"This error typically occurred with older versions of the `xarray` library when attempting to use `pydap` as an engine, due to `pydap.model.DatasetType` changing its internal iteration methods (e.g., from `iteritems` to `items`) in later PyDAP versions.","error":"AttributeError: '<class 'pydap.model.DatasetType'>' object has no attribute 'iteritems'"},{"fix":"Explicitly encode problematic URL components using `urllib.parse.quote` or verify the encoding of the URL source. Ensure your Python environment is configured for UTF-8 where possible, e.g., via `locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')` if applicable.","cause":"Attempting to open a URL containing characters that are not correctly encoded for the system's default locale or the URL's intended encoding, leading to a decoding failure.","error":"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x__ in position __: invalid continuation byte"},{"fix":"Double-check that the subsetting (slicing) in your `pydap` code is correct. If the issue persists even with very small subsets, the problem lies with the specific OPeNDAP server or `pydap`'s interaction with it. Consider fetching data in even smaller chunks, if possible, or consulting the server's documentation.","cause":"The OPeNDAP server misinterpreted a subset request as a request for the entire dataset, exceeding its configured maximum download size. This can be due to how pydap constructs the OPeNDAP URL constraint expression for certain data types or server implementations.","error":"Request too big=XXXX.X Mbytes, max=YY.Y Mbytes (403 Forbidden)"}]}