Skip to content

Instantly share code, notes, and snippets.

@emiliom
Created October 30, 2013 21:36
Show Gist options
  • Save emiliom/7240742 to your computer and use it in GitHub Desktop.
Save emiliom/7240742 to your computer and use it in GitHub Desktop.
#IOOS #SOS #OWSLib Client Access Tests for IOOS SOS Milestone 1, using the AOOS 52North SOS endpoint. Access the AOOS SOS GetCapabilities, then issue a sample GetObservation request. Currently the GetObs request is failing; it returns a stock web page, not a data response. 2013/10/30
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "AOOS_SOS_owslib_AlaskaNDBCBuoy"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": "# Client Access Tests for IOOS SOS Milestone 1, using the AOOS 52North SOS endpoint\nAccess the AOOS SOS GetCapabilities, then issue a sample GetObservation request. Currently the GetObs request is failing; it returns a stock web page, not a data response. 2013/10/30"
},
{
"cell_type": "code",
"collapsed": false,
"input": "from owslib.sos import SensorObservationService\nfrom datetime import datetime\nimport urllib2",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": "# AOOS SOS Tests (GetCap extracted from the AOOS 52N SOS Test Client)\naoossos_gc_url = \"http://sos.aoos.org/sos/sos/kvp?service=SOS&request=GetCapabilities&AcceptVersions=1.0.0\"",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": "aoosxml = urllib2.urlopen(aoossos_gc_url).read()\naoosgc = SensorObservationService(None, xml=aoosxml)",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": "aoosgcid = aoosgc.identification\nprint aoosgcid.title, \" || \", aoosgcid.version, \" || \", aoosgcid.abstract",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "AOOS 52N SOS || 1.0.0 || AOOS 52North Sensor Observation Service\n"
}
],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": "aoosgcid.keywords",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "pyout",
"prompt_number": 8,
"text": "['Alaska', 'observing', 'ocean', 'sensor', 'system']"
}
],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": "print len(aoosgc.contents), type(aoosgc.contents)\nprint len(aoosgc.offerings), type(aoosgc.offerings)",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "1380 <type 'dict'>\n1380 <type 'list'>\n"
}
],
"prompt_number": 13
},
{
"cell_type": "code",
"collapsed": false,
"input": "# find wmo 46083 ndbc buoy offering, from the offerings list\nndbcfind = [offering for offering in aoosgc.offerings if '46083' in offering.name.lower()]\nprint len(ndbcfind), ndbcfind[0].name, ndbcfind[0].id",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "1 urn:ioos:station:wmo:46083 urn_ioos_station_wmo_46083\n"
}
],
"prompt_number": 45
},
{
"cell_type": "code",
"collapsed": false,
"input": "#aoosoff1 = aoosgc.offerings[800]\naoosoff1 = ndbcfind[0]\nprint aoosoff1.id, aoosoff1.name, aoosoff1.description\nprint aoosoff1.procedures",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "urn_ioos_station_wmo_46083 urn:ioos:station:wmo:46083 None\n['urn:ioos:station:wmo:46083']\n"
}
],
"prompt_number": 46
},
{
"cell_type": "code",
"collapsed": false,
"input": "print aoosoff1.bbox\nprint aoosoff1.begin_position, aoosoff1.end_position\nprint '\\n'.join(aoosoff1.response_formats), '\\n-----------\\n', '\\n'.join(aoosoff1.observed_properties)",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "(-137.986, 58.237, -137.986, 58.237)\n2013-07-22 14:50:00.182000+00:00 2013-10-03 04:00:00.844000+00:00\napplication/zip\ntext/xml;subtype=\"om/1.0.0\"\ntext/xml;subtype=\"om/1.0.0/profiles/ioos_sos/1.0\" \n-----------\nNONE\nhttp://mmisw.org/ont/cf/parameter/air_pressure\nhttp://mmisw.org/ont/cf/parameter/air_temperature\nhttp://mmisw.org/ont/cf/parameter/dew_point_temperature\nhttp://mmisw.org/ont/cf/parameter/sea_surface_swell_wave_period\nhttp://mmisw.org/ont/cf/parameter/sea_surface_swell_wave_significant_height\nhttp://mmisw.org/ont/cf/parameter/sea_surface_swell_wave_to_direction\nhttp://mmisw.org/ont/cf/parameter/sea_surface_wave_significant_height\nhttp://mmisw.org/ont/cf/parameter/sea_surface_wind_wave_period\nhttp://mmisw.org/ont/cf/parameter/sea_surface_wind_wave_significant_height\nhttp://mmisw.org/ont/cf/parameter/sea_surface_wind_wave_to_direction\nhttp://mmisw.org/ont/cf/parameter/sea_water_temperature\nhttp://mmisw.org/ont/cf/parameter/wind_from_direction\nhttp://mmisw.org/ont/cf/parameter/wind_speed\nhttp://mmisw.org/ont/cf/parameter/wind_speed_of_gust\nhttp://mmisw.org/ont/fake/parameter/sea_surface_dominant_wave_period\nhttp://mmisw.org/ont/fake/parameter/sea_surface_dominant_wave_to_direction\nhttp://mmisw.org/ont/fake/parameter/sea_surface_wave_mean_period\n"
}
],
"prompt_number": 50
},
{
"cell_type": "code",
"collapsed": false,
"input": "offering = [aoosoff1.name]\nrespFormat = aoosoff1.response_formats[2]\nobsProps = [\"http://mmisw.org/ont/cf/parameter/wind_speed\"]\nprint offering, respFormat, '\\n', obsProps",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "['urn:ioos:station:wmo:46083'] text/xml;subtype=\"om/1.0.0/profiles/ioos_sos/1.0\" \n['http://mmisw.org/ont/cf/parameter/wind_speed']\n"
}
],
"prompt_number": 54
},
{
"cell_type": "code",
"collapsed": false,
"input": "# buoy WMO id\nsta_id='46083' # Station 46083 (LLNR 1082) - Fairweather Ground 105NM West of Juno, AK\n# pick a start & stop time\nstart = '2013-10-25T00:00:00Z'\nstop = '2013-10-30T00:00:00Z'",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 53
},
{
"cell_type": "code",
"collapsed": false,
"input": "#eventTime = None\n# issue the SOS get_obs request\nresponse = aoosgc.get_observation(offerings=['urn:ioos:station:wmo:%s' % sta_id],\n responseFormat=respFormat,\n observedProperties=obsProps,\n eventTime='%s/%s' % (start,stop))",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 61
},
{
"cell_type": "code",
"collapsed": false,
"input": "print len(response), type(response)",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "8014 <type 'str'>\n"
}
],
"prompt_number": 62
},
{
"cell_type": "code",
"collapsed": false,
"input": "from IPython.core.display import HTML\nHTML(response)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "\n\n\n\n\n\n\n\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n\t<head>\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n\t\t<meta http-equiv=\"Content-Language\" content=\"en\" />\n\t\t<meta name=\"author\" content=\"c.autermann@52north.org\" />\n\t\t<meta name=\"Date-Creation-yyyymmdd\" content=\"20120306\" />\n\t\t<meta name=\"Date-Revision-yyyymmdd\" content=\"20120307\" />\n\t\t<link href=\"/sos/static/images/favicon.ico\" rel=\"shortcut icon\" type=\"image/x-icon\" /> \n\t\t<link rel=\"stylesheet\" href=\"/sos/static/css/52n.css\" type=\"text/css\" />\n\t\t<link rel=\"stylesheet\" href=\"/sos/static/css/52n.cssmenu.css\" type=\"text/css\"/>\n\t\t<link rel=\"stylesheet\" href=\"/sos/static/lib/bootstrap-2.3.1.min.css\" type=\"text/css\" />\n\t\t<link rel=\"stylesheet\" href=\"/sos/static/css/application.css\" type=\"text/css\" />\n\t\t<script type=\"text/javascript\" src=\"/sos/static/js/arrays.js\"></script>\n\t\t<script type=\"text/javascript\" src=\"/sos/static/lib/jquery-1.8.2.min.js\"></script>\n\t\t<script type=\"text/javascript\" src=\"/sos/static/lib/bootstrap-2.3.1.min.js\"></script>\n\t\t<script type=\"text/javascript\" src=\"/sos/static/js/application.js\"></script>\n\t\t<title>52&deg;North Sensor Observation Service</title>\n\t\t\n \n\t</head>\n\t<body>\n\t\t<div id=\"wrap\">\n\t\t\t<div id=\"main\" class=\"clearfix\">\n\t\t\t\t<div id=\"navigation_h\">\n\t\t\t\t\t<div id=\"wopper\" class=\"wopper\">\n\t\t\t\t\t\t<div id=\"ja-mainnavwrap\">\n\t\t\t\t\t\t\t<div id=\"ja-mainnav\">\n\t\t\t\t\t\t\t\t<ul id=\"ja-cssmenu\" class=\"clearfix\">\n\t\t\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t\t\t<a id=\"home-menuitem\" class=\"menu-item0\" href=\"/sos/index\">\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"menu-title\">Home</span>\n\t\t\t\t\t\t\t\t\t\t</a>\n </li>\n \n <li>\n <a id=\"client-menuitem\" class=\"menu-item1\" href=\"/sos/client\">\n <span class=\"menu-title\">Test Client</span>\n </a>\n </li>\n \n \n <li>\n <a id=\"admin-menuitem\" class=\"menu-item2\" href=\"/sos/admin/index\">\n <span class=\"menu-title\">Admin</span>\n </a>\n \n </li>\n \n \n\t\t\t\t\t\t\t\t</ul> \n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\t$(\"#ja-cssmenu li a#home-menuitem\").addClass(\"active\");\n\t\t\t\t</script>\n\t\t\t\t<div class=\"container\">\n\t\t\t\t\t<div id=\"content\" class=\"span12\">\n\n\n\n<div>\n\t<h4>52&deg;North SOS - IOOS Build</h4>\n</div>\n<div class=\"row\">\n\t<div class=\"span9\">\n\t\t<h2>52&deg;North SOS</h2>\n\t\t<p class=\"lead\">Open Source Sensor Observation Service</p>\n\t</div>\n\t<div class=\"span3 header-img-span\">\n\t\t<img src=\"/sos/static/images/52n-logo-220x80.png\"/>\n\t\t<img style=\"padding:10px 0 10px 20px;\" src=\"/sos/static/images/ioos_logo.png\"/>\t\t\n\t</div>\n</div>\n\n<div></div>\n\n<hr/>\n<p>The 52&deg;North SOS is an open source software implementation of the Open Geospatial Consortium's Sensor Observation Service (SOS) Standard.</p>\n\n<p>From the menu at the top you can access a basic form-based test client and the administrative backend.</p>\n\n<p>More information about the SOS and further software components, for example clients, can be found on the <a href=\"http://52north.org/communities/sensorweb/\" title=\"52&deg;North Sensor Web Community Website\">Sensor Web community homepage</a>.</p>\n\n<br/>\n\n\n\n</div>\n</div>\n</div>\n</div>\n<div id=\"footer\">\n <div id=\"f_top\">\n <div id=\"f_navigation\">\n <div class=\"fn_box\">\n <h3>Communities</h3>\n <ul class=\"fn_list\">\n <li><a target=\"_blank\" href=\"http://52north.org/communities/sensorweb/\">Sensor Web</a></li>\n <li><a target=\"_blank\" href=\"http://52north.org/communities/geoprocessing\">Geoprocessing</a></li>\n <li><a target=\"_blank\" href=\"http://52north.org/communities/ilwis/overview\">ILWIS</a></li>\n <li><a target=\"_blank\" href=\"http://52north.org/communities/earth-observation/overview\">Earth Observation</a></li>\n <li><a target=\"_blank\" href=\"http://52north.org/communities/security/\">Security &amp; Geo-RM</a></li>\n <li><a target=\"_blank\" href=\"http://52north.org/communities/semantics/\">Semantics</a></li>\n <li><a target=\"_blank\" href=\"http://52north.org/communities/geostatistics/overview\">Geostatistics</a></li>\n <li><a target=\"_blank\" href=\"http://52north.org/communities/3d-community\">3D Community</a></li>\n <li><a target=\"_blank\" href=\"http://52north.org/communities/metadata-management-community/\">Metadata Management</a></li>\n </ul>\n </div>\n <div class=\"fn_box\">\n <h3>Get Involved</h3>\n <ul class=\"fn_list\">\n <li><a href=\"http://52north.org/about/get-involved/partnership-levels\" target=\"_blank\">Partnership Levels</a></li>\n <li><a href=\"http://52north.org/about/get-involved/license-agreement\" target=\"_blank\">License Agreement</a></li>\n </ul>\n </div>\n <div class=\"fn_box\">\n <h3>Affiliations</h3>\n <p>The 52&deg;North affiliations:</p>\n <a href=\"http://www.opengeospatial.org/\" target=\"_blank\" title=\"OGC Assiciate Members\"><img border=\"0\" alt=\"\" src=\"http://52north.org/images/logos/ogc.gif\" /></a>\n <br />\n <a href=\"http://www.sensorweb-alliance.org/\" target=\"_blank\" title=\"Sensor Web Alliance\"><img border=\"0\" alt=\"\" src=\"http://52north.org/images/logos/swa.gif\" /></a>\n </div>\n <div class=\"fn_box\">\n <h3>Cooperation partners</h3>\n <p>The 52&deg;North principal cooperation partners</p>\n <a href=\"http://ifgi.uni-muenster.de/\" target=\"_blank\" title=\"Institute for Geoinformatics\">Institute for Geoinformatics</a><br/>\n <a href=\"http://www.conterra.de/\" target=\"_blank\" title=\"con terra GmbH\">con terra GmbH</a><br/>\n <a href=\"http://www.esri.com/\" target=\"_blank\" title=\"ESRI\">ESRI</a><br/>\n <a href=\"http://www.itc.nl/\" target=\"_blank\" title=\"International Institute for Geo-Information Science and Earth Observation\">International Institute for Geo-Information Science and Earth Observation</a>\n </div>\n </div>\n </div>\n <div id=\"f_bottom\">\n <ul>\n <li class=\"ja-firstitem\"><a href=\"/sos/get-involved\">Get Involved</a></li>\n <li><a href=\"/sos/license\">Licenses</a></li>\n <li><a href=\"http://52north.org/about/contact\" target=\"_blank\">Contact</a></li>\n <li><a href=\"http://52north.org/about/imprint\" target=\"_blank\">Imprint</a></li>\n <li><a id=\"scrollToTop\" href=\"#\">Top</a></li>\n </ul>\n <script type=\"text/javascript\">\n $(\"#scrollToTop\").click(function() {\n $(\"body,html\").animate({ \"scrollTop\": 0 }, 800);\n return false;\n });\n </script>\n <small>Tested in Firefox 17.0.1, Google Chrome 23.0.1271.95, Safari 6, Internet Explorer 10</small>\n <br/>\n <small>Copyright &copy; \n <script type=\"text/javascript\">document.write(new Date().getFullYear());</script>\n <noscript>2012</noscript>\n 52&deg;North Initiative for Geospatial Open Source Software GmbH. All Rights Reserved.\n </small>\n </div>\n</div>\n</body>\n</html>\n\n",
"output_type": "pyout",
"prompt_number": 63,
"text": "<IPython.core.display.HTML at 0x5d76410>"
}
],
"prompt_number": 63
},
{
"cell_type": "code",
"collapsed": false,
"input": "",
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment