Exemple #1
0
def list_monitoring_features(self, query: QueryMonitoringFeature):
    """
    Get Monitoring Feature Info
    """
    assert query

    obj_region = self.synthesis_model_class(
        plugin_access=self,
        id="Region1",
        name="AwesomeRegion",
        description="This region is really awesome.",
        feature_type=FeatureTypeEnum.REGION,
        shape=SpatialSamplingShapes.SHAPE_SURFACE,
        coordinates=Coordinate(representative=RepresentativeCoordinate(
            representative_point=AbsoluteCoordinate(
                horizontal_position=GeographicCoordinate(
                    units=GeographicCoordinate.UNITS_DEC_DEGREES,
                    latitude=70.4657,
                    longitude=-20.4567),
                vertical_extent=AltitudeCoordinate(
                    datum=AltitudeCoordinate.DATUM_NAVD88,
                    value=1500,
                    distance_units=VerticalCoordinate.DISTANCE_UNITS_FEET)),
            representative_point_type=RepresentativeCoordinate.
            REPRESENTATIVE_POINT_TYPE_CENTER_LOCAL_SURFACE)))

    yield obj_region

    obj_point = self.synthesis_model_class(
        plugin_access=self,
        id="1",
        name="Point Location 1",
        description="The first point.",
        feature_type=FeatureTypeEnum.POINT,
        shape=SpatialSamplingShapes.SHAPE_POINT,
        coordinates=Coordinate(
            absolute=AbsoluteCoordinate(
                horizontal_position=GeographicCoordinate(
                    units=GeographicCoordinate.UNITS_DEC_DEGREES,
                    latitude=70.4657,
                    longitude=-20.4567),
                vertical_extent=AltitudeCoordinate(
                    datum=AltitudeCoordinate.DATUM_NAVD88,
                    value=1500,
                    distance_units=VerticalCoordinate.DISTANCE_UNITS_FEET)),
            representative=RepresentativeCoordinate(
                vertical_position=DepthCoordinate(
                    datum=DepthCoordinate.DATUM_LOCAL_SURFACE,
                    value=-0.5,
                    distance_units=VerticalCoordinate.DISTANCE_UNITS_METERS))),
        observed_property_variables=["Ag", "Acetate"],
        related_sampling_feature_complex=[
            RelatedSamplingFeature(
                plugin_access=self,
                related_sampling_feature="Region1",
                related_sampling_feature_type=FeatureTypeEnum.REGION,
                role=RelatedSamplingFeature.ROLE_PARENT)
        ])

    yield obj_point
