Beispiel #1
0
 def test_readAndWriteMultiChannelASCFile(self):
     """
     Read and write ASC file via obspy.sh.core.readASC.
     """
     origfile = os.path.join(self.path, 'data', 'QFILE-TEST-ASC.ASC')
     # read original
     stream1 = readASC(origfile)
     stream1.verify()
     self._compareStream(stream1)
     # write
     tempfile = NamedTemporaryFile().name
     writeASC(stream1, tempfile, STANDARD_ASC_HEADERS + ['COMMENT'])
     # read both files and compare the content
     text1 = open(origfile, 'rb').read()
     text2 = open(tempfile, 'rb').read()
     self.assertEquals(text1, text2)
     # read again
     stream2 = readASC(tempfile)
     stream2.verify()
     self._compareStream(stream2)
     os.remove(tempfile)
Beispiel #2
0
 def test_readAndWriteMultiChannelASCFile(self):
     """
     Read and write ASC file via obspy.sh.core.readASC.
     """
     origfile = os.path.join(self.path, 'data', 'QFILE-TEST-ASC.ASC')
     # read original
     stream1 = readASC(origfile)
     stream1.verify()
     self._compareStream(stream1)
     # write
     tempfile = NamedTemporaryFile().name
     writeASC(stream1, tempfile, STANDARD_ASC_HEADERS + ['COMMENT'])
     # read both files and compare the content
     text1 = open(origfile, 'rb').read()
     text2 = open(tempfile, 'rb').read()
     self.assertEquals(text1, text2)
     # read again
     stream2 = readASC(tempfile)
     stream2.verify()
     self._compareStream(stream2)
     os.remove(tempfile)
Beispiel #3
0
 def test_skipASClines(self):
     testfile = os.path.join(self.path, 'data', 'QFILE-TEST-ASC.ASC')
     # read
     stream = readASC(testfile, skip=100, delta=0.1, length=2)
     stream.verify()
     # skip force one trace only
     self.assertEqual(len(stream), 1)
     # headers
     self.assertEqual(stream[0].stats.delta, 1.000000e-01)
     self.assertEqual(stream[0].stats.npts, 2)
     # check samples
     self.assertEqual(len(stream[0].data), 2)
     self.assertAlmostEqual(stream[0].data[0], 111.7009, 4)
     self.assertAlmostEqual(stream[0].data[1], 119.5831, 4)
Beispiel #4
0
 def test_skipASClines(self):
     testfile = os.path.join(self.path, 'data', 'QFILE-TEST-ASC.ASC')
     # read
     stream = readASC(testfile, skip=100, delta=0.1, length=2)
     stream.verify()
     # skip force one trace only
     self.assertEqual(len(stream), 1)
     # headers
     self.assertEqual(stream[0].stats.delta, 1.000000e-01)
     self.assertEqual(stream[0].stats.npts, 2)
     # check samples
     self.assertEqual(len(stream[0].data), 2)
     self.assertAlmostEqual(stream[0].data[0], 111.7009, 4)
     self.assertAlmostEqual(stream[0].data[1], 119.5831, 4)
Beispiel #5
0
 def test_readSingleChannelASCFile(self):
     """
     Read ASC file test via obspy.sh.core.readASC.
     """
     testfile = os.path.join(self.path, 'data', 'TEST_090101_0101.ASC')
     # read
     stream = readASC(testfile)
     stream.verify()
     self.assertEqual(stream[0].stats.delta, 5.000000e-02)
     self.assertEqual(stream[0].stats.npts, 1000)
     self.assertEqual(stream[0].stats.starttime,
                      UTCDateTime(2009, 1, 1, 1, 1, 1))
     self.assertEqual(stream[0].stats.channel, 'BHZ')
     self.assertEqual(stream[0].stats.station, 'TEST')
     self.assertEqual(stream[0].stats.calib, 1.0e-00)
     # check last 4 samples
     data = [2.176000e+01, 2.195485e+01, 2.213356e+01, 2.229618e+01]
     np.testing.assert_array_almost_equal(stream[0].data[-4:], data)
Beispiel #6
0
 def test_readSingleChannelASCFile(self):
     """
     Read ASC file test via obspy.sh.core.readASC.
     """
     testfile = os.path.join(self.path, 'data', 'TEST_090101_0101.ASC')
     # read
     stream = readASC(testfile)
     stream.verify()
     self.assertEqual(stream[0].stats.delta, 5.000000e-02)
     self.assertEqual(stream[0].stats.npts, 1000)
     self.assertEqual(stream[0].stats.starttime,
                      UTCDateTime(2009, 1, 1, 1, 1, 1))
     self.assertEqual(stream[0].stats.channel, 'BHZ')
     self.assertEqual(stream[0].stats.station, 'TEST')
     self.assertEqual(stream[0].stats.calib, 1.0e-00)
     # check last 4 samples
     data = [2.176000e+01, 2.195485e+01, 2.213356e+01, 2.229618e+01]
     np.testing.assert_array_almost_equal(stream[0].data[-4:], data)