def write_sampled(datfile, data, sampling_rate, **params):
"""Writes a sampled dataset to disk as a raw binary file, plus a meta file.
Args:
datfile (str): path to file to write to. If the file exists, it is
overwritten.
data (sequence): time series data of at most 2 dimensions
sampling_rate (int or float): sampling rate of `data`
**params: all other keyword arguments are treated as dataset attributes,
and added to the meta file
Returns:
SampledData: sampled dataset containing `data`
"""
if 'columns' not in params:
params['columns'] = sampled_columns(data)
params["dtype"] = data.dtype.str
shape = data.shape
mdata = np.memmap(datfile, dtype=params["dtype"], mode="w+", shape=shape)
mdata[:] = data[:]
write_metadata(datfile, sampling_rate=sampling_rate, **params)
params['sampling_rate'] = sampling_rate
return SampledData(mdata, datfile, params)
评论列表
文章目录