{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Extra convenience methods for common responses\n", "\n", "### OPeNDAP\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2023-08-09T14:31:53.685573Z", "iopub.status.busy": "2023-08-09T14:31:53.685264Z", "iopub.status.idle": "2023-08-09T14:31:54.214144Z", "shell.execute_reply": "2023-08-09T14:31:54.213424Z" } }, "outputs": [], "source": [ "from erddapy import ERDDAP\n", "\n", "\n", "e = ERDDAP(server=\"https://gliders.ioos.us/erddap\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2023-08-09T14:31:54.217495Z", "iopub.status.busy": "2023-08-09T14:31:54.217010Z", "iopub.status.idle": "2023-08-09T14:31:54.653037Z", "shell.execute_reply": "2023-08-09T14:31:54.652325Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "https://gliders.ioos.us/erddap/tabledap/whoi_406-20160902T1700\n", "Slocum glider dataset gathered as part of the TEMPESTS (The Experiment to Measure and Predict East coast STorm Strength), funded by NOAA through CINAR (Cooperative Institute for the North Atlantic Region).\n" ] } ], "source": [ "from netCDF4 import Dataset\n", "\n", "\n", "e.constraints = None\n", "e.protocol = \"tabledap\"\n", "e.dataset_id = \"whoi_406-20160902T1700\"\n", "\n", "opendap_url = e.get_download_url(\n", " response=\"opendap\",\n", ")\n", "\n", "print(opendap_url)\n", "with Dataset(opendap_url) as nc:\n", " print(nc.summary)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### netCDF Climate and Forecast\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2023-08-09T14:31:54.656416Z", "iopub.status.busy": "2023-08-09T14:31:54.655925Z", "iopub.status.idle": "2023-08-09T14:31:55.016064Z", "shell.execute_reply": "2023-08-09T14:31:55.015313Z" }, "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Unidata Dataset Discovery v1.0, COARDS, CF-1.6\n", "\n", "float32 temperature(obs)\n", " _ChunkSizes: 106\n", " _FillValue: -999.0\n", " actual_range: [ 9.9473 22.6177]\n", " ancillary_variables: qartod_temperature_climatological_flag qartod_temperature_flat_line_flag qartod_temperature_gross_range_flag qartod_temperature_rate_of_change_flag qartod_temperature_spike_flag temperature_qc\n", " colorBarMaximum: 32.0\n", " colorBarMinimum: 0.0\n", " coordinates: time latitude longitude depth\n", " instrument: instrument_ctd\n", " ioos_category: Temperature\n", " long_name: Sea Water Temperature\n", " observation_type: measured\n", " platform: platform\n", " standard_name: sea_water_temperature\n", " units: Celsius\n", " valid_max: 40.0\n", " valid_min: -5.0\n", "unlimited dimensions: \n", "current shape = (54245,)\n", "filling on\n" ] } ], "source": [ "e.response = \"nc\"\n", "e.variables = [\"longitude\", \"latitude\", \"temperature\", \"salinity\"]\n", "\n", "nc = e.to_ncCF()\n", "\n", "print(nc.Conventions)\n", "print(nc[\"temperature\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### xarray\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2023-08-09T14:31:55.019070Z", "iopub.status.busy": "2023-08-09T14:31:55.018699Z", "iopub.status.idle": "2023-08-09T14:31:56.013354Z", "shell.execute_reply": "2023-08-09T14:31:56.012521Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.Dataset>\n",
       "Dimensions:          (trajectory: 1, profile: 525, obs: 54245)\n",
       "Coordinates:\n",
       "  * trajectory       (trajectory) object 'whoi_406-20160902T1700'\n",
       "    time             (profile) datetime64[ns] ...\n",
       "    longitude        (profile) float64 ...\n",
       "    latitude         (profile) float64 ...\n",
       "    depth            (obs) float32 ...\n",
       "Dimensions without coordinates: profile, obs\n",
       "Data variables:\n",
       "    profile_id       (profile) float64 ...\n",
       "    trajectoryIndex  (profile) int32 ...\n",
       "    rowSize          (profile) int32 ...\n",
       "    temperature      (obs) float32 ...\n",
       "    salinity         (obs) float32 ...\n",
       "Attributes: (12/56)\n",
       "    acknowledgment:                This deployment supported by NOAA through ...\n",
       "    cdm_data_type:                 TrajectoryProfile\n",
       "    cdm_profile_variables:         time_uv,lat_uv,lon_uv,u,v,profile_id,time,...\n",
       "    cdm_trajectory_variables:      trajectory,wmo_id\n",
       "    comment:                       Glider operatored by Woods Hole Oceanograp...\n",
       "    contributor_name:              Robert Todd, Larry George, Patrick Deane, ...\n",
       "    ...                            ...\n",
       "    subsetVariables:               wmo_id,trajectory,profile_id,time,latitude...\n",
       "    summary:                       Slocum glider dataset gathered as part of ...\n",
       "    time_coverage_end:             2016-09-20T13:32:33Z\n",
       "    time_coverage_start:           2016-09-02T17:05:38Z\n",
       "    title:                         whoi_406-20160902T1700\n",
       "    Westernmost_Easting:           -71.54982816987487
" ], "text/plain": [ "\n", "Dimensions: (trajectory: 1, profile: 525, obs: 54245)\n", "Coordinates:\n", " * trajectory (trajectory) object 'whoi_406-20160902T1700'\n", " time (profile) datetime64[ns] ...\n", " longitude (profile) float64 ...\n", " latitude (profile) float64 ...\n", " depth (obs) float32 ...\n", "Dimensions without coordinates: profile, obs\n", "Data variables:\n", " profile_id (profile) float64 ...\n", " trajectoryIndex (profile) int32 ...\n", " rowSize (profile) int32 ...\n", " temperature (obs) float32 ...\n", " salinity (obs) float32 ...\n", "Attributes: (12/56)\n", " acknowledgment: This deployment supported by NOAA through ...\n", " cdm_data_type: TrajectoryProfile\n", " cdm_profile_variables: time_uv,lat_uv,lon_uv,u,v,profile_id,time,...\n", " cdm_trajectory_variables: trajectory,wmo_id\n", " comment: Glider operatored by Woods Hole Oceanograp...\n", " contributor_name: Robert Todd, Larry George, Patrick Deane, ...\n", " ... ...\n", " subsetVariables: wmo_id,trajectory,profile_id,time,latitude...\n", " summary: Slocum glider dataset gathered as part of ...\n", " time_coverage_end: 2016-09-20T13:32:33Z\n", " time_coverage_start: 2016-09-02T17:05:38Z\n", " title: whoi_406-20160902T1700\n", " Westernmost_Easting: -71.54982816987487" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds = e.to_xarray()\n", "\n", "ds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### iris\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2023-08-09T14:31:56.016790Z", "iopub.status.busy": "2023-08-09T14:31:56.016187Z", "iopub.status.idle": "2023-08-09T14:31:56.846670Z", "shell.execute_reply": "2023-08-09T14:31:56.845772Z" }, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: The trajectory to which this profile is associated. / (unknown) (-- : 525)\n", "1: sea_water_temperature / (Celsius) (-- : 54245)\n", "2: Profile ID / (unknown) (-- : 525)\n", "3: sea_water_practical_salinity / (1) (-- : 54245)\n", "4: Number of Observations for this Profile / (unknown) (-- : 525)\n", "5: Trajectory Name / (unknown) (-- : 1)\n", "6: latitude / (degrees) (-- : 525)\n", "7: time / (seconds since 1970-01-01T00:00:00Z) (-- : 525)\n", "8: longitude / (degrees) (-- : 525)\n" ] } ], "source": [ "import warnings\n", "\n", "# Iris warnings are quire verbose!\n", "with warnings.catch_warnings():\n", " warnings.simplefilter(\"ignore\")\n", " cubes = e.to_iris()\n", "\n", "print(cubes)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "execution": { "iopub.execute_input": "2023-08-09T14:31:56.850407Z", "iopub.status.busy": "2023-08-09T14:31:56.850139Z", "iopub.status.idle": "2023-08-09T14:31:56.868094Z", "shell.execute_reply": "2023-08-09T14:31:56.867442Z" }, "scrolled": false }, "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", " \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", "\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", "\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", "
Sea Water Temperature (Celsius)--
Shape54245
Auxiliary coordinates
\tdepthx
Attributes
\tConventions'Unidata Dataset Discovery v1.0, COARDS, CF-1.6'
\tEasternmost_Easting-70.67537291773046
\tMetadata_Conventions'Unidata Dataset Discovery v1.0, COARDS, CF-1.6'
\tNorthernmost_Northing41.120018298037856
\tSouthernmost_Northing40.257794149155615
\tWesternmost_Easting-71.54982816987487
\t_ChunkSizes106
\tacknowledgment'This deployment supported by NOAA through the Cooperative Institute for ...'
\tactual_rangearray([ 9.9473, 22.6177], dtype=float32)
\tcdm_data_type'TrajectoryProfile'
\tcdm_profile_variables'time_uv,lat_uv,lon_uv,u,v,profile_id,time,latitude,longitude'
\tcdm_trajectory_variables'trajectory,wmo_id'
\tcolorBarMaximum32.0
\tcolorBarMinimum0.0
\tcomment'Glider operatored by Woods Hole Oceanographic Institution'
\tcontributor_name'Robert Todd, Larry George, Patrick Deane, Sean Whalen, John Kerfoot'
\tcontributor_role'Principal Investigator, pilot and technician, technician, technician, data ...'
\tcreator_email'rtodd@whoi.edu'
\tcreator_name'Robert Todd'
\tcreator_url'gliders.whoi.edu'
\tdate_created'2016-09-09T22:06:05Z'
\tdate_issued'2016-09-09T22:06:05Z'
\tfeatureType'TrajectoryProfile'
\tformat_version'/tmp/IOOS_Glider_NetCDF_v2.0-qartod.nc'
\tgeospatial_lat_max41.120018298037856
\tgeospatial_lat_min40.257794149155615
\tgeospatial_lat_units'degrees_north'
\tgeospatial_lon_max-70.67537291773046
\tgeospatial_lon_min-71.54982816987487
\tgeospatial_lon_units'degrees_east'
\tgeospatial_vertical_max98.05
\tgeospatial_vertical_min2.49
\tgeospatial_vertical_positive#x27;down'
\tgeospatial_vertical_units'm'
\tgts_ingest'true'
\thistory'2016-09-09T22:06:05Z /home/kerfoot/slocum/matlab/spt/export/nc/IOOS/DAC/writeQartodGliderFlatNc.m%standard ...'
\tid'whoi_406-20160905T0304'
\tinfoUrl'https://gliders.ioos.us/erddap/'
\tinstitution'Woods Hole Oceanographic Institution'
\tinstrument'instrument_ctd'
\tioos_category'Temperature'
\tioos_dac_checksum'6e67c5e2c364def562bb32242dec8fd5'
\tioos_dac_completed'True'
\tkeywords'AUVS > Autonomous Underwater Vehicles, Earth Science > Oceans > Ocean Pressure ...'
\tkeywords_vocabulary'GCMD Science Keywords'
\tlicense'This data may be redistributed and used without restriction. Data provided ...'
\tnaming_authority'edu.rutgers.marine'
\tobservation_type'measured'
\tplatform'platform'
\tplatform_type'Slocum Glider'
\tproject'TEMPESTS'
\tpublisher_email'kerfoot@marine.rutgers.edu'
\tpublisher_name'John Kerfoot'
\tpublisher_url'https://rucool/marine.rutgers.edu'
\treferences'https://ioos.noaa.gov/wp-content/uploads/2015/10/Manual-for-QC-of-Glid ...'
\tsea_name'Mid-Atlantic Bight'
\tsource'Observational data from a profiling glider'
\tsourceUrl'(local files)'
\tstandard_name_vocabulary'CF-v25'
\tsubsetVariables'wmo_id,trajectory,profile_id,time,latitude,longitude'
\tsummary'Slocum glider dataset gathered as part of the TEMPESTS (The Experiment ...'
\ttime_coverage_end'2016-09-20T13:32:33Z'
\ttime_coverage_start'2016-09-02T17:05:38Z'
\ttitle'whoi_406-20160902T1700'
\tvalid_max40.0
\tvalid_min-5.0
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cubes.extract_cube(\"sea_water_temperature\")" ] } ], "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.11.4" } }, "nbformat": 4, "nbformat_minor": 1 }