Exemple #1
0
 def test_load_with_wcelemlist(self):
     global test_file
     rs = ['VDS_Veh_Dynamic_Pres',
           'SCC_DynObj_CvedId',
           'VDS_Veh_Eng_RPM',
           'SCC_DynObj_RollPitch',
           'SCC_DynObj_ColorIndex',
           'VDS_Veh_Eng_Torque',
           'SCC_DynObj_AudioVisualState',
           'SCC_DynObj_Vel',
           'SCC_DynObj_DataSize',
           'VDS_Veh_Dist',
           'VDS_Veh_Heading',
           'SCC_DynObj_HcsmType',
           'SCC_DynObj_SolId',
           'SCC_DynObj_Pos',
           'VDS_Veh_Speed',
           'SCC_DynObj_Heading',
           'SCC_DynObj_Name']
     
     daq = Daq()
     daq.read(os.path.join('data', test_file),
              elemlist=['VDS_Veh*','SCC_Dyn*']) 
         
     assert_array_equal(rs, daq.keys())
Exemple #2
0
    def test_load(self):
        global test_file
        
        daq = Daq()
        daq.read(os.path.join('data', test_file))

        old_daq = old_convert_daq.read_file(os.path.join('data', test_file))
        self.__assert_old_daq_equals_daq(old_daq, daq)
 def setUp(self):
     global test_file_large
     hdf5file = test_file_large[:-4]+'.hdf5'
     hdf5file = os.path.join('data', hdf5file)
     
     try:
        with open(hdf5file):
            pass
     except IOError:
        daq = Daq()
        daq.read(os.path.join('data', test_file_large))
        daq.write_hd5(hdf5file)
Exemple #4
0
 def setUp(self):
     global test_file_large
     hdf5file = test_file_large[:-4]+'.hdf5'
     hdf5file = os.path.join('data', hdf5file)
     
     try:
        with open(hdf5file):
            pass
     except IOError:
        daq = Daq()
        daq.read(os.path.join('data', test_file_large))
        daq.write_hd5(hdf5file)
Exemple #5
0
    def test_readwrite_no_data(self):
        global test_file
        hdf5file = os.path.join('tmp', test_file[:-4]+'_5.hdf5')
        
        daq = Daq()
        daq.read(os.path.join('data', test_file))
        daq.write_hd5(hdf5file)

        daq2 = Daq()
        daq2.read_hd5(hdf5file)

        assert_Daqs_equal(self, daq, daq2)
Exemple #6
0
    def test_load_with_elemlist(self):
        global test_file
        
        daq = Daq()
        daq.load_elemlist_fromfile('elemList2.txt')

        # something about nose makes catching the warnings not work
        with warnings.catch_warnings(record=True) as w:
            daq.read(os.path.join('data', test_file))

        old_daq = old_convert_daq.read_file(os.path.join('data', test_file), 
                                            elemfile='elemList2.txt')

        self.__assert_old_daq_equals_daq(old_daq, daq)
Exemple #7
0
    def test_readwrite_with_elemlist_f0fend(self):
        global test_file
        hdf5file = os.path.join('tmp', test_file[:-4]+'_4.hdf5')
        
        daq = Daq()
        daq.load_elemlist_fromfile('elemList2.txt')
        with warnings.catch_warnings(record=True) as w:
            daq.read(os.path.join('data', test_file)) 
                              
        daq.write_hd5(hdf5file)

        daq2 = Daq()
        daq2.read_hd5(hdf5file, fend=8000)

        self.assertEqual(daq2.frame.frame[-1], 8000)
Exemple #8
0
    def test_load_partial(self):
        """test a file that did not close properly"""

        try:
            with open(os.path.join('data', partial)):
                pass
        except:
            return
        
        daq = Daq()
        with warnings.catch_warnings(record=True) as w:
            daq.read(os.path.join('data', partial))

        self.assertEqual(len(daq.keys()), 246)
        self.assertEqual(daq['VDS_Veh_Speed'].shape, (1, 68646))
Exemple #9
0
    def test_readwrite_with_elemlist(self):
        global test_file
        hdf5file = os.path.join('tmp', test_file[:-4]+'_2.hdf5')
        
        daq = Daq()
        daq.load_elemlist_fromfile('elemList2.txt')
        with warnings.catch_warnings(record=True) as w:
            daq.read(os.path.join('data', test_file)) 
            
                              
        daq.write_hd5(hdf5file)

        daq2 = Daq()
        daq2.read_hd5(hdf5file)

        assert_Daqs_equal(self, daq, daq2)
Exemple #10
0
    def test_load(self):
        global test_file
        matfile = os.path.join('tmp', test_file[:-4]+'1.mat')
        matfile2 = os.path.join('tmp', test_file[:-4]+'2.mat')
        
        daq = Daq()
        daq.read(os.path.join('data', test_file),
                 process_dynobjs=False)
        daq.write_mat(matfile)
        del daq
        daqmat = sio.loadmat(matfile)

        old_convert_daq.convert_daq(os.path.join('data', test_file),
                                    '',matfile2)
        old_daqmat = sio.loadmat(matfile2)
        self.__assert_daqmats_equal(old_daqmat, daqmat)
Exemple #11
0
    def test_load_missing(self):
        """test a file with missing frames"""
        missing = 'Left_08_20130426164301.daq'

        try:
            with open(os.path.join('data', missing)):
                pass
        except:
            return
        
        daq = Daq()
        with warnings.catch_warnings(record=True) as w:
            daq.read(os.path.join('data', missing))

        daq.write_hd5(os.path.join('tmp', 'partial.hdf5'))
        
        daq2 = Daq()
        daq2.read_hd5(os.path.join('tmp', 'partial.hdf5'))

        assert_Daqs_equal(self, daq, daq2)        
Exemple #12
0
    def test_load_with_elemlist(self):
        global test_file
        matfile = os.path.join('tmp', test_file[:-4]+'11.mat')
        matfile2 = os.path.join('tmp', test_file[:-4]+'22.mat')
        
        daq = Daq()
        daq.load_elemlist_fromfile('elemList2.txt')

        with warnings.catch_warnings(record=True) as w:
            daq.read(os.path.join('data', test_file),
                     process_dynobjs=False)

            
        daq.write_mat(matfile)
        del daq
        daqmat = sio.loadmat(matfile)

        old_convert_daq.convert_daq(os.path.join('data', test_file),
                                    'elemList2.txt',matfile2)
        old_daqmat = sio.loadmat(matfile2)
        self.__assert_daqmats_equal(old_daqmat, daqmat)
Exemple #13
0
from undaqTools import Daq

if __name__ == '__main__':
    
    for test_file in ['./data/data reduction_20130204125617.daq',
                      './data/Alaska_0_20130301142422.daq']:
        
        hdf5file = test_file[:-4]+'.hdf5'
        
        try:
           with open(hdf5file):
               pass
        except IOError:
           daq = Daq()
           daq.read(test_file)
           daq.write_hd5(hdf5file)
Exemple #14
0
 def test_process(self):
     global test_file_large
             
     daq = Daq()
     daq.read(os.path.join('data', test_file_large))
     daq.write_hd5('./tmp/dynobj_process_test.hdf5')
        rt_fname = sys.argv[1]
        daq_fname = sys.argv[2]
    except:
        print('Expecting routetable file name '
              'and route id as command line args')
        sys.exit()

    # specify broadcast rate in Hz
    try:
        broadcast_rate = int(sys.argv[3])
    except:
        broadcast_rate = 60

    # open datafile to broadcast
    daq = Daq()
    daq.read(daq_fname)
    numframes = len(daq.frame.frame)

    # read the routetable
    rt = RouteTable()
    rt.read(rt_fname)

    # prebuild the device arrays
    vecs = {}
    for route in rt.routes.values():
        for devid in route.devices:
            device = rt.devices[devid]

            if device.id in vecs:
                continue