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

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

#!/usr/bin/env python 

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

""" 

The paz test suite. 

""" 

 

from obspy.gse2 import paz 

import unittest 

import StringIO 

 

 

class PAZTestCase(unittest.TestCase): 

    """ 

    Test cases for reading GSE PAZ files. 

    """ 

    def test_readWithSpace(self): 

        """ 

        Reading PAZ files where PAZ are separated by spaces. 

        """ 

        f = StringIO.StringIO("""CAL1 RJOB   LE-3D    Z  M24    PAZ 010824 0001 

        2 

        -4.39823 4.48709 

        -4.39823 -4.48709 

        3 

        0.0 0.0 

        0.0 0.0 

        0.0 0.0 

        0.4""") 

        p, z, k = paz.readPaz(f) 

        self.assertAlmostEquals(-4.39823, p[0].real) 

        self.assertAlmostEquals(4.48709, p[0].imag) 

        self.assertAlmostEquals(-4.39823, p[1].real) 

        self.assertAlmostEquals(-4.48709, p[1].imag) 

        self.assertEquals([0j, 0j, 0j], z) 

        self.assertAlmostEquals(0.4, k) 

        f.close() 

 

    def test_readWithOutSpace(self): 

        """ 

        Reading PAZ files where PAZ are not separated by spaces. 

 

        Tests uses unrealistic PAZ information. 

        """ 

        f = StringIO.StringIO("""CAL1 RJOB   LE-3D    Z  M24    PAZ 010824 0001 

2 

-4.3982340.48709 

-4.39823-4.48709 

3 

1.2 4.0 

-1.09823-3.08709 

-1.0982330.08709 

0.5""") 

        p, z, k = paz.readPaz(f) 

        self.assertAlmostEquals(-4.39823, p[0].real) 

        self.assertAlmostEquals(40.48709, p[0].imag) 

        self.assertAlmostEquals(-4.39823, p[1].real) 

        self.assertAlmostEquals(-4.48709, p[1].imag) 

        self.assertAlmostEquals(1.2, z[0].real) 

        self.assertAlmostEquals(4.0, z[0].imag) 

        self.assertAlmostEquals(-1.09823, z[1].real) 

        self.assertAlmostEquals(-3.08709, z[1].imag) 

        self.assertAlmostEquals(-1.09823, z[2].real) 

        self.assertAlmostEquals(30.08709, z[2].imag) 

        self.assertAlmostEquals(0.5, k) 

        f.close() 

 

 

def suite(): 

    return unittest.makeSuite(PAZTestCase, 'test') 

 

 

if __name__ == '__main__': 

    unittest.main(defaultTest='suite')