Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

#!/usr/bin/env python 

# -*- coding: utf-8 -*- 

""" 

The cross correlation test suite. 

""" 

 

import os 

import unittest 

from obspy import read, UTCDateTime 

from obspy.signal.cross_correlation import xcorrPickCorrection 

 

 

class CrossCorrelationTestCase(unittest.TestCase): 

    """ 

    Cross corrrelation test case 

    """ 

    def setUp(self): 

        # directory where the test files are located 

        self.path = os.path.join(os.path.dirname(__file__), 'data') 

 

    def test_xcorrPickCorrection(self): 

        """ 

        Test cross correlation pick correction on a set of two small local 

        earthquakes. 

        """ 

        st1 = read(os.path.join(self.path, 

                                'BW.UH1._.EHZ.D.2010.147.a.slist.gz')) 

        st2 = read(os.path.join(self.path, 

                                'BW.UH1._.EHZ.D.2010.147.b.slist.gz')) 

 

        tr1 = st1.select(component="Z")[0] 

        tr2 = st2.select(component="Z")[0] 

        t1 = UTCDateTime("2010-05-27T16:24:33.315000Z") 

        t2 = UTCDateTime("2010-05-27T16:27:30.585000Z") 

 

        dt, coeff = xcorrPickCorrection(t1, tr1, t2, tr2, 0.05, 0.2, 0.1) 

        self.assertAlmostEquals(dt, -0.014459080288833711) 

        self.assertAlmostEquals(coeff, 0.91542878457939791) 

        dt, coeff = xcorrPickCorrection(t2, tr2, t1, tr1, 0.05, 0.2, 0.1) 

        self.assertAlmostEquals(dt, 0.014459080288833711) 

        self.assertAlmostEquals(coeff, 0.91542878457939791) 

        dt, coeff = xcorrPickCorrection(t1, tr1, t2, tr2, 0.05, 0.2, 0.1, 

                filter="bandpass", 

                filter_options={'freqmin': 1, 'freqmax': 10}) 

        self.assertAlmostEquals(dt, -0.013025086360067755) 

        self.assertAlmostEquals(coeff, 0.98279277273758803) 

 

 

def suite(): 

    return unittest.makeSuite(CrossCorrelationTestCase, 'test') 

 

 

if __name__ == '__main__': 

    unittest.main(defaultTest='suite')