Example #1
0
def test_greatcircle_points_generator():
    """
    Tests the greatcircle discrete point generator.
    """
    points = list(utils.greatcircle_points(
        utils.Point(0, 0), utils.Point(0, 90), max_npts=90))
    assert len(points) == 90
    assert [_i.lat for _i in points] == 90 * [0.0]
    np.testing.assert_array_almost_equal([_i.lng for _i in points],
                                         np.linspace(0, 90, 90))

    points = list(utils.greatcircle_points(
        utils.Point(0, 0), utils.Point(0, 90), max_npts=110))
    assert len(points) == 110
Example #2
0
def test_greatcircle_points_generator():
    """
    Tests the greatcircle discrete point generator.
    """
    points = list(
        utils.greatcircle_points(utils.Point(0, 0),
                                 utils.Point(0, 90),
                                 max_npts=90))
    assert len(points) == 90
    assert [_i.lat for _i in points] == 90 * [0.0]
    np.testing.assert_array_almost_equal([_i.lng for _i in points],
                                         np.linspace(0, 90, 90))

    points = list(
        utils.greatcircle_points(utils.Point(0, 0),
                                 utils.Point(0, 90),
                                 max_npts=110))
    assert len(points) == 110
Example #3
0
    def is_event_station_raypath_within_boundaries(
        self,
        event_name: str,
        station_latitude: float,
        station_longitude: float,
        raypath_steps: int = 500,
    ):
        """
        Checks if the full station-event raypath is within the project's domain
        boundaries.

        Returns True if this is the case, False if not.

        :param event_name: Name of the event
        :type event_name: str
        :param station_latitude: The station latitude.
        :type station_latitude: float
        :param station_longitude: The station longitude.
        :type station_longitude: float
        :param raypath_steps: The number of discrete points along the raypath
            that will be checked, defaults to 25
        :type raypath_steps: int, optional
        """
        from lasif.utils import greatcircle_points, Point

        ev = self.comm.events.get(event_name)

        domain = self.comm.project.domain

        # Short circuit.
        if domain.is_global_domain():
            return True

        for point in greatcircle_points(
            Point(station_latitude, station_longitude),
            Point(ev["latitude"], ev["longitude"]),
            max_npts=raypath_steps,
        ):

            if not domain.point_in_domain(
                latitude=point.lat, longitude=point.lng
            ):
                return False
        return True
Example #4
0
    def is_event_station_raypath_within_boundaries(self,
                                                   event_name,
                                                   station_latitude,
                                                   station_longitude,
                                                   raypath_steps=25):
        """
        Checks if the full station-event raypath is within the project's domain
        boundaries.

        Returns True if this is the case, False if not.

        :type event_latitude: float
        :param event_latitude: The event latitude.
        :type event_longitude: float
        :param event_longitude: The event longitude.
        :type station_latitude: float
        :param station_latitude: The station latitude.
        :type station_longitude: float
        :param station_longitude: The station longitude.
        :type raypath_steps: int
        :param raypath_steps: The number of discrete points along the raypath
            that will be checked. Optional.
        """
        from lasif.utils import greatcircle_points, Point
        import lasif.domain

        ev = self.comm.events.get(event_name)

        domain = self.comm.project.domain

        # Shortcircuit.
        if isinstance(domain, lasif.domain.GlobalDomain):
            return True

        for point in greatcircle_points(Point(station_latitude,
                                              station_longitude),
                                        Point(ev["latitude"], ev["longitude"]),
                                        max_npts=raypath_steps):

            if not domain.point_in_domain(latitude=point.lat,
                                          longitude=point.lng):
                return False
        return True
Example #5
0
    def is_event_station_raypath_within_boundaries(
            self, event_name, station_latitude, station_longitude,
            raypath_steps=25):
        """
        Checks if the full station-event raypath is within the project's domain
        boundaries.

        Returns True if this is the case, False if not.

        :type event_latitude: float
        :param event_latitude: The event latitude.
        :type event_longitude: float
        :param event_longitude: The event longitude.
        :type station_latitude: float
        :param station_latitude: The station latitude.
        :type station_longitude: float
        :param station_longitude: The station longitude.
        :type raypath_steps: int
        :param raypath_steps: The number of discrete points along the raypath
            that will be checked. Optional.
        """
        from lasif.utils import greatcircle_points, Point
        import lasif.domain

        ev = self.comm.events.get(event_name)

        domain = self.comm.project.domain

        # Shortcircuit.
        if isinstance(domain, lasif.domain.GlobalDomain):
            return True

        for point in greatcircle_points(
                Point(station_latitude, station_longitude),
                Point(ev["latitude"], ev["longitude"]),
                max_npts=raypath_steps):

            if not domain.point_in_domain(latitude=point.lat,
                                          longitude=point.lng):
                return False
        return True
Example #6
0
    def is_event_station_raypath_within_boundaries(
        self, event_latitude, event_longitude, station_latitude, station_longitude, raypath_steps=25
    ):
        """
        Checks if the full station-event raypath is within the project's domain
        boundaries.

        Returns True if this is the case, False if not.

        :type event_latitude: float
        :param event_latitude: The event latitude.
        :type event_longitude: float
        :param event_longitude: The event longitude.
        :type station_latitude: float
        :param station_latitude: The station latitude.
        :type station_longitude: float
        :param station_longitude: The station longitude.
        :type raypath_steps: int
        :param raypath_steps: The number of discrete points along the raypath
            that will be checked. Optional.
        """
        from lasif.utils import greatcircle_points, Point, point_in_domain

        domain = self.comm.project.domain

        for point in greatcircle_points(
            Point(station_latitude, station_longitude), Point(event_latitude, event_longitude), max_npts=raypath_steps
        ):

            if not point_in_domain(
                point.lat,
                point.lng,
                domain["bounds"],
                rotation_axis=domain["rotation_axis"],
                rotation_angle_in_degree=domain["rotation_angle"],
            ):
                return False
        return True
Example #7
0
 def add_greatcircle(self, point_1, point_2, max_npts=3000):
     for point in greatcircle_points(point_1, point_2, self.max_range,
                                     max_npts):
         self.add_point(point)
Example #8
0
 def add_greatcircle(self, point_1, point_2, max_npts=3000):
     for point in greatcircle_points(point_1, point_2, self.max_range,
                                     max_npts):
         self.add_point(point)