Exemple #2
0
def test_monitoring_feature_create(plugin_access_alpha):
    """Test instance of monitoring feature"""

    a_region = MonitoringFeature(
        plugin_access=plugin_access_alpha,
        id="Region1",
        name="AwesomeRegion",
        description="This region is really awesome.",
        feature_type=FeatureTypeEnum.REGION,
        shape=SpatialSamplingShapes.SHAPE_SURFACE,
        coordinates=Coordinate(representative=RepresentativeCoordinate(
            representative_point=AbsoluteCoordinate(
                horizontal_position=GeographicCoordinate(
                    units=GeographicCoordinate.UNITS_DEC_DEGREES,
                    latitude=70.4657,
                    longitude=-20.4567),
                vertical_extent=AltitudeCoordinate(
                    datum=AltitudeCoordinate.DATUM_NAVD88,
                    value=1500,
                    distance_units=VerticalCoordinate.DISTANCE_UNITS_FEET)),
            representative_point_type=RepresentativeCoordinate.
            REPRESENTATIVE_POINT_TYPE_CENTER_LOCAL_SURFACE)))

    assert a_region.datasource.id == 'Alpha'
    assert a_region.id == 'A-Region1'
    assert a_region.name == 'AwesomeRegion'
    assert a_region.feature_type == FeatureTypeEnum.REGION
    assert a_region.description == 'This region is really awesome.'
    assert a_region.shape == SpatialSamplingShapes.SHAPE_SURFACE
    assert a_region.coordinates.representative.representative_point.horizontal_position[0].units == \
        GeographicCoordinate.UNITS_DEC_DEGREES
    assert a_region.coordinates.representative.representative_point.horizontal_position[
        0].latitude == 70.4657
    assert a_region.coordinates.representative.representative_point.horizontal_position[
        0].longitude == -20.4567
    assert a_region.coordinates.representative.representative_point.vertical_extent[0].datum == \
        AltitudeCoordinate.DATUM_NAVD88
    assert a_region.coordinates.representative.representative_point.vertical_extent[
        0].value == 1500
    assert a_region.coordinates.representative.representative_point.vertical_extent[0].distance_units == \
        VerticalCoordinate.DISTANCE_UNITS_FEET
    assert a_region.coordinates.representative.representative_point_type == \
        RepresentativeCoordinate.REPRESENTATIVE_POINT_TYPE_CENTER_LOCAL_SURFACE

    a_point = MonitoringFeature(
        plugin_access=plugin_access_alpha,
        id='1',
        name='Point Location 1',
        description='The first point.',
        feature_type=FeatureTypeEnum.POINT,
        shape=SpatialSamplingShapes.SHAPE_POINT,
        coordinates=Coordinate(
            absolute=AbsoluteCoordinate(
                horizontal_position=GeographicCoordinate(
                    units=GeographicCoordinate.UNITS_DEC_DEGREES,
                    latitude=70.4657,
                    longitude=-20.4567),
                vertical_extent=AltitudeCoordinate(
                    datum=AltitudeCoordinate.DATUM_NAVD88,
                    value=1500,
                    distance_units=VerticalCoordinate.DISTANCE_UNITS_FEET)),
            representative=RepresentativeCoordinate(
                vertical_position=DepthCoordinate(
                    datum=DepthCoordinate.DATUM_LOCAL_SURFACE,
                    value=-0.5,
                    distance_units=VerticalCoordinate.DISTANCE_UNITS_METERS))),
        observed_property_variables=['Ag', 'Acetate'],
        related_sampling_feature_complex=[
            RelatedSamplingFeature(
                plugin_access=plugin_access_alpha,
                related_sampling_feature='Region1',
                related_sampling_feature_type=FeatureTypeEnum.REGION,
                role=RelatedSamplingFeature.ROLE_PARENT)
        ])

    assert a_point.datasource.id == 'Alpha'
    assert a_point.id == 'A-1'
    assert a_point.name == 'Point Location 1'
    assert a_point.feature_type == FeatureTypeEnum.POINT
    assert a_point.description == 'The first point.'
    assert a_point.shape == SpatialSamplingShapes.SHAPE_POINT
    assert a_point.coordinates.absolute.horizontal_position[0].units == \
        GeographicCoordinate.UNITS_DEC_DEGREES
    assert a_point.coordinates.absolute.horizontal_position[
        0].latitude == 70.4657
    assert a_point.coordinates.absolute.horizontal_position[
        0].longitude == -20.4567
    assert a_point.coordinates.absolute.vertical_extent[0].datum == \
        AltitudeCoordinate.DATUM_NAVD88
    assert a_point.coordinates.absolute.vertical_extent[0].value == 1500
    assert a_point.coordinates.absolute.vertical_extent[0].distance_units == \
        VerticalCoordinate.DISTANCE_UNITS_FEET
    assert a_point.coordinates.representative.vertical_position.value == -0.5
    assert a_point.coordinates.representative.vertical_position.distance_units == \
        VerticalCoordinate.DISTANCE_UNITS_METERS
    assert a_point.coordinates.representative.vertical_position.datum == \
        DepthCoordinate.DATUM_LOCAL_SURFACE
    assert a_point.observed_property_variables == ['ACT', 'Ag']
    assert a_point.related_sampling_feature_complex[
        0].related_sampling_feature == 'A-Region1'
    assert a_point.related_sampling_feature_complex[0].role == 'PARENT'
