def getdata(self, seconds, flush=True ):
"""
Flush all the Data present in MuLES buffer and,
Request and Retrieve a certain amount of Data indicated as seconds
Data returned has the shape [seconds * sampling_frequency, channels]
Argument:
seconds: used to calculate the amount of samples requested n_samples
n_samples = seconds * sampling_frequency
flush: Boolean, if True send the command Flush before getting Data,
Defaul = True
"""
if flush:
self.flushdata()
# Size of data requested
n_samples = int(round(seconds * self.params['sampling frequency']))
n_columns = len(self.params['data format'])
data_buffer = -1 * np.ones((n_samples, n_columns))
while (data_buffer[0, n_columns - 1]) < 0 : #While the first row has not been rewriten
new_data = self.getalldata()
new_samples = new_data.shape[0]
data_buffer = np.concatenate((data_buffer, new_data), axis =0)
data_buffer = np.delete(data_buffer, np.s_[0:new_samples], 0)
return data_buffer
评论列表
文章目录