def test_broken_last_record(self): """ Test if Libmseed is able to read files with broken last record. Use both methods, readMSTracesViaRecords and readMSTraces """ file = os.path.join(self.path, "data", "brokenlastrecord.mseed") # independent reading of the data, 128 Bytes header d = np.fromfile(file, dtype=np.uint8)[128:] data = util._unpack_steim_2(d, 5980, swapflag=self.swap, verbose=0) # test readMSTraces. Will raise an internal warning. with WarningsCapture() as w: data_record = _read_mseed(file)[0].data # This will raise 18 (!) warnings. It will skip 17 * 128 bytes due # to it not being a SEED records and then complain that the remaining # 30 bytes are not enough to constitute a full SEED record. self.assertEqual(len(w), 18) self.assertEqual(w[0].category, InternalMSEEDWarning) # Test against reference data. self.assertEqual(len(data_record), 5980) last10samples = [2862, 2856, 2844, 2843, 2851, 2853, 2853, 2854, 2857, 2863] np.testing.assert_array_equal(data_record[-10:], last10samples) # Also test against independently unpacked data. np.testing.assert_allclose(data_record, data)
def test_broken_last_record(self): """ Test if Libmseed is able to read files with broken last record. Use both methods, readMSTracesViaRecords and readMSTraces """ file = os.path.join(self.path, "data", "brokenlastrecord.mseed") # independent reading of the data, 128 Bytes header d = np.fromfile(file, dtype=np.uint8)[128:] data = util._unpack_steim_2(d, 5980, swapflag=self.swap, verbose=0) # test readMSTraces. Will raise an internal warning. with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") data_record = _read_mseed(file)[0].data self.assertEqual(len(w), 1) self.assertEqual(w[0].category, InternalMSEEDWarning) # Test against reference data. self.assertEqual(len(data_record), 5980) last10samples = [2862, 2856, 2844, 2843, 2851, 2853, 2853, 2854, 2857, 2863] np.testing.assert_array_equal(data_record[-10:], last10samples) # Also test against independently unpacked data. np.testing.assert_allclose(data_record, data)
def test_broken_last_record(self): """ Test if Libmseed is able to read files with broken last record. Use both methods, readMSTracesViaRecords and readMSTraces """ file = os.path.join(self.path, "data", "brokenlastrecord.mseed") # independent reading of the data, 128 Bytes header d = np.fromfile(file, dtype=np.uint8)[128:] data = util._unpack_steim_2(d, 5980, swapflag=self.swap, verbose=0) # test readMSTraces. Will raise an internal warning. with WarningsCapture() as w: data_record = _read_mseed(file)[0].data # This will raise 18 (!) warnings. It will skip 17 * 128 bytes due # to it not being a SEED records and then complain that the remaining # 30 bytes are not enough to constitute a full SEED record. self.assertEqual(len(w), 18) self.assertEqual(w[0].category, InternalMSEEDWarning) # Test against reference data. self.assertEqual(len(data_record), 5980) last10samples = [ 2862, 2856, 2844, 2843, 2851, 2853, 2853, 2854, 2857, 2863 ] np.testing.assert_array_equal(data_record[-10:], last10samples) # Also test against independently unpacked data. np.testing.assert_allclose(data_record, data)
def test_broken_last_record(self): """ Test if Libmseed is able to read files with broken last record. Use both methods, readMSTracesViaRecords and readMSTraces """ file = os.path.join(self.path, "data", "brokenlastrecord.mseed") # independent reading of the data, 128 Bytes header d = np.fromfile(file, dtype=np.uint8)[128:] data = util._unpack_steim_2(d, 5980, swapflag=self.swap, verbose=0) # test readMSTraces. Will raise an internal warning. with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") data_record = _read_mseed(file)[0].data self.assertEqual(len(w), 1) self.assertEqual(w[0].category, InternalMSEEDReadingWarning) # Test against reference data. self.assertEqual(len(data_record), 5980) last10samples = [2862, 2856, 2844, 2843, 2851, 2853, 2853, 2854, 2857, 2863] np.testing.assert_array_equal(data_record[-10:], last10samples) # Also test against independently unpacked data. np.testing.assert_allclose(data_record, data)
def test_unpackSteim2(self): """ Test decompression of Steim2 strings. Remove 128 Bytes of header by hand, see SEEDManual_V2.4.pdf page 100. """ steim2_file = os.path.join(self.path, 'data', 'steim2.mseed') # 128 Bytes header. with open(steim2_file, 'rb') as fp: data_string = fp.read()[128:] data = util._unpack_steim_2(data_string, 5980, swapflag=self.swap, verbose=0) data_record = _read_mseed(steim2_file)[0].data np.testing.assert_array_equal(data, data_record)
def test_brokenLastRecord(self): """ Test if Libmseed is able to read files with broken last record. Use both methods, readMSTracesViaRecords and readMSTraces """ file = os.path.join(self.path, "data", "brokenlastrecord.mseed") # independent reading of the data with open(file, 'rb') as fp: data_string = fp.read()[128:] # 128 Bytes header data = util._unpack_steim_2(data_string, 5980, swapflag=self.swap, verbose=0) # test readMSTraces data_record = _read_mseed(file)[0].data np.testing.assert_array_equal(data, data_record)
def test_broken_last_record(self): """ Test if Libmseed is able to read files with broken last record. Use both methods, readMSTracesViaRecords and readMSTraces """ file = os.path.join(self.path, "data", "brokenlastrecord.mseed") # independent reading of the data with open(file, "rb") as fp: data_string = fp.read()[128:] # 128 Bytes header data = util._unpack_steim_2(data_string, 5980, swapflag=self.swap, verbose=0) # test readMSTraces. Will raise an internal warning. with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") data_record = _read_mseed(file)[0].data self.assertEqual(len(w), 1) self.assertEqual(w[0].category, InternalMSEEDReadingWarning) np.testing.assert_array_equal(data, data_record)
def test_broken_last_record(self): """ Test if Libmseed is able to read files with broken last record. Use both methods, readMSTracesViaRecords and readMSTraces """ file = os.path.join(self.path, "data", "brokenlastrecord.mseed") # independent reading of the data with open(file, 'rb') as fp: data_string = fp.read()[128:] # 128 Bytes header data = util._unpack_steim_2(data_string, 5980, swapflag=self.swap, verbose=0) # test readMSTraces. Will raise an internal warning. with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") data_record = _read_mseed(file)[0].data self.assertEqual(len(w), 1) self.assertEqual(w[0].category, InternalMSEEDReadingWarning) np.testing.assert_array_equal(data, data_record)