In [38]:
filename = "test_data/n6mab031109.dat"
filename_h5 = "test_data/n6mab031109.h5"
In [34]:
import numpy as np
import tables
import os
datatype = np.dtype(np.int16)
nchannels = 32
freq = 20000.
rowsize_total = os.path.getsize(filename) / (datatype.itemsize * nchannels)
duration_total = rowsize_total / float(freq)
duration = 60.
In [36]:
X = np.fromfile(filename, dtype=dtype, count=channels * int(duration * freq))
X = X.reshape((-1, channels)).T
In [48]:
f = tables.openFile(filename_h5, 'w')
atom = tables.Atom.from_dtype(X.dtype)
ds = f.createEArray(f.root, 'raw_data', atom, shape=(nchannels, 0), expectedrows=rowsize_total)
ds.append(X)
f.close()
In [49]:
f = tables.openFile(filename_h5, 'r')
ds = f.root.raw_data
In [50]:
%timeit -n 1 -r 1 x = ds[::10,:]
In [ ]:
f.close()