Exemple #3
0
def _load_point_obj(datasource,
                    json_obj,
                    feature_observed_properties,
                    observed_property_variables=None):
    """
    Instantiate the object

    #
    # The following selected fields are included in this output:
    #
    #  agency_cd       -- Agency
    #  site_no         -- Site identification number
    #  station_nm      -- Site name
    #  site_tp_cd      -- Site type
    #  dec_lat_va      -- Decimal latitude
    #  dec_long_va     -- Decimal longitude
    #  coord_acy_cd    -- Latitude-longitude accuracy
    #  dec_coord_datum_cd -- Decimal Latitude-longitude datum
    #  alt_va          -- Altitude of Gage/land surface
    #  alt_acy_va      -- Altitude accuracy
    #  alt_datum_cd    -- Altitude datum
    #  huc_cd          -- Hydrologic unit code

    :param json_obj:
    :param feature_observed_properties: dictionary of locations and their available variables
    :type feature_observed_properties: dict
    :return:
    """

    if 'site_no' in json_obj:
        id = json_obj['site_no']

        # Get the location variables from the dictionary
        if observed_property_variables is None:
            if id in feature_observed_properties.keys():
                observed_property_variables = feature_observed_properties[id]

        lat, lon = None, None
        try:
            lat, lon = float(json_obj['dec_lat_va']), float(
                json_obj['dec_long_va'])
        except Exception as e:
            logger.error(str(e))

        monitoring_feature = MonitoringFeature(
            datasource,
            id="{}".format(id),
            name=json_obj['station_nm'],
            feature_type=FeatureTypeEnum.POINT,
            shape=SpatialSamplingShapes.SHAPE_POINT,
            related_sampling_feature_complex=[
                RelatedSamplingFeature(
                    datasource,
                    related_sampling_feature=json_obj['huc_cd'],
                    related_sampling_feature_type=FeatureTypeEnum.
                    SUBBASIN,  # previously site
                    role=RelatedSamplingFeature.ROLE_PARENT)
            ],
            # geographical_group_id=huc_accounting_unit_id,
            # geographical_group_type=FeatureTypeEnum.REGION,
            observed_property_variables=observed_property_variables,
            coordinates=Coordinate(absolute=AbsoluteCoordinate(
                horizontal_position=GeographicCoordinate(
                    **{
                        "latitude": lat,
                        "longitude": lon,
                        "datum": json_obj['dec_coord_datum_cd'],
                        "units": GeographicCoordinate.UNITS_DEC_DEGREES
                    }))))

        # huc_accounting_unit_id = json_obj['huc_cd'][0:6]  #Subbasin
        if json_obj['alt_va'] and json_obj['alt_acy_va'] and json_obj[
                'alt_datum_cd']:
            monitoring_feature.coordinates.absolute.vertical_extent = \
                [AltitudeCoordinate(
                    **{"value": float(json_obj['alt_va']),
                       "resolution": float(json_obj['alt_acy_va']),
                       "datum": json_obj['alt_datum_cd']})]

        return monitoring_feature
Exemple #4
0
def find_measurement_timeseries_tvp_observations(self, **kwargs):
    """ Generate the MeasurementTimeseriesTVPObservation

      Attributes:
        - *id:* string, Cs137 MR survey ID
        - *observed_property:* string, Cs137MID
        - *utc_offset:* float (offset in hours), +9
        - *geographical_group_id:* string, River system ID (Region ID).
        - *geographical_group_type* enum (sampling_feature, site, plot, region)
        - *results_points:* Array of DataPoint objects

    """
    data = []
    from datetime import datetime
    for num in range(1, 10):
        data.append((datetime(2016, 2, num), num * 0.3454))

    for num in range(1, 3):
        yield MeasurementTimeseriesTVPObservation(
            plugin_access=self,
            id=num,
            observed_property_variable="Acetate",
            utc_offset=-8 - num,
            feature_of_interest=MonitoringFeature(
                plugin_access=self,
                id=num,
                name="Point Location " + str(num),
                description="The point.",
                feature_type=FeatureTypes.POINT,
                shape=SpatialSamplingShapes.SHAPE_POINT,
                coordinates=Coordinate(
                    absolute=AbsoluteCoordinate(
                        horizontal_position=GeographicCoordinate(
                            units=GeographicCoordinate.UNITS_DEC_DEGREES,
                            latitude=70.4657,
                            longitude=-20.4567),
                        vertical_extent=AltitudeCoordinate(
                            datum=AltitudeCoordinate.DATUM_NAVD88,
                            value=1500,
                            distance_units=VerticalCoordinate.
                            DISTANCE_UNITS_FEET)),
                    representative=RepresentativeCoordinate(
                        vertical_position=DepthCoordinate(
                            datum=DepthCoordinate.DATUM_LOCAL_SURFACE,
                            value=-0.5 - num * 0.1,
                            distance_units=VerticalCoordinate.
                            DISTANCE_UNITS_METERS))),
                observed_property_variables=["Ag", "Acetate"],
                related_sampling_feature_complex=[
                    RelatedSamplingFeature(
                        plugin_access=self,
                        related_sampling_feature="Region1",
                        related_sampling_feature_type=FeatureTypes.REGION,
                        role=RelatedSamplingFeature.ROLE_PARENT)
                ]),
            feature_of_interest_type=FeatureTypes.POINT,
            unit_of_measurement="nm",
            aggregation_duration=TimeFrequency.DAY,
            result_quality="CHECKED",
            time_reference_position=None,
            statistic="MEAN",
            result_points=data)