Ejemplo n.º 1
0
    def _get_nationalmap_data(self, datum: SeismicData) -> bool:
        """
        Attempts to get elevation properties from National Map data. If no properties can be found
        this function returns false. It does not set the properties to "None".

        Args:
            datum (SeismicData): The data point from which to get elevation properties.

        Returns:
            True, if successful, false if point not found within map.
        """
        bilinear_point = SimplePoint(datum.converted_point.x_value,
                                     datum.converted_point.y_value, 0)

        if bilinear_point.x < -180 or bilinear_point.x > 180 or \
           bilinear_point.y < -90 or bilinear_point.y > 90:
            return False

        # Make sure we can get the National Map data.
        if hasattr(
                self, "dem_nationalmap_" +
                str(-1 * math.floor(datum.converted_point.x_value)) + "_" +
                str(math.floor(datum.converted_point.y_value))):
            use_data = getattr(
                self, "dem_nationalmap_" +
                str(-1 * math.floor(datum.converted_point.x_value)) + "_" +
                str(math.floor(datum.converted_point.y_value)))
        else:
            if hasattr(
                    self._opened_file, "dem_nationalmap_" +
                    str(math.ceil(-1 * datum.converted_point.x_value)) + "_" +
                    str(math.floor(datum.converted_point.y_value))):
                use_data = getattr(
                    self._opened_file, "dem_nationalmap_" +
                    str(-1 * math.floor(datum.converted_point.x_value)) + "_" +
                    str(math.floor(datum.converted_point.y_value)))[:, :]
            else:
                return False

        rect = SimpleRotatedRectangle(use_data["metadata"][1][0],
                                      use_data["metadata"][2][0], 0,
                                      use_data["metadata"][0][0],
                                      use_data["metadata"][0][0])

        value = calculate_bilinear_value(bilinear_point, rect, use_data.data)

        # Check if not defined by DEM (i.e. in water).
        if value == 0 or value == -9999:
            return False

        datum.set_elevation_data(
            ElevationProperties(value, self._public_metadata["id"]))

        return True
Ejemplo n.º 2
0
    def _get_nationalmap_data(self, datum: SeismicData) -> bool:
        """
        Attempts to get elevation properties from National Map data. If no properties can be found
        this function returns false. It does not set the properties to "None".

        Args:
            datum (SeismicData): The data point from which to get elevation properties.

        Returns:
            True, if successful, false if point not found within map.
        """
        bilinear_point = SimplePoint(
            datum.converted_point.x_value,
            datum.converted_point.y_value,
            0
        )

        if bilinear_point.x < -180 or bilinear_point.x > 180 or \
           bilinear_point.y < -90 or bilinear_point.y > 90:
            return False

        # Make sure we can get the National Map data.
        if hasattr(self, "dem_nationalmap_" + str(-1 * math.floor(datum.converted_point.x_value)) + "_" +
           str(math.floor(datum.converted_point.y_value))):
            use_data = getattr(self, "dem_nationalmap_" + str(-1 * math.floor(datum.converted_point.x_value)) + "_" +
                               str(math.floor(datum.converted_point.y_value)))
        else:
            if hasattr(self._opened_file, "dem_nationalmap_" + str(math.ceil(-1 * datum.converted_point.x_value)) +
                       "_" + str(math.floor(datum.converted_point.y_value))):
                use_data = getattr(self._opened_file, "dem_nationalmap_" +
                                   str(-1 * math.floor(datum.converted_point.x_value)) + "_" +
                                   str(math.floor(datum.converted_point.y_value)))[:, :]
            else:
                return False

        rect = SimpleRotatedRectangle(
            use_data["metadata"][1][0],
            use_data["metadata"][2][0],
            0,
            use_data["metadata"][0][0],
            use_data["metadata"][0][0]
        )

        value = calculate_bilinear_value(bilinear_point, rect, use_data.data)

        # Check if not defined by DEM (i.e. in water).
        if value == 0 or value == -9999:
            return False

        datum.set_elevation_data(ElevationProperties(value, self._public_metadata["id"]))

        return True
Ejemplo n.º 3
0
    def _get_etopo1_data(self, datum: SeismicData) -> bool:
        """
        Attempts to get elevation properties from ETOPO1 data. If no properties can be found
        this function returns false. It does not set the properties to "None".

        Args:
            datum (SeismicData): The data point from which to get elevation properties.

        Returns:
            True, if successful, false if point not found within map.
        """
        datum.converted_point = datum.original_point.convert_to_projection(UCVM_DEFAULT_PROJECTION)

        bilinear_point = SimplePoint(
            datum.converted_point.x_value,
            datum.converted_point.y_value,
            0
        )

        if not hasattr(self, "etopo1_data"):
            self.etopo1_data = self._opened_file["dem_etopo1"]["data"][:, :]
            self.etopo1_metadata = self._opened_file["dem_etopo1"]["metadata"][:, :]

        if bilinear_point.x < -180 or bilinear_point.x > 180 or \
           bilinear_point.y < -90 or bilinear_point.y > 90:
            return False

        rect = SimpleRotatedRectangle(
            self.etopo1_metadata[1][0],
            self.etopo1_metadata[2][0],
            0,
            self.etopo1_metadata[0][0],
            self.etopo1_metadata[0][0]
        )

        datum.set_elevation_data(ElevationProperties(
            calculate_bilinear_value(bilinear_point, rect, self.etopo1_data),
            self._public_metadata["id"]
        ))

        return True
Ejemplo n.º 4
0
    def _get_etopo1_data(self, datum: SeismicData) -> bool:
        """
        Attempts to get elevation properties from ETOPO1 data. If no properties can be found
        this function returns false. It does not set the properties to "None".

        Args:
            datum (SeismicData): The data point from which to get elevation properties.

        Returns:
            True, if successful, false if point not found within map.
        """
        datum.converted_point = datum.original_point.convert_to_projection(
            UCVM_DEFAULT_PROJECTION)

        bilinear_point = SimplePoint(datum.converted_point.x_value,
                                     datum.converted_point.y_value, 0)

        if not hasattr(self, "etopo1_data"):
            self.etopo1_data = self._opened_file["dem_etopo1"]["data"][:, :]
            self.etopo1_metadata = self._opened_file["dem_etopo1"][
                "metadata"][:, :]

        if bilinear_point.x < -180 or bilinear_point.x > 180 or \
           bilinear_point.y < -90 or bilinear_point.y > 90:
            return False

        rect = SimpleRotatedRectangle(self.etopo1_metadata[1][0],
                                      self.etopo1_metadata[2][0], 0,
                                      self.etopo1_metadata[0][0],
                                      self.etopo1_metadata[0][0])

        datum.set_elevation_data(
            ElevationProperties(
                calculate_bilinear_value(bilinear_point, rect,
                                         self.etopo1_data),
                self._public_metadata["id"]))

        return True