Пример #1
0
    def collect(self, **kwargs):
        # there is an unfortunate difference in how 52N and ncSOS handle the response format.
        # 52N expects subtype, ncSOS expects schema.
        # consult the observed properties and getcaps to figure out which should be used if none passed
        if 'responseFormat' not in kwargs:

            # iterate offerings and see if we need to change to subtype
            off_dict = {off.name: off for off in self.server.offerings}

            response_format = None

            for offering in kwargs.get('offerings', []):
                if offering not in off_dict:
                    continue

                ioos_formats = [
                    rf for rf in off_dict[offering].response_formats
                    if 'ioos_sos/1.0' in rf
                ]
                if not len(ioos_formats):
                    raise Exception(
                        "No ioos_sos/1.0 response format found for offering {}"
                        .format(offering))

                if response_format != ioos_formats[0]:
                    response_format = ioos_formats[0]

            kwargs["responseFormat"] = response_format

        return IoosGetObservation(self.raw(**kwargs)).observations
Пример #2
0
    def test_o_and_m_get_observation(self):
        data = open(resource_file(os.path.join('ioos_swe', 'OM-GetObservation.xml')), "rb").read()

        d = IoosGetObservation(data)
        assert d.ioos_version       == "1.0"
        assert len(d.observations)  == 1

        ts = d.observations[0]
        assert ts.description.replace("\n", "").replace("       ", "").replace("  -", " -") == "Observations at point station urn:ioos:station:wmo:41001, 150 NM East of Cape HATTERAS. Observations at point station urn:ioos:station:wmo:41002, S HATTERAS - 250 NM East of Charleston, SC"
        assert ts.begin_position                == datetime(2009, 5, 23, 0, tzinfo=pytz.utc)
        assert ts.end_position                  == datetime(2009, 5, 23, 2, tzinfo=pytz.utc)
        assert sorted(ts.procedures)            == sorted(["urn:ioos:station:wmo:41001", "urn:ioos:station:wmo:41002"])
        assert sorted(ts.observedProperties)    == sorted([ "http://mmisw.org/ont/cf/parameter/air_temperature",
                                                            "http://mmisw.org/ont/cf/parameter/sea_water_temperature",
                                                            "http://mmisw.org/ont/cf/parameter/wind_direction",
                                                            "http://mmisw.org/ont/cf/parameter/wind_speed",
                                                            "http://mmisw.org/ont/ioos/parameter/dissolved_oxygen"
                                                            ])
        assert ts.feature_type          == "timeSeries"

        assert ts.bbox_srs.getcode()    == "EPSG:4326"
        assert ts.bbox.equals(box(-75.42, 32.38, -72.73, 34.7))

        assert ts.location["urn:ioos:station:wmo:41001"].equals(Point(-72.73, 34.7))
        assert ts.location["urn:ioos:station:wmo:41002"].equals(Point(-75.415, 32.382))