| 1 |
# SOS version 2.0 tests using the 52North installation for IOOS: http://ioossos.axiomalaska.com/ |
| 2 |
|
| 3 |
# Imports |
| 4 |
|
| 5 |
>>> from owslib.sos import SensorObservationService |
| 6 |
>>> from owslib.swe.observation.sos200 import SOSGetObservationResponse |
| 7 |
>>> from owslib.etree import etree |
| 8 |
|
| 9 |
# Setup |
| 10 |
|
| 11 |
#>>> service = SensorObservationService('http://geoviqua.dev.52north.org/SOS-Q/sos/kvp',version='2.0.0') |
| 12 |
|
| 13 |
>>> service = SensorObservationService('http://ioossos.axiomalaska.com/52n-sos-ioos-stable/sos/kvp',version='2.0.0') |
| 14 |
|
| 15 |
# http://ioossos.axiomalaska.com/52n-sos-ioos-stable/sos/kvp?service=SOS&request=GetObservation&namespaces=xmlns(om%2Chttp%3A%2F%2Fwww.opengis.net%2Fom%2F2.0)&temporalFilter=om%3AphenomenonTime%2Clatest&version=2.0.0 |
| 16 |
|
| 17 |
# Check allowed params for get observation |
| 18 |
|
| 19 |
>>> get_obs=service.get_operation_by_name('GetObservation') |
| 20 |
|
| 21 |
>>> response = service.get_observation(responseFormat='http://www.opengis.net/om/2.0', offerings=['urn:ioos:station:test:8'], observedProperties=['http://mmisw.org/ont/cf/parameter/sea_water_temperature'], timeout=60) |
| 22 |
|
| 23 |
>>> xml_tree = etree.fromstring(response) |
| 24 |
|
| 25 |
>>> parsed_response = SOSGetObservationResponse(xml_tree) |
| 26 |
|
| 27 |
>>> type(parsed_response) |
| 28 |
<class 'owslib.swe.observation.sos200.SOSGetObservationResponse'> |
| 29 |
|
| 30 |
>>> o=parsed_response.observations[0] |
| 31 |
|
| 32 |
## Value changes each call so can't be tested |
| 33 |
|
| 34 |
## >>> o.get_result().value |
| 35 |
|
| 36 |
>>> o.get_result().uom |
| 37 |
'urn:ogc:def:uom:udunits:2:Cel' |
| 38 |
|
| 39 |
# This O&M structure of the results splits each point into an O&M object, resulting in 400 results |
| 40 |
|
| 41 |
>>> len(parsed_response.observations) |
| 42 |
400 |
| 43 |
>>> type(parsed_response.observations[0]) |
| 44 |
<class 'owslib.swe.observation.om.MeasurementObservation'> |
| 45 |
|
| 46 |
# Get observation for a specific offering (in this case corresponds to a station) and observed property (sea water temperature) |
| 47 |
|
| 48 |
>>> response = service.get_observation(responseFormat='http://www.opengis.net/waterml/2.0', offerings=['urn:ioos:station:test:8'], observedProperties=['http://mmisw.org/ont/cf/parameter/sea_water_temperature'], timeout=60) |
| 49 |
>>> xml_tree = etree.fromstring(response) |
| 50 |
>>> parsed_response = SOSGetObservationResponse(xml_tree) |
| 51 |
>>> type(parsed_response) |
| 52 |
<class 'owslib.swe.observation.sos200.SOSGetObservationResponse'> |
| 53 |
|
| 54 |
>>> len(parsed_response.observations) |
| 55 |
20 |
| 56 |
>>> type(parsed_response.observations[0]) |
| 57 |
<class 'owslib.swe.observation.waterml2.MeasurementTimeseriesObservation'> |
| 58 |
>>> type(parsed_response.observations[0].get_result()) |
| 59 |
<class 'owslib.swe.observation.waterml2.MeasurementTimeseries'> |
| 60 |
|
| 61 |
>>> measurement_timeseries = parsed_response.observations[0].get_result() |
| 62 |
>>> len(measurement_timeseries) |
| 63 |
20 |