|
|
@ -20,11 +20,13 @@ class PeakModel(Model): |
|
|
|
'pattern_center': [], |
|
|
|
'pattern_center': [], |
|
|
|
'pattern_model': [], |
|
|
|
'pattern_model': [], |
|
|
|
'confidence': 1.5, |
|
|
|
'confidence': 1.5, |
|
|
|
'convolve_max': 570000, |
|
|
|
'convolve_max': 0, |
|
|
|
'convolve_min': 530000, |
|
|
|
'convolve_min': 0, |
|
|
|
'WINDOW_SIZE': 0, |
|
|
|
'WINDOW_SIZE': 0, |
|
|
|
'conv_del_min': 54000, |
|
|
|
'conv_del_min': 0, |
|
|
|
'conv_del_max': 55000, |
|
|
|
'conv_del_max': 0, |
|
|
|
|
|
|
|
'height_max': 0, |
|
|
|
|
|
|
|
'height_min': 0, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def get_model_type(self) -> (str, bool): |
|
|
|
def get_model_type(self) -> (str, bool): |
|
|
@ -46,6 +48,7 @@ class PeakModel(Model): |
|
|
|
self.state['pattern_model'] = utils.get_av_model(learning_info['patterns_list']) |
|
|
|
self.state['pattern_model'] = utils.get_av_model(learning_info['patterns_list']) |
|
|
|
convolve_list = utils.get_convolve(self.state['pattern_center'], self.state['pattern_model'], data, window_size) |
|
|
|
convolve_list = utils.get_convolve(self.state['pattern_center'], self.state['pattern_model'], data, window_size) |
|
|
|
correlation_list = utils.get_correlation(self.state['pattern_center'], self.state['pattern_model'], data, window_size) |
|
|
|
correlation_list = utils.get_correlation(self.state['pattern_center'], self.state['pattern_model'], data, window_size) |
|
|
|
|
|
|
|
height_list = learning_info['patterns_value'] |
|
|
|
|
|
|
|
|
|
|
|
del_conv_list = [] |
|
|
|
del_conv_list = [] |
|
|
|
delete_pattern_width = [] |
|
|
|
delete_pattern_width = [] |
|
|
@ -61,7 +64,7 @@ class PeakModel(Model): |
|
|
|
delete_pattern_height.append(utils.find_confidence(deleted)[1]) |
|
|
|
delete_pattern_height.append(utils.find_confidence(deleted)[1]) |
|
|
|
delete_pattern_width.append(utils.find_width(deleted, True)) |
|
|
|
delete_pattern_width.append(utils.find_width(deleted, True)) |
|
|
|
|
|
|
|
|
|
|
|
self._update_fiting_result(self.state, learning_info['confidence'], convolve_list, del_conv_list) |
|
|
|
self._update_fiting_result(self.state, learning_info['confidence'], convolve_list, del_conv_list, height_list) |
|
|
|
|
|
|
|
|
|
|
|
def do_detect(self, dataframe: pd.DataFrame): |
|
|
|
def do_detect(self, dataframe: pd.DataFrame): |
|
|
|
data = utils.cut_dataframe(dataframe) |
|
|
|
data = utils.cut_dataframe(dataframe) |
|
|
@ -86,9 +89,15 @@ class PeakModel(Model): |
|
|
|
close_patterns = utils.close_filtering(segments, variance_error) |
|
|
|
close_patterns = utils.close_filtering(segments, variance_error) |
|
|
|
segments = utils.best_pattern(close_patterns, data, 'max') |
|
|
|
segments = utils.best_pattern(close_patterns, data, 'max') |
|
|
|
|
|
|
|
|
|
|
|
if len(segments) == 0 or len(self.state.get('pattern_center', [])) == 0: |
|
|
|
if len(segments) == 0 or len(self.state.get('pattern_model', [])) == 0: |
|
|
|
return [] |
|
|
|
return [] |
|
|
|
pattern_data = self.state['pattern_model'] |
|
|
|
pattern_data = self.state['pattern_model'] |
|
|
|
|
|
|
|
up_height = self.state['height_max'] * (1 + self.HEIGHT_ERROR) |
|
|
|
|
|
|
|
low_height = self.state['height_min'] * (1 - self.HEIGHT_ERROR) |
|
|
|
|
|
|
|
up_conv = self.state['convolve_max'] * (1 + 1.5 * self.CONV_ERROR) |
|
|
|
|
|
|
|
low_conv = self.state['convolve_min'] * (1 - self.CONV_ERROR) |
|
|
|
|
|
|
|
up_del_conv = self.state['conv_del_max'] * (1 + self.DEL_CONV_ERROR) |
|
|
|
|
|
|
|
low_del_conv = self.state['conv_del_min'] * (1 - self.DEL_CONV_ERROR) |
|
|
|
for segment in segments: |
|
|
|
for segment in segments: |
|
|
|
if segment > self.state['WINDOW_SIZE']: |
|
|
|
if segment > self.state['WINDOW_SIZE']: |
|
|
|
convol_data = utils.get_interval(data, segment, self.state['WINDOW_SIZE']) |
|
|
|
convol_data = utils.get_interval(data, segment, self.state['WINDOW_SIZE']) |
|
|
@ -102,9 +111,14 @@ class PeakModel(Model): |
|
|
|
convol_data = utils.nan_to_zero(convol_data, nan_list) |
|
|
|
convol_data = utils.nan_to_zero(convol_data, nan_list) |
|
|
|
pattern_data = utils.nan_to_zero(pattern_data, nan_list) |
|
|
|
pattern_data = utils.nan_to_zero(pattern_data, nan_list) |
|
|
|
conv = scipy.signal.fftconvolve(convol_data, pattern_data) |
|
|
|
conv = scipy.signal.fftconvolve(convol_data, pattern_data) |
|
|
|
if max(conv) > self.state['convolve_max'] * 1.2 or max(conv) < self.state['convolve_min'] * 0.9: |
|
|
|
pattern_height = convol_data.values[self.state['WINDOW_SIZE']] |
|
|
|
|
|
|
|
if pattern_height > up_height or pattern_height < low_height: |
|
|
|
delete_list.append(segment) |
|
|
|
delete_list.append(segment) |
|
|
|
elif max(conv) < self.state['conv_del_max'] * 1.02 and max(conv) > self.state['conv_del_min'] * 0.98: |
|
|
|
continue |
|
|
|
|
|
|
|
if max(conv) > up_conv or max(conv) < low_conv: |
|
|
|
|
|
|
|
delete_list.append(segment) |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
if max(conv) < up_del_conv and max(conv) > low_del_conv: |
|
|
|
delete_list.append(segment) |
|
|
|
delete_list.append(segment) |
|
|
|
else: |
|
|
|
else: |
|
|
|
delete_list.append(segment) |
|
|
|
delete_list.append(segment) |
|
|
|