Exemplo n.º 1
0
 def test_cross_chan_coherence_non_matching_sampling_rates(self):
     """Initial test to ensure cross_chan_coherence runs."""
     st2 = self.st2.copy()
     for tr in st2:
         tr.stats.sampling_rate += 20
     with warnings.catch_warnings(record=True) as w:
         cross_chan_coherence(st1=self.st1.copy(), st2=st2)
         self.assertTrue('Sampling rates do not match' in str(w[0].message))
Exemplo n.º 2
0
 def test_cross_chan_coherence_non_matching(self):
     """Initial test to ensure cross_chan_coherence runs."""
     st2 = self.st2.copy()
     for tr in st2:
         tr.stats.station += 'A'
     with warnings.catch_warnings(record=True) as w:
         cross_chan_coherence(st1=self.st1.copy(), st2=st2)
         self.assertEqual(len(w), 1)
         self.assertTrue('No matching channels' in str(w[0].message))
Exemplo n.º 3
0
 def test_inverted_coherence(self):
     """Reverse channels and ensure we get -1"""
     st2 = self.st2.copy()
     for tr in st2:
         tr.data *= -1
     cccoh, i = cross_chan_coherence(st1=self.st1.copy(), st2=st2, i=1)
     self.assertEqual(cccoh, -1)
     self.assertEqual(i, 1)
Exemplo n.º 4
0
 def test_cross_chan_coherence(self):
     """Initial test to ensure cross_chan_coherence runs."""
     from eqcorrscan.utils.clustering import cross_chan_coherence
     from obspy import read
     st1 = read()
     st2 = read()
     cccoh, i = cross_chan_coherence(st1=st1, st2=st2)
     self.assertEqual(cccoh, 1)
     self.assertEqual(i, 0)
Exemplo n.º 5
0
 def test_known_coherence(self):
     """Test for a real stream case"""
     st1 = read(os.path.join(self.testing_path, 'WAV', 'TEST_',
                             '2013-09-01-0410-35.DFDPC_024_00'))
     st2 = read(os.path.join(self.testing_path, 'WAV', 'TEST_',
                             '2013-09-01-2040-11.DFDPC_039_00'))
     cccoh, i = cross_chan_coherence(st1=st1, st2=st2)
     self.assertTrue(cccoh < 0.01)
     self.assertEqual(i, 0)
Exemplo n.º 6
0
 def test_cross_chan_coherence(self):
     """Initial test to ensure cross_chan_coherence runs."""
     from eqcorrscan.utils.clustering import cross_chan_coherence
     from obspy import read
     st1 = read()
     st2 = read()
     cccoh, i = cross_chan_coherence(st1=st1, st2=st2)
     self.assertEqual(cccoh, 1)
     self.assertEqual(i, 0)
Exemplo n.º 7
0
 def test_inverted_coherence(self):
     """Reverse channels and ensure we get -1"""
     from eqcorrscan.utils.clustering import cross_chan_coherence
     from obspy import read
     st1 = read()
     st2 = read()
     for tr in st2:
         tr.data *= -1
     cccoh, i = cross_chan_coherence(st1=st1, st2=st2, i=1)
     self.assertEqual(cccoh, -1)
     self.assertEqual(i, 1)
Exemplo n.º 8
0
 def test_inverted_coherence(self):
     """Reverse channels and ensure we get -1"""
     from eqcorrscan.utils.clustering import cross_chan_coherence
     from obspy import read
     st1 = read()
     st2 = read()
     for tr in st2:
         tr.data *= -1
     cccoh, i = cross_chan_coherence(st1=st1, st2=st2, i=1)
     self.assertEqual(cccoh, -1)
     self.assertEqual(i, 1)
Exemplo n.º 9
0
def cc_coh_dets(streams, length, wav_prepick, corr_prepick, shift):
    # Loop over detections and return list of cc_coh with template
    # Trim all wavs to desired length
    # Assumes the first entry is template
    for st in streams:
        for tr in st:
            strt = tr.stats.starttime + wav_prepick - corr_prepick - (shift / 2.)
            tr.trim(starttime=strt, endtime=strt + length + (shift / 2.))
    cccohs = []
    for stream in streams[1:]:
        coh, i = cross_chan_coherence(st1=streams[0], st2=stream,
                                      allow_shift=True, shift_len=shift)
        cccohs.append(coh)
    return cccohs
Exemplo n.º 10
0
 def test_known_coherence(self):
     """Test for a real stream case"""
     from eqcorrscan.utils.clustering import cross_chan_coherence
     from obspy import read
     import os
     testing_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                 'test_data')
     st1 = read(os.path.join(testing_path, 'WAV', 'TEST_',
                             '2013-09-01-0410-35.DFDPC_024_00'))
     st2 = read(os.path.join(testing_path, 'WAV', 'TEST_',
                             '2013-09-01-2040-11.DFDPC_039_00'))
     cccoh, i = cross_chan_coherence(st1=st1, st2=st2)
     self.assertTrue(cccoh < 0.01)
     self.assertEqual(i, 0)
Exemplo n.º 11
0
 def test_cross_chan_coherence_shifted(self):
     """Initial test to ensure cross_chan_coherence runs."""
     cccoh, i = cross_chan_coherence(st1=self.st1.copy(),
                                     st2=self.st2.copy(), allow_shift=True)
     self.assertEqual(round(cccoh, 6), 1)
     self.assertEqual(i, 0)
Exemplo n.º 12
0
 def test_cross_chan_coherence(self):
     """Initial test to ensure cross_chan_coherence runs."""
     cccoh, i = cross_chan_coherence(st1=self.st1.copy(),
                                     st2=self.st2.copy())
     self.assertEqual(cccoh, 1)
     self.assertEqual(i, 0)