コード例 #1
0
def test_convert():
    """Test conversion from dat to kwd."""
    # Create the DAT reader with two DAT files.
    dat_reader = DatRawDataReader([PATH, PATH2],
                                  dtype=np.int16,
                                  dtype_to=np.int16,
                                  shape=(-1, NCHANNELS))

    # Create an empty KWD file.
    kwd_file = "test.kwd"
    create_kwd(kwd_file)

    # Convert from DAT to the newly created KWD file.
    convert_dat_to_kwd(dat_reader, kwd_file)

    # Now, check that the conversion worked. Read the data in DAT and KWD
    # and check the arrays are the same.
    f = tb.openFile(kwd_file, 'r')
    # Load full KWD data.
    data_kwd = np.vstack([
        f.root.recordings._f_getChild('0').data,
        f.root.recordings._f_getChild('1').data
    ])
    # Load full DAT data.
    data_dat = np.vstack(
        [chunk.data_chunk_full for chunk in dat_reader.chunks(20000)])
    # Assert the two are equal.
    assert np.array_equal(data_kwd, data_dat)
    f.close()

    os.remove(kwd_file)
コード例 #2
0
def kwd_setup():
    # Create an empty KWD file.
    create_kwd(os.path.join(DIRPATH, FILENAME_KWD))
    data = create_trace(NSAMPLES, NCHANNELS)
    add_recording_in_kwd(os.path.join(DIRPATH, FILENAME_KWD), data=data)