示例#1
0
    def test_typeInteger(self):
        #confirm value types are integers (int, numpy.int32, numpy.int16)
        filename = self._createtempfile('dataValueTypeInt')
        hdr = bluefile.readheader(filename, dict)
        self._typeInteger(hdr['ext_header']['mykeyword'])

        # write back to disk, unmodified
        bluefile.writeheader(filename, hdr)
        hdr2 = bluefile.readheader(filename, dict)

        # read in same file and check keyword
        self._typeInteger(hdr2['ext_header']['mykeyword'])

        #cast the integer to 'int'
        hdr['ext_header']['mykeyword'] = int(hdr['ext_header']['mykeyword'])
        bluefile.writeheader(filename, hdr)
        hdr = bluefile.readheader(filename, dict)
        self._typeInteger(hdr['ext_header']['mykeyword'])
示例#2
0
    def test_typeConsistency(self):
        filename = self._createtempfile('dataTypeConsistency')
        hdr = bluefile.readheader(filename, dict)

        # write back to disk, unmodified
        bluefile.writeheader(filename, hdr)
        hdr2 = bluefile.readheader(filename, dict)

        # read in same file and check keyword
        self.assertEqual(type(hdr['ext_header']['mykeyword']), \
                         type(hdr2['ext_header']['mykeyword']), \
                         msg="\nKeyword data type is not packed and unpacked consistently")

        #cast the integer to int()
        hdr['ext_header']['mykeyword'] = int(hdr['ext_header']['mykeyword'])
        bluefile.writeheader(filename, hdr)
        hdr = bluefile.readheader(filename, dict)
        self.assertEqual(type(hdr['ext_header']['mykeyword']), \
                         type(hdr2['ext_header']['mykeyword']), \
                         msg="\nKeyword is not packed and unpacked consistently")
    def test_FileSinkTimecode(self):
        filename = self._tempfileName('source_timecode')

        # Create a source with a known start time
        time_in = time.time()
        source = sb.DataSource(dataFormat='float', startTime=time_in)
        sink = sb.FileSink(filename, midasFile=True)
        source.connect(sink)
        sb.start()

        # The data isn't important, other than to cause a pushPacket with the
        # initial timestamp
        source.push(range(16), EOS=True)
        sink.waitForEOS()

        # Read back the timecode from the output file
        hdr = bluefile.readheader(filename)
        time_out = bluefile_helpers.j1950_to_unix(hdr['timecode'])
        self.assertAlmostEqual(time_in, time_out, 5)