PyDAP

3.5.9 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

from pydap.client import open_url

# Example OPeNDAP URL for a publicly available dataset
dataset_url = 'http://test.opendap.org/dap/data/nc/coads_climatology.nc'

try:
    # Open the remote dataset
    dataset = open_url(dataset_url)
    print(f"Dataset keys: {list(dataset.keys())}")

    # Access a variable lazily (no data downloaded yet)
    sst_variable = dataset['SST']
    print(f"SST variable shape: {sst_variable.shape}")
    print(f"SST variable data type: {sst_variable.dtype}")

    # Retrieve a small subset of data (data downloaded on-the-fly)
    # Example: first time step, subset of latitude/longitude
    data_subset = sst_variable[0, 10:14, 10:14]
    print("\nSubset of SST data (downloaded):")
    print(data_subset.data)

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →