def test_swapbytes(self): tfilel = os.path.join(os.path.dirname(__file__), 'data', 'test.sac') tfileb = os.path.join(os.path.dirname(__file__), 'data', 'test.sac.swap') with NamedTemporaryFile() as tf: tempfile = tf.name tb = SacIO(tfileb) tb.swap_byte_order() tb.WriteSacBinary(tempfile) t = SacIO(tempfile) tl = SacIO(tfilel) self.assertEqual(t.GetHvalue('kevnm'), tl.GetHvalue('kevnm')) self.assertEqual(t.GetHvalue('npts'), tl.GetHvalue('npts')) self.assertEqual(t.GetHvalue('delta'), tl.GetHvalue('delta')) np.testing.assert_array_equal(t.seis, tl.seis) with NamedTemporaryFile() as tf: tempfile = tf.name tl = SacIO(tfilel) tl.swap_byte_order() tl.WriteSacBinary(tempfile) t = SacIO(tempfile) tb = SacIO(tfileb) self.assertEqual(t.GetHvalue('kevnm'), tb.GetHvalue('kevnm')) self.assertEqual(t.GetHvalue('npts'), tb.GetHvalue('npts')) self.assertEqual(t.GetHvalue('delta'), tb.GetHvalue('delta')) np.testing.assert_array_equal(t.seis, tb.seis)
def test_swapbytes(self): tfilel = os.path.join(os.path.dirname(__file__), "data", "test.sac") tfileb = os.path.join(os.path.dirname(__file__), "data", "test.sac.swap") with NamedTemporaryFile() as tf: tempfile = tf.name tb = SacIO(tfileb) tb.swap_byte_order() tb.WriteSacBinary(tempfile) tr1 = SacIO(tempfile) tl = SacIO(tfilel) np.testing.assert_array_equal(tl.seis, tr1.seis) self.assertEqual(tl.GetHvalue("kevnm"), tr1.GetHvalue("kevnm")) self.assertEqual(tl.GetHvalue("npts"), tr1.GetHvalue("npts")) self.assertEqual(tl.GetHvalueFromFile(tfilel, "kcmpnm"), tr1.GetHvalueFromFile(tempfile, "kcmpnm"))
def test_swapbytes(self): tfilel = os.path.join(os.path.dirname(__file__), 'data', 'test.sac') tfileb = os.path.join(os.path.dirname(__file__), 'data', 'test.sac.swap') tempfile = NamedTemporaryFile().name tb = SacIO(tfileb) tb.swap_byte_order() tb.WriteSacBinary(tempfile) tr1 = SacIO(tempfile) tl = SacIO(tfilel) np.testing.assert_array_equal(tl.seis, tr1.seis) self.assertEqual(tl.GetHvalue('kevnm'), tr1.GetHvalue('kevnm')) self.assertEqual(tl.GetHvalue('npts'), tr1.GetHvalue('npts')) self.assertEqual(tl.GetHvalueFromFile(tfilel, 'kcmpnm'), tr1.GetHvalueFromFile(tempfile, 'kcmpnm')) os.remove(tempfile)