def read_sampled(datfile, mode="r"):
"""Loads raw binary file and associated metadata into a sampled dataset.
Args:
datfile (str): path to raw binary file to read from
mode: may be "r" or "r+"; use "r+" for modifying the data
(not recommended)
Returns:
SampledData: sampled dataset containing `datfile`'s data
"""
path = os.path.abspath(datfile)
params = read_metadata(datfile)
try:
data = np.memmap(datfile, dtype=params["dtype"], mode=mode)
except ValueError:
data = np.array([])
data = data.reshape(-1, len(params['columns']))
return SampledData(data, path, params)
评论列表
文章目录