Esempio n. 1
0
 def do_shoot_existing_ray_param_for_phase(self, phase_name):
     phase = SeismicPhase(phase_name, self.tau_model)
     for i, ray_param in enumerate(phase.ray_param):
         max_rp_arrival = phase.shoot_ray(-1, ray_param)
         self.assertAlmostEqual(phase.dist[i], max_rp_arrival.purist_dist,
                                delta=0.0001)
         self.assertAlmostEqual(phase.time[i], max_rp_arrival.time,
                                delta=0.0001)
Esempio n. 2
0
 def test_shoot_middle_ray_param(self):
     phase = SeismicPhase("P", self.tMod)
     for i in range(phase.ray_param.shape[0] - 1):
         rp = (phase.ray_param[i] + phase.ray_param[i + 1]) / 2
         timeTol = abs(phase.time[i] - phase.time[i + 1])
         maxRPArrival = phase.shoot_ray(-1, rp)
         self.assertAlmostEqual(phase.dist[i], maxRPArrival.purist_dist, delta=0.1)
         self.assertAlmostEqual(phase.time[i], maxRPArrival.time, delta=timeTol)
         self.assertAlmostEqual(phase.dist[i + 1], maxRPArrival.purist_dist, delta=0.1)
         self.assertAlmostEqual(phase.time[i + 1], maxRPArrival.time, delta=timeTol)
Esempio n. 3
0
 def test_shoot_middle_ray_param(self, tau_model):
     phase = SeismicPhase('P', tau_model)
     for i in range(phase.ray_param.shape[0] - 1):
         rp = (phase.ray_param[i] + phase.ray_param[i + 1]) / 2
         time_tol = abs(phase.time[i] - phase.time[i + 1])
         max_rp_arrival = phase.shoot_ray(-1, rp)
         assert abs(phase.dist[i] - max_rp_arrival.purist_dist) < 0.1
         assert abs(phase.time[i] - max_rp_arrival.time) < time_tol
         assert abs(phase.dist[i + 1] - max_rp_arrival.purist_dist) < 0.1
         assert abs(phase.time[i + 1] - max_rp_arrival.time) < time_tol
Esempio n. 4
0
    def test_phase_names(self, tau_model):
        """
        Simple check to see if illegal phase names are caught.
        """
        legal_phase_names = ["ScS", "ScSScS"]
        illegal_phase_names = ["ScScS", "PKIKPKIKP", "PKIKIKP"]

        for name in legal_phase_names:
            SeismicPhase(name, tau_model)

        for name in illegal_phase_names:
            with pytest.raises(TauModelError):
                SeismicPhase(name, tau_model)
Esempio n. 5
0
 def test_shoot_middle_ray_param(self):
     phase = SeismicPhase('P', self.tau_model)
     for i in range(phase.ray_param.shape[0] - 1):
         rp = (phase.ray_param[i] + phase.ray_param[i + 1]) / 2
         time_tol = abs(phase.time[i] - phase.time[i + 1])
         max_rp_arrival = phase.shoot_ray(-1, rp)
         self.assertAlmostEqual(phase.dist[i], max_rp_arrival.purist_dist,
                                delta=0.1)
         self.assertAlmostEqual(phase.time[i], max_rp_arrival.time,
                                delta=time_tol)
         self.assertAlmostEqual(phase.dist[i + 1],
                                max_rp_arrival.purist_dist, delta=0.1)
         self.assertAlmostEqual(phase.time[i + 1], max_rp_arrival.time,
                                delta=time_tol)
Esempio n. 6
0
    def test_fruit(self):
        """
        Check handling of low velocity zones.

        Test case where bottom of mantle has a negative velocity gradient
        so phase cannot turn.
        """
        model_name = "fruit"
        with TemporaryWorkingDirectory():
            folder = os.path.abspath(os.curdir)
            build_taup_model(
              filename=os.path.join(DATA, os.path.pardir, model_name + ".nd"),
              output_folder=folder, verbose=False)
            model = TauPyModel(os.path.join(folder, model_name + ".npz"))

            s_mod = model.model.s_mod
            high_slow_range = s_mod.high_slowness_layer_depths_p[0]
            assert s_mod.depth_in_high_slowness(1360, 18, True)
            assert s_mod.depth_in_high_slowness(
                1360,
                high_slow_range.ray_param+0.00000001,
                True)
            assert not s_mod.depth_in_high_slowness(
                1360,
                high_slow_range.ray_param,
                True)
            assert not s_mod.depth_in_high_slowness(
                1360,
                high_slow_range.ray_param-0.00000001,
                True)

            p = SeismicPhase("P", model.model)
            atol = 1e-2
            np.testing.assert_allclose(p.min_distance, 0.0, atol=atol)
            np.testing.assert_allclose(p.max_distance*180.0/np.pi,
                                       72.66, atol=atol)
            assert p.branch_seq == [0, 0]
Esempio n. 7
0
    def test_diffracted_phases(self):
        """
        Test of exotic diffracted phases.
        """
        model = TauPyModel('iasp91')
        phs = [
            "SedPdiffKP", "PdiffPdiff", "PedPdiffKKP", "PdiffKKPdiff",
            "PPdiff", "SKdiffP"
        ]
        dists = [155.0, 210.0, 310.0, 300.0, 220.0, 200.0]
        times = [1464.97, 1697.88, 2052.42, 2008.03, 1742.27, 1431.53]

        for ph, dist, time in zip(phs, dists, times):
            phase = SeismicPhase(ph, model.model)
            arrivals = phase.calc_time(dist)
            arrival = arrivals[0]
            phase.calc_pierce_from_arrival(arrival)
            phase.calc_path_from_arrival(arrival)

            tol = 1e-2
            assert abs(arrival.time - time) < tol
            assert abs(arrival.pierce["time"][-1] - time) < tol
            assert abs(arrival.path["time"][-1] - time) < tol
Esempio n. 8
0
 def do_shoot_existing_ray_param_for_phase(self, phase_name, tau_model):
     phase = SeismicPhase(phase_name, tau_model)
     for i, ray_param in enumerate(phase.ray_param):
         max_rp_arrival = phase.shoot_ray(-1, ray_param)
         assert abs(phase.dist[i] - max_rp_arrival.purist_dist) < 0.0001
         assert abs(phase.time[i] - max_rp_arrival.time) < 0.0001