{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Quick introduction\n",
"\n",
"erddapy is a pure python package and can be installed with conda\n",
"\n",
"```shell\n",
"conda install --channel conda-forge erddapy\n",
"```\n",
"\n",
"or pip\n",
"\n",
"```shell\n",
"pip install erddapy\n",
"```\n",
"\n",
"\n",
"First we need to instantiate the ERDDAP URL constructor for a server.\n",
"In these examples we will use [https://erddap.sensors.ioos.us/erddap/index.html](https://erddap.sensors.ioos.us/erddap/index.html)."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-14T17:42:00.059220Z",
"iopub.status.busy": "2025-04-14T17:42:00.058814Z",
"iopub.status.idle": "2025-04-14T17:42:00.568345Z",
"shell.execute_reply": "2025-04-14T17:42:00.567838Z"
}
},
"outputs": [],
"source": [
"from erddapy import ERDDAP\n",
"\n",
"server = \"https://erddap.sensors.ioos.us/erddap\"\n",
"e = ERDDAP(\n",
" server=server,\n",
" protocol=\"tabledap\",\n",
" response=\"csv\",\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can populate the object a dataset id, variables of interest, and its\n",
"constraints (last week gliders). Use the method `to_pandas` to download the\n",
"csv(p) response, a comma separated values with units and explore the Dataframe.\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-14T17:42:00.570246Z",
"iopub.status.busy": "2025-04-14T17:42:00.570068Z",
"iopub.status.idle": "2025-04-14T17:42:03.536949Z",
"shell.execute_reply": "2025-04-14T17:42:03.536350Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" latitude (degrees_north) | \n",
" longitude (degrees_east) | \n",
" sea_water_temperature (degree_Celsius) | \n",
" air_temperature (degree_Celsius) | \n",
"
\n",
" \n",
" time (UTC) | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" 2005-11-14 23:00:40+00:00 | \n",
" 32.8032 | \n",
" -79.6204 | \n",
" 20.3767 | \n",
" 21.7 | \n",
"
\n",
" \n",
" 2005-11-15 01:00:40+00:00 | \n",
" 32.8032 | \n",
" -79.6204 | \n",
" 20.0283 | \n",
" 20.9 | \n",
"
\n",
" \n",
" 2005-11-15 03:00:40+00:00 | \n",
" 32.8032 | \n",
" -79.6204 | \n",
" 19.7840 | \n",
" 20.3 | \n",
"
\n",
" \n",
" 2005-11-15 05:00:40+00:00 | \n",
" 32.8032 | \n",
" -79.6204 | \n",
" 19.6207 | \n",
" 20.1 | \n",
"
\n",
" \n",
" 2005-11-15 07:00:40+00:00 | \n",
" 32.8032 | \n",
" -79.6204 | \n",
" 19.7652 | \n",
" 20.8 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" latitude (degrees_north) longitude (degrees_east) \\\n",
"time (UTC) \n",
"2005-11-14 23:00:40+00:00 32.8032 -79.6204 \n",
"2005-11-15 01:00:40+00:00 32.8032 -79.6204 \n",
"2005-11-15 03:00:40+00:00 32.8032 -79.6204 \n",
"2005-11-15 05:00:40+00:00 32.8032 -79.6204 \n",
"2005-11-15 07:00:40+00:00 32.8032 -79.6204 \n",
"\n",
" sea_water_temperature (degree_Celsius) \\\n",
"time (UTC) \n",
"2005-11-14 23:00:40+00:00 20.3767 \n",
"2005-11-15 01:00:40+00:00 20.0283 \n",
"2005-11-15 03:00:40+00:00 19.7840 \n",
"2005-11-15 05:00:40+00:00 19.6207 \n",
"2005-11-15 07:00:40+00:00 19.7652 \n",
"\n",
" air_temperature (degree_Celsius) \n",
"time (UTC) \n",
"2005-11-14 23:00:40+00:00 21.7 \n",
"2005-11-15 01:00:40+00:00 20.9 \n",
"2005-11-15 03:00:40+00:00 20.3 \n",
"2005-11-15 05:00:40+00:00 20.1 \n",
"2005-11-15 07:00:40+00:00 20.8 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"e.dataset_id = \"org_cormp_cap2\"\n",
"\n",
"e.variables = [\n",
" \"time\",\n",
" \"latitude\",\n",
" \"longitude\",\n",
" \"sea_water_temperature\",\n",
" \"air_temperature\",\n",
"]\n",
"\n",
"e.constraints = {\n",
" \"time>=\": \"2000-01-01\",\n",
"}\n",
"\n",
"\n",
"df = e.to_pandas(\n",
" index_col=\"time (UTC)\",\n",
" parse_dates=True,\n",
").dropna()\n",
"\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can constraint the in time and space with relative constraints like in the\n",
"example below. For more ways to access the data please check the \"Longer\n",
"introduction.\"\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-14T17:42:03.565560Z",
"iopub.status.busy": "2025-04-14T17:42:03.565354Z",
"iopub.status.idle": "2025-04-14T17:42:03.569235Z",
"shell.execute_reply": "2025-04-14T17:42:03.568697Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://erddap.ioos.us/erddap/tabledap/processed_asset_inventory.htmlTable?&longitude<=min(longitude)+10&longitude>=min(longitude)&latitude<=min(latitude)+10&latitude>=min(latitude)\n"
]
}
],
"source": [
"server = \"https://erddap.ioos.us/erddap\"\n",
"e = ERDDAP(\n",
" server=server,\n",
" protocol=\"tabledap\",\n",
" response=\"csv\",\n",
")\n",
"\n",
"e.dataset_id = \"processed_asset_inventory\"\n",
"\n",
"# Get the box of the first 10 degrees bbox.\n",
"constraints = {\n",
" \"longitude<=\": \"min(longitude)+10\",\n",
" \"longitude>=\": \"min(longitude)\",\n",
" \"latitude<=\": \"min(latitude)+10\",\n",
" \"latitude>=\": \"min(latitude)\",\n",
"}\n",
"\n",
"\n",
"url = e.get_download_url(\n",
" response=\"htmlTable\",\n",
" constraints=constraints,\n",
")\n",
"\n",
"print(url)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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 `/erddap//allDatasets.html` page, like [this one](https://erddap.ifremer.fr/erddap/tabledap/allDatasets.html) for the Ifremer ERDDAP server."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-14T17:42:03.570768Z",
"iopub.status.busy": "2025-04-14T17:42:03.570607Z",
"iopub.status.idle": "2025-04-14T17:42:03.696616Z",
"shell.execute_reply": "2025-04-14T17:42:03.696132Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://erddap.ioos.us/erddap/tabledap/allDatasets.html?datasetID,institution\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" institution | \n",
"
\n",
" \n",
" datasetID | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" allDatasets | \n",
" Integrated Ocean Observing System (IOOS) | \n",
"
\n",
" \n",
" atn_collection | \n",
" IOOS / ATN | \n",
"
\n",
" \n",
" atn_99310_bearded-seal_trajectory_20110617-20120606 | \n",
" NOAA Alaska Fisheries Science Center | \n",
"
\n",
" \n",
" OBIS | \n",
" ??? | \n",
"
\n",
" \n",
" ra_regional_boundaries | \n",
" NOAA/NOS/IOOS | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" institution\n",
"datasetID \n",
"allDatasets Integrated Ocean Observing System (IOOS)\n",
"atn_collection IOOS / ATN\n",
"atn_99310_bearded-seal_trajectory_20110617-2012... NOAA Alaska Fisheries Science Center\n",
"OBIS ???\n",
"ra_regional_boundaries NOAA/NOS/IOOS"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"e.dataset_id = \"allDatasets\"\n",
"\n",
"e.variables = [\n",
" \"datasetID\",\n",
" \"institution\",\n",
"]\n",
"\n",
"\n",
"url = e.get_download_url(response=\"html\")\n",
"print(url)\n",
"\n",
"df = e.to_pandas(\n",
" index_col=\"datasetID\",\n",
").dropna()\n",
"\n",
"\n",
"df.head()"
]
}
],
"metadata": {
"_draft": {
"nbviewer_url": "https://gist.github.com/7e5eab16282538d11fdab7de5bd0c474"
},
"gist": {
"data": {
"description": "ERDDAP_advanced_glider_search.ipynb",
"public": true
},
"id": "7e5eab16282538d11fdab7de5bd0c474"
},
"gist_id": "3f0f25b13ade0c64c84607bd92903d1b",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
}