Esempio n. 1
0
 def test_bug_write_read_float32_seed_win32(self):
     """
     Test case for issue #64.
     """
     # create stream object
     data = np.array([
         395.07809448, 395.0782, 1060.28112793, -1157.37487793,
         -1236.56237793, 355.07028198, -1181.42175293
     ],
                     dtype=np.float32)
     st = Stream([Trace(data=data)])
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         _write_mseed(st, tempfile, format="MSEED")
         # read temp file directly without libmseed
         with open(tempfile, 'rb') as fp:
             fp.seek(56)
             dtype = np.dtype(native_str('>f4'))
             bin_data = from_buffer(fp.read(7 * dtype.itemsize),
                                    dtype=dtype)
         np.testing.assert_array_equal(data, bin_data)
         # read via ObsPy
         st2 = _read_mseed(tempfile)
     # test results
     np.testing.assert_array_equal(data, st2[0].data)
Esempio n. 2
0
    def test_write_with_date_time_before_1970(self):
        """
        Write an stream via libmseed with a datetime before 1970.

        This test depends on the platform specific localtime()/gmtime()
        function.
        """
        # create trace
        tr = Trace(data=np.empty(1000))
        tr.stats.starttime = UTCDateTime("1969-01-01T00:00:00")
        # write file
        with NamedTemporaryFile() as tf:
            tempfile = tf.name
            _write_mseed(Stream([tr]), tempfile, format="MSEED")
            # read again
            stream = _read_mseed(tempfile)
            stream.verify()
Esempio n. 3
0
 def test_one_sample_overlap(self):
     """
     Both methods readMSTraces and readMSTracesViaRecords should recognize a
     single sample overlap.
     """
     # create a stream with one sample overlapping
     trace1 = Trace(data=np.zeros(1000))
     trace2 = Trace(data=np.zeros(10))
     trace2.stats.starttime = UTCDateTime(999)
     st = Stream([trace1, trace2])
     # write into MSEED
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         _write_mseed(st, tempfile, format="MSEED")
         # read it again
         new_stream = _read_mseed(tempfile)
         self.assertEqual(len(new_stream), 2)
Esempio n. 4
0
    def test_write_with_date_time_before_1970(self):
        """
        Write an stream via libmseed with a datetime before 1970.

        This test depends on the platform specific localtime()/gmtime()
        function.
        """
        # create trace
        tr = Trace(data=np.empty(1000))
        tr.stats.starttime = UTCDateTime("1969-01-01T00:00:00")
        # write file
        with NamedTemporaryFile() as tf:
            tempfile = tf.name
            _write_mseed(Stream([tr]), tempfile, format="MSEED")
            # read again
            stream = _read_mseed(tempfile)
            stream.verify()
Esempio n. 5
0
 def test_one_sample_overlap(self):
     """
     Both methods readMSTraces and readMSTracesViaRecords should recognize a
     single sample overlap.
     """
     # create a stream with one sample overlapping
     trace1 = Trace(data=np.zeros(1000))
     trace2 = Trace(data=np.zeros(10))
     trace2.stats.starttime = UTCDateTime(999)
     st = Stream([trace1, trace2])
     # write into MSEED
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         _write_mseed(st, tempfile, format="MSEED")
         # read it again
         new_stream = _read_mseed(tempfile)
         self.assertEqual(len(new_stream), 2)
Esempio n. 6
0
 def test_bug_write_read_float32_seed_win32(self):
     """
     Test case for issue #64.
     """
     # create stream object
     data = np.array([395.07809448, 395.0782, 1060.28112793, -1157.37487793,
                      -1236.56237793, 355.07028198, -1181.42175293],
                     dtype=np.float32)
     st = Stream([Trace(data=data)])
     with NamedTemporaryFile() as tf:
         tempfile = tf.name
         _write_mseed(st, tempfile, format="MSEED")
         # read temp file directly without libmseed
         with open(tempfile, 'rb') as fp:
             fp.seek(56)
             dtype = np.dtype(native_str('>f4'))
             bin_data = from_buffer(fp.read(7 * dtype.itemsize),
                                    dtype=dtype)
         np.testing.assert_array_equal(data, bin_data)
         # read via ObsPy
         st2 = _read_mseed(tempfile)
     # test results
     np.testing.assert_array_equal(data, st2[0].data)