/[escript]/trunk/downunder/test/python/run_seismic.py
ViewVC logotype

Contents of /trunk/downunder/test/python/run_seismic.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4539 - (show annotations)
Thu Nov 28 00:38:10 2013 UTC (5 years, 10 months ago) by gross
File MIME type: text/x-python
File size: 2379 byte(s)
segy writer test added.
1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2013 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development since 2012 by School of Earth Sciences
13 #
14 ##############################################################################
15
16 __copyright__="""Copyright (c) 2003-2013 by University of Queensland
17 http://www.uq.edu.au
18 Primary Business: Queensland, Australia"""
19 __license__="""Licensed under the Open Software License version 3.0
20 http://www.opensource.org/licenses/osl-3.0.php"""
21 __url__="https://launchpad.net/escript-finley"
22
23 import logging
24 import unittest
25 import numpy as np
26 import os
27 import sys
28 from esys.downunder import *
29 from esys.escript import unitsSI as U
30 from esys.weipa import saveSilo
31
32 # this is mainly to avoid warning messages
33 logging.basicConfig(format='%(name)s: %(message)s', level=logging.INFO)
34
35 try:
36 TEST_DATA_ROOT=os.environ['DOWNUNDER_TEST_DATA_ROOT']
37 except KeyError:
38 TEST_DATA_ROOT='ref_data'
39
40 try:
41 WORKDIR=os.environ['DOWNUNDER_WORKDIR']
42 except KeyError:
43 WORKDIR='.'
44
45
46
47
48 class TestSeismicTools(unittest.TestCase):
49 def test_segy_writer1(self):
50 sw= SimpleSEGYWriter(receiver_group=[0.,1.,2.], source=1., sampling_interval=10*U.msec, text="testing")
51 self.assertRaises(ValueError, sw.addRecord, [1])
52 for i in xrange(713):
53 # Create some random data.
54 data = np.random.ranf(3)
55 sw.addRecord(data)
56 sw.write(os.path.join(WORKDIR,"test1.sgy"))
57
58 def test_segy_writer2(self):
59 sw= SimpleSEGYWriter(receiver_group=[(0.,0.),(1.,-1.),(2.,-2)], source=(3,3), sampling_interval=10*U.msec, text="testing")
60 self.assertRaises(ValueError, sw.addRecord, [1])
61 for i in xrange(411):
62 # Create some random data.
63 data = np.random.ranf(3)
64 sw.addRecord(data)
65 sw.write(os.path.join(WORKDIR,"test2.sgy"))
66
67
68
69 if __name__ == "__main__":
70 suite = unittest.TestSuite()
71 suite.addTest(unittest.makeSuite(TestSeismicTools))
72 s=unittest.TextTestRunner(verbosity=2).run(suite)
73 if not s.wasSuccessful(): sys.exit(1)
74

  ViewVC Help
Powered by ViewVC 1.1.26