|
|
|
@ -41,7 +41,7 @@ class JumpModel(Model):
|
|
|
|
|
segment_from_index, segment_to_index, segment_data = parse_segment(segment, dataframe) |
|
|
|
|
percent_of_nans = segment_data.isnull().sum() / len(segment_data) |
|
|
|
|
if percent_of_nans > 0 or len(segment_data) == 0: |
|
|
|
|
continue |
|
|
|
|
continue |
|
|
|
|
confidence = utils.find_confidence(segment_data) |
|
|
|
|
confidences.append(confidence) |
|
|
|
|
segment_cent_index, jump_height, jump_length = utils.find_jump_parameters(segment_data, segment_from_index) |
|
|
|
@ -51,10 +51,10 @@ class JumpModel(Model):
|
|
|
|
|
labeled_jump = utils.get_interval(data, segment_cent_index, self.state['WINDOW_SIZE']) |
|
|
|
|
labeled_jump = utils.subtract_min_without_nan(labeled_jump) |
|
|
|
|
patterns_list.append(labeled_jump) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.model_jump = utils.get_av_model(patterns_list) |
|
|
|
|
convolve_list = utils.get_convolve(self.ijumps, self.model_jump, data, self.state['WINDOW_SIZE']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
del_conv_list = [] |
|
|
|
|
for segment in segments: |
|
|
|
|
if segment['deleted']: |
|
|
|
@ -65,7 +65,7 @@ class JumpModel(Model):
|
|
|
|
|
deleted_jump = utils.get_interval(data, segment_cent_index, self.state['WINDOW_SIZE']) |
|
|
|
|
deleted_jump = utils.subtract_min_without_nan(labeled_jump) |
|
|
|
|
del_conv_jump = scipy.signal.fftconvolve(deleted_jump, self.model_jump) |
|
|
|
|
del_conv_list.append(max(del_conv_jump)) |
|
|
|
|
del_conv_list.append(max(del_conv_jump)) |
|
|
|
|
|
|
|
|
|
if len(confidences) > 0: |
|
|
|
|
self.state['confidence'] = float(min(confidences)) |
|
|
|
@ -76,7 +76,7 @@ class JumpModel(Model):
|
|
|
|
|
self.state['convolve_max'] = float(max(convolve_list)) |
|
|
|
|
else: |
|
|
|
|
self.state['convolve_max'] = self.state['WINDOW_SIZE'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(convolve_list) > 0: |
|
|
|
|
self.state['convolve_min'] = float(min(convolve_list)) |
|
|
|
|
else: |
|
|
|
@ -91,12 +91,12 @@ class JumpModel(Model):
|
|
|
|
|
self.state['JUMP_LENGTH'] = int(max(jump_length_list)) |
|
|
|
|
else: |
|
|
|
|
self.state['JUMP_LENGTH'] = 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(del_conv_list) > 0: |
|
|
|
|
self.state['conv_del_min'] = float(min(del_conv_list)) |
|
|
|
|
else: |
|
|
|
|
self.state['conv_del_min'] = self.state['WINDOW_SIZE'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(del_conv_list) > 0: |
|
|
|
|
self.state['conv_del_max'] = float(max(del_conv_list)) |
|
|
|
|
else: |
|
|
|
@ -113,7 +113,7 @@ class JumpModel(Model):
|
|
|
|
|
variance_error = self.state['WINDOW_SIZE'] |
|
|
|
|
close_patterns = utils.close_filtering(segments, variance_error) |
|
|
|
|
segments = utils.best_pat(close_patterns, data, 'max') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(segments) == 0 or len(self.ijumps) == 0 : |
|
|
|
|
segments = [] |
|
|
|
|
return segments |
|
|
|
|