Exemple #1
0
 def test_read_and_write(self):
     """
     Writes, reads and compares files created via libgse2.
     """
     gse2file = os.path.join(self.path, 'loc_RNON20040609200559.z')
     with open(gse2file, 'rb') as f:
         header, data = libgse2.read(f)
     with NamedTemporaryFile() as f:
         libgse2.write(header, data, f)
         f.flush()
         with open(f.name, 'rb') as f2:
             newheader, newdata = libgse2.read(f2)
     self.assertEqual(header, newheader)
     np.testing.assert_equal(data, newdata)
Exemple #2
0
 def test_readAndWrite(self):
     """
     Writes, reads and compares files created via libgse2.
     """
     gse2file = os.path.join(self.path, 'loc_RNON20040609200559.z')
     with open(gse2file, 'rb') as f:
         header, data = libgse2.read(f)
     with NamedTemporaryFile() as f:
         libgse2.write(header, data, f)
         f.flush()
         with open(f.name, 'rb') as f2:
             newheader, newdata = libgse2.read(f2)
     self.assertEqual(header, newheader)
     np.testing.assert_equal(data, newdata)
Exemple #3
0
 def test_read_and_write(self):
     """
     Writes, reads and compares files created via libgse2.
     """
     gse2file = os.path.join(self.path, 'loc_RNON20040609200559.z')
     with open(gse2file, 'rb') as f:
         header, data = libgse2.read(f)
     with NamedTemporaryFile() as f:
         # raises "UserWarning: Bad value in GSE2 header field"
         with warnings.catch_warnings():
             warnings.simplefilter('ignore', UserWarning)
             libgse2.write(header, data, f)
         f.flush()
         with open(f.name, 'rb') as f2:
             newheader, newdata = libgse2.read(f2)
     self.assertEqual(header, newheader)
     np.testing.assert_equal(data, newdata)
Exemple #4
0
 def test_bytes_io(self):
     """
     Checks that reading and writing works via BytesIO.
     """
     gse2file = os.path.join(self.path, 'loc_RNON20040609200559.z')
     with open(gse2file, 'rb') as f:
         fin = io.BytesIO(f.read())
     header, data = libgse2.read(fin)
     # be sure something es actually read
     self.assertEqual(12000, header['npts'])
     self.assertEqual(1, data[-1])
     fout = io.BytesIO()
     libgse2.write(header, data, fout)
     fout.seek(0)
     newheader, newdata = libgse2.read(fout)
     self.assertEqual(header, newheader)
     np.testing.assert_equal(data, newdata)
Exemple #5
0
 def test_bytesIO(self):
     """
     Checks that reading and writing works via BytesIO.
     """
     gse2file = os.path.join(self.path, 'loc_RNON20040609200559.z')
     with open(gse2file, 'rb') as f:
         fin = io.BytesIO(f.read())
     header, data = libgse2.read(fin)
     # be sure something es actually read
     self.assertEqual(12000, header['npts'])
     self.assertEqual(1, data[-1])
     fout = io.BytesIO()
     libgse2.write(header, data, fout)
     fout.seek(0)
     newheader, newdata = libgse2.read(fout)
     self.assertEqual(header, newheader)
     np.testing.assert_equal(data, newdata)
Exemple #6
0
 def test_bytes_io(self):
     """
     Checks that reading and writing works via BytesIO.
     """
     gse2file = os.path.join(self.path, 'loc_RNON20040609200559.z')
     with open(gse2file, 'rb') as f:
         fin = io.BytesIO(f.read())
     header, data = libgse2.read(fin)
     # be sure something es actually read
     self.assertEqual(12000, header['npts'])
     self.assertEqual(1, data[-1])
     fout = io.BytesIO()
     # raises "UserWarning: Bad value in GSE2 header field"
     with warnings.catch_warnings():
         warnings.simplefilter('ignore', UserWarning)
         libgse2.write(header, data, fout)
     fout.seek(0)
     newheader, newdata = libgse2.read(fout)
     self.assertEqual(header, newheader)
     np.testing.assert_equal(data, newdata)