Quick introduction

erddapy is a pure python package and can be installed with conda

conda install --channel conda-forge erddapy

or pip

pip install erddapy

First we need to instantiate the ERDDAP URL constructor for a server. In these examples we will use https://standards.sensors.ioos.us/erddap/index.html and https://erddap.ioos.us/erddap/index.html.

[1]:
from erddapy import ERDDAP

server = "https://standards.sensors.ioos.us/erddap"
e = ERDDAP(
    server=server,
    protocol="tabledap",
    response="csv",
)

Now we can populate the object a dataset id, variables of interest, and its constraints (last week gliders). Use the method to_pandas to download the csv(p) response, a comma separated values with units and explore the Dataframe.

[2]:
e.dataset_id = "org_cormp_cap2"

e.variables = [
    "time",
    "latitude",
    "longitude",
    "sea_water_temperature",
    "air_temperature",
]

e.constraints = {
    "time>=": "2000-01-01",
}


df = e.to_pandas(
    index_col="time (UTC)",
    parse_dates=True,
).dropna()

df.head()
[2]:
latitude (degrees_north) longitude (degrees_east) sea_water_temperature (degree_Celsius) air_temperature (degree_Celsius)
time (UTC)
2000-01-01 00:08:00+00:00 32.8032 -79.6204 14.01 14.42
2000-01-01 01:08:00+00:00 32.8032 -79.6204 13.92 13.91
2000-01-01 02:08:00+00:00 32.8032 -79.6204 13.90 13.60
2000-01-01 03:08:00+00:00 32.8032 -79.6204 13.92 13.47
2000-01-01 04:08:00+00:00 32.8032 -79.6204 13.93 13.28

We can constraint the in time and space with relative constraints like in the example below. For more ways to access the data please check the “Longer introduction.”

[3]:
server = "https://erddap.ioos.us/erddap"
e = ERDDAP(
    server=server,
    protocol="tabledap",
    response="csv",
)

e.dataset_id = "processed_asset_inventory"

# Get the box of the first 10 degrees bbox.
constraints = {
    "longitude<=": "min(longitude)+10",
    "longitude>=": "min(longitude)",
    "latitude<=": "min(latitude)+10",
    "latitude>=": "min(latitude)",
}


url = e.get_download_url(
    response="htmlTable",
    constraints=constraints,
)

print(url)
https://erddap.ioos.us/erddap/tabledap/processed_asset_inventory.htmlTable?&longitude<=min(longitude)+10&longitude>=min(longitude)&latitude<=min(latitude)+10&latitude>=min(latitude)

We can search all datasets with a set of constraints by setting dataset_id to "allDatasets". Note that these variables are different than the ones available at the individual dataset level. For a reference of the possible variables to query all datasets see the <server-url>/erddap/<protocol>/allDatasets.html page, like this one for the Ifremer ERDDAP server.

[4]:
e.dataset_id = "allDatasets"

e.variables = [
    "datasetID",
    "institution",
]


url = e.get_download_url(response="html")
print(url)

df = e.to_pandas(
    index_col="datasetID",
).dropna()


df.head()
https://erddap.ioos.us/erddap/tabledap/allDatasets.html?datasetID,institution
[4]:
institution
datasetID
allDatasets Integrated Ocean Observing System (IOOS)
OBIS ???
ra_regional_boundaries NOAA/NOS/IOOS
by_the_numbers IOOS
processed_asset_inventory NOAA/NOS/IOOS