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://erddap.sensors.ioos.us/erddap/index.html.

[1]:
from erddapy import ERDDAP

server = "https://erddap.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)
2005-11-14 23:00:40+00:00 32.8032 -79.6204 20.3767 21.7
2005-11-15 01:00:40+00:00 32.8032 -79.6204 20.0283 20.9
2005-11-15 03:00:40+00:00 32.8032 -79.6204 19.7840 20.3
2005-11-15 05:00:40+00:00 32.8032 -79.6204 19.6207 20.1
2005-11-15 07:00:40+00:00 32.8032 -79.6204 19.7652 20.8

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)
atn_collection IOOS / ATN
atn_99310_bearded-seal_trajectory_20110617-20120606 NOAA Alaska Fisheries Science Center
OBIS ???
ra_regional_boundaries NOAA/NOS/IOOS