{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Quick introduction\n", "\n", "gliderpy can be installed with conda\n", "\n", "```\n", "conda install --channel conda-forge gliderpy\n", "```\n", "\n", "or pip\n", "\n", "```\n", "pip install gliderpy\n", "```\n", "\n", "gliderpy aims to make querying and downloading glider data easier.\n", "Here is how one would build a query using erddapy:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2025-05-23T19:45:03.903090Z", "iopub.status.busy": "2025-05-23T19:45:03.902922Z", "iopub.status.idle": "2025-05-23T19:45:07.209298Z", "shell.execute_reply": "2025-05-23T19:45:07.208812Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
depth (m)latitude (degrees_north)longitude (degrees_east)salinity (1)temperature (Celsius)profile_id
time (UTC)
2016-09-02 17:05:38+00:006.4341.120018-71.01711832.07925820.54071
2016-09-02 17:05:38+00:007.8241.120018-71.01711832.09540620.50711
2016-09-02 17:05:38+00:008.6941.120018-71.01711832.11192020.49041
2016-09-02 17:05:38+00:009.5441.120018-71.01711832.12658720.48971
2016-09-02 17:05:38+00:0010.3241.120018-71.01711832.14071720.49091
\n", "
" ], "text/plain": [ " depth (m) latitude (degrees_north) \\\n", "time (UTC) \n", "2016-09-02 17:05:38+00:00 6.43 41.120018 \n", "2016-09-02 17:05:38+00:00 7.82 41.120018 \n", "2016-09-02 17:05:38+00:00 8.69 41.120018 \n", "2016-09-02 17:05:38+00:00 9.54 41.120018 \n", "2016-09-02 17:05:38+00:00 10.32 41.120018 \n", "\n", " longitude (degrees_east) salinity (1) \\\n", "time (UTC) \n", "2016-09-02 17:05:38+00:00 -71.017118 32.079258 \n", "2016-09-02 17:05:38+00:00 -71.017118 32.095406 \n", "2016-09-02 17:05:38+00:00 -71.017118 32.111920 \n", "2016-09-02 17:05:38+00:00 -71.017118 32.126587 \n", "2016-09-02 17:05:38+00:00 -71.017118 32.140717 \n", "\n", " temperature (Celsius) profile_id \n", "time (UTC) \n", "2016-09-02 17:05:38+00:00 20.5407 1 \n", "2016-09-02 17:05:38+00:00 20.5071 1 \n", "2016-09-02 17:05:38+00:00 20.4904 1 \n", "2016-09-02 17:05:38+00:00 20.4897 1 \n", "2016-09-02 17:05:38+00:00 20.4909 1 " ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from erddapy import ERDDAP\n", "\n", "e = ERDDAP(\n", " server=\"https://gliders.ioos.us/erddap\",\n", " protocol=\"tabledap\",\n", " response=\"csv\",\n", ")\n", "e.dataset_id = \"whoi_406-20160902T1700\"\n", "\n", "e.variables = [\n", " \"depth\",\n", " \"latitude\",\n", " \"longitude\",\n", " \"salinity\",\n", " \"temperature\",\n", " \"profile_id\",\n", " \"time\",\n", "]\n", "\n", "df = e.to_pandas(\n", " index_col=\"time (UTC)\",\n", " parse_dates=True,\n", ")\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And here is how to use gliderpy to obtain the same results but with fewer lines and a cleaner code:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2025-05-23T19:45:07.237428Z", "iopub.status.busy": "2025-05-23T19:45:07.237022Z", "iopub.status.idle": "2025-05-23T19:45:12.135732Z", "shell.execute_reply": "2025-05-23T19:45:12.135278Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
latitudelongitudepressureprofile_idsalinitytemperaturedataset_url
time (utc)
2016-09-02 17:05:3841.120018-71.0171186.43132.07925820.5407https://gliders.ioos.us/erddap/tabledap/whoi_4...
2016-09-02 17:05:3841.120018-71.0171187.82132.09540620.5071https://gliders.ioos.us/erddap/tabledap/whoi_4...
2016-09-02 17:05:3841.120018-71.0171188.69132.11192020.4904https://gliders.ioos.us/erddap/tabledap/whoi_4...
2016-09-02 17:05:3841.120018-71.0171189.54132.12658720.4897https://gliders.ioos.us/erddap/tabledap/whoi_4...
2016-09-02 17:05:3841.120018-71.01711810.32132.14071720.4909https://gliders.ioos.us/erddap/tabledap/whoi_4...
\n", "
" ], "text/plain": [ " latitude longitude pressure profile_id salinity \\\n", "time (utc) \n", "2016-09-02 17:05:38 41.120018 -71.017118 6.43 1 32.079258 \n", "2016-09-02 17:05:38 41.120018 -71.017118 7.82 1 32.095406 \n", "2016-09-02 17:05:38 41.120018 -71.017118 8.69 1 32.111920 \n", "2016-09-02 17:05:38 41.120018 -71.017118 9.54 1 32.126587 \n", "2016-09-02 17:05:38 41.120018 -71.017118 10.32 1 32.140717 \n", "\n", " temperature \\\n", "time (utc) \n", "2016-09-02 17:05:38 20.5407 \n", "2016-09-02 17:05:38 20.5071 \n", "2016-09-02 17:05:38 20.4904 \n", "2016-09-02 17:05:38 20.4897 \n", "2016-09-02 17:05:38 20.4909 \n", "\n", " dataset_url \n", "time (utc) \n", "2016-09-02 17:05:38 https://gliders.ioos.us/erddap/tabledap/whoi_4... \n", "2016-09-02 17:05:38 https://gliders.ioos.us/erddap/tabledap/whoi_4... \n", "2016-09-02 17:05:38 https://gliders.ioos.us/erddap/tabledap/whoi_4... \n", "2016-09-02 17:05:38 https://gliders.ioos.us/erddap/tabledap/whoi_4... \n", "2016-09-02 17:05:38 https://gliders.ioos.us/erddap/tabledap/whoi_4... " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from gliderpy.fetchers import GliderDataFetcher\n", "\n", "glider_grab = GliderDataFetcher()\n", "\n", "glider_grab.dataset_ids = [\"whoi_406-20160902T1700\"]\n", "dfs = glider_grab.to_pandas()\n", "df = dfs[\"whoi_406-20160902T1700\"]\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Much easier, right?\n", "The variable names are standardized by gliderpy,\n", "making it easier to fetch from different data sources and comparing the results.\n", "\n", "The gliderpy library can subset the data on the server side by passing a geographic bounding box and time interval.\n", "\n", "We can heck the glider metrics with the `.summary()` method." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2025-05-23T19:45:12.137669Z", "iopub.status.busy": "2025-05-23T19:45:12.137298Z", "iopub.status.idle": "2025-05-23T19:45:12.148310Z", "shell.execute_reply": "2025-05-23T19:45:12.147899Z" } }, "outputs": [ { "data": { "text/plain": [ "num_profiles 545\n", "days 19 days 00:00:00\n", "deployment_lat 41.120018\n", "deployment_lon -71.017118\n", "dtype: object" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.summary()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Querying multiple datasets\n", "\n", "The most common use is to search all datasets for data that falls within the certain space-time bounds." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2025-05-23T19:45:12.150132Z", "iopub.status.busy": "2025-05-23T19:45:12.149745Z", "iopub.status.idle": "2025-05-23T19:45:12.408299Z", "shell.execute_reply": "2025-05-23T19:45:12.407844Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TitleInstitutionDataset IDinfo_url
0silbo-20110413T1600Teledyne Webb Research Corporation,Rutgers Uni...silbo-20110413T1600https://gliders.ioos.us/erddap/info/silbo-2011...
6ru23-20130305T2004Rutgers Universityru23-20130305T2004https://gliders.ioos.us/erddap/info/ru23-20130...
7ru23-20121025T1944Rutgers Universityru23-20121025T1944https://gliders.ioos.us/erddap/info/ru23-20121...
8silbo-20110623T1215Teledyne Webb Research Corporation,Rutgers Uni...silbo-20110623T1215https://gliders.ioos.us/erddap/info/silbo-2011...
9silbo-20120724T1247Teledyne Webb Research Corporation,Rutgers Uni...silbo-20120724T1247https://gliders.ioos.us/erddap/info/silbo-2012...
\n", "
" ], "text/plain": [ " Title Institution \\\n", "0 silbo-20110413T1600 Teledyne Webb Research Corporation,Rutgers Uni... \n", "6 ru23-20130305T2004 Rutgers University \n", "7 ru23-20121025T1944 Rutgers University \n", "8 silbo-20110623T1215 Teledyne Webb Research Corporation,Rutgers Uni... \n", "9 silbo-20120724T1247 Teledyne Webb Research Corporation,Rutgers Uni... \n", "\n", " Dataset ID info_url \n", "0 silbo-20110413T1600 https://gliders.ioos.us/erddap/info/silbo-2011... \n", "6 ru23-20130305T2004 https://gliders.ioos.us/erddap/info/ru23-20130... \n", "7 ru23-20121025T1944 https://gliders.ioos.us/erddap/info/ru23-20121... \n", "8 silbo-20110623T1215 https://gliders.ioos.us/erddap/info/silbo-2011... \n", "9 silbo-20120724T1247 https://gliders.ioos.us/erddap/info/silbo-2012... " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "glider_grab = GliderDataFetcher()\n", "\n", "df = glider_grab.query(\n", " min_lat=10,\n", " max_lat=40,\n", " min_lon=-90,\n", " max_lon=8,\n", " min_time=\"2010-01-01\",\n", " max_time=\"2013-06-02\",\n", ")\n", "df" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2025-05-23T19:45:12.409880Z", "iopub.status.busy": "2025-05-23T19:45:12.409714Z", "iopub.status.idle": "2025-05-23T19:46:06.824002Z", "shell.execute_reply": "2025-05-23T19:46:06.823509Z" } }, "outputs": [ { "data": { "text/plain": [ "dict_keys(['silbo-20110413T1600', 'ru23-20130305T2004', 'ru23-20121025T1944', 'silbo-20110623T1215', 'silbo-20120724T1247'])" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "datasets = glider_grab.to_pandas()\n", "datasets.keys()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "execution": { "iopub.execute_input": "2025-05-23T19:46:06.825592Z", "iopub.status.busy": "2025-05-23T19:46:06.825426Z", "iopub.status.idle": "2025-05-23T19:46:06.832563Z", "shell.execute_reply": "2025-05-23T19:46:06.832173Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
latitudelongitudepressureprofile_idsalinity (1e-3)temperaturedataset_url
time (utc)
2012-10-27 18:20:2539.999821-73.5105661.6728931.97303016.9787https://gliders.ioos.us/erddap/tabledap/ru23-2...
2012-10-27 18:20:2539.999821-73.5105661.6828931.97380616.9775https://gliders.ioos.us/erddap/tabledap/ru23-2...
2012-10-27 18:20:2539.999821-73.510566NaN289NaNNaNhttps://gliders.ioos.us/erddap/tabledap/ru23-2...
2012-10-27 18:20:2539.999821-73.5105661.8228931.97308716.9778https://gliders.ioos.us/erddap/tabledap/ru23-2...
2012-10-27 18:20:2539.999821-73.510566NaN289NaNNaNhttps://gliders.ioos.us/erddap/tabledap/ru23-2...
\n", "
" ], "text/plain": [ " latitude longitude pressure profile_id \\\n", "time (utc) \n", "2012-10-27 18:20:25 39.999821 -73.510566 1.67 289 \n", "2012-10-27 18:20:25 39.999821 -73.510566 1.68 289 \n", "2012-10-27 18:20:25 39.999821 -73.510566 NaN 289 \n", "2012-10-27 18:20:25 39.999821 -73.510566 1.82 289 \n", "2012-10-27 18:20:25 39.999821 -73.510566 NaN 289 \n", "\n", " salinity (1e-3) temperature \\\n", "time (utc) \n", "2012-10-27 18:20:25 31.973030 16.9787 \n", "2012-10-27 18:20:25 31.973806 16.9775 \n", "2012-10-27 18:20:25 NaN NaN \n", "2012-10-27 18:20:25 31.973087 16.9778 \n", "2012-10-27 18:20:25 NaN NaN \n", "\n", " dataset_url \n", "time (utc) \n", "2012-10-27 18:20:25 https://gliders.ioos.us/erddap/tabledap/ru23-2... \n", "2012-10-27 18:20:25 https://gliders.ioos.us/erddap/tabledap/ru23-2... \n", "2012-10-27 18:20:25 https://gliders.ioos.us/erddap/tabledap/ru23-2... \n", "2012-10-27 18:20:25 https://gliders.ioos.us/erddap/tabledap/ru23-2... \n", "2012-10-27 18:20:25 https://gliders.ioos.us/erddap/tabledap/ru23-2... " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "datasets[\"ru23-20121025T1944\"].head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Dataset search\n", "\n", "One can query all dataset_ids available in the server." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "execution": { "iopub.execute_input": "2025-05-23T19:46:06.834097Z", "iopub.status.busy": "2025-05-23T19:46:06.833937Z", "iopub.status.idle": "2025-05-23T19:46:07.406796Z", "shell.execute_reply": "2025-05-23T19:46:07.406385Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "found 1451 glider datasets on https://gliders.ioos.us/erddap.\n" ] } ], "source": [ "from gliderpy.fetchers import DatasetList\n", "\n", "datasets = DatasetList()\n", "ds_ids = datasets.get_ids()\n", "\n", "print(f\"found {len(ds_ids)} glider datasets on {datasets.e.server}.\")" ] } ], "metadata": { "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": 4 }