1 | import unittest |
---|
2 | import numpy |
---|
3 | from eqf import earthquake_tsunami, Okada_func |
---|
4 | |
---|
5 | class Test_eq(unittest.TestCase): |
---|
6 | def setUp(self): |
---|
7 | pass |
---|
8 | |
---|
9 | def tearDown(self): |
---|
10 | pass |
---|
11 | |
---|
12 | |
---|
13 | def test_Okada_func(self): |
---|
14 | x0 = 38000.0 |
---|
15 | y0 = 12500.0 |
---|
16 | length = 25.0 |
---|
17 | width = 5.0 |
---|
18 | strike = 0.0 |
---|
19 | depth = 3500. |
---|
20 | slip = 10.0 |
---|
21 | dip = 15.0 |
---|
22 | rake = 90.0 |
---|
23 | test = -2205.904774487 |
---|
24 | |
---|
25 | #print 'depth', depth |
---|
26 | z = Okada_func(length=length, width=width, dip=dip, \ |
---|
27 | x0=x0, y0=y0, strike=strike, depth=depth, \ |
---|
28 | slip=slip, rake=rake, test=test) |
---|
29 | |
---|
30 | assert numpy.allclose(z.length, length) |
---|
31 | assert numpy.allclose(z.width, width) |
---|
32 | assert numpy.allclose(z.x0, x0) |
---|
33 | assert numpy.allclose(z.y0, y0) |
---|
34 | assert numpy.allclose(z.strike, strike) |
---|
35 | assert numpy.allclose(z.depth, depth) |
---|
36 | assert numpy.allclose(z.slip, slip) |
---|
37 | assert numpy.allclose(z.dip, dip) |
---|
38 | assert numpy.allclose(z.rake, rake) |
---|
39 | |
---|
40 | #print 'in test', z.test |
---|
41 | assert numpy.allclose(z.test, -2205.904774487) |
---|
42 | |
---|
43 | #print 'hello finished okada' |
---|
44 | |
---|
45 | def test_earthquake_tsunami(self): |
---|
46 | |
---|
47 | x0 = 0.0 |
---|
48 | y0 = 0.0 |
---|
49 | length = 25.0 |
---|
50 | width = 5.0 |
---|
51 | strike = 0.0 |
---|
52 | depth = 3500. |
---|
53 | slip = 10.0 |
---|
54 | dip = 15.0 |
---|
55 | |
---|
56 | eq = earthquake_tsunami(length=length, width = width, depth=depth, \ |
---|
57 | strike = strike, dip = dip, slip = slip, \ |
---|
58 | x0 = x0, y0 = y0) |
---|
59 | |
---|
60 | #------------------------------------------------------------- |
---|
61 | if __name__ == "__main__": |
---|
62 | suite = unittest.makeSuite(Test_eq,'test_Okada_func') |
---|
63 | #suite = unittest.makeSuite(Test_eq,'test_earthquake_tsunami') |
---|
64 | runner = unittest.TextTestRunner() |
---|
65 | runner.run(suite) |
---|
66 | |
---|