Skip to content
Snippets Groups Projects
Commit 1e72b001 authored by Camilla Compton's avatar Camilla Compton
Browse files

change logic in refine.py to be less repetitive, uses a ind_list for all

parent c67cef5c
No related branches found
No related tags found
1 merge request!98Draft: WIP Positive/negative standard deviation refinement
......@@ -94,20 +94,15 @@ def refine_calculate(event, params, window, refined_gps=None, threshold=None):
else:
inds_above = np.where(buf.data > upper_threshold)[0]
inds_below = np.where(buf.data < lower_threshold)[0]
if inds_above.any() or inds_below.any():
if inds_above.any() and inds_below.any():
ind_list = [[np.min(inds_above), upper_threshold],
[np.min(inds_below), lower_threshold]]
ind_list.sort()
ind = ind_list[0][0]
threshold = ind_list[0][1]
elif inds_above.any() and not inds_below.any():
ind = np.min(inds_above)
threshold = upper_threshold
elif not inds_above.any() and inds_below.any():
ind = np.min(inds_below)
threshold = lower_threshold
ind_list = []
if inds_above.any():
ind_list.append([np.min(inds_above), upper_threshold])
if inds_below.any():
ind_list.append([np.min(inds_below), lower_threshold])
if ind_list.any():
ind_list.sort()
ind = ind_list[0][0]
threshold = ind_list[0][1]
refined_gps = buf.tarray[ind]
logging.info("threshold: {}".format(threshold))
logging.info("refined time: {}".format(refined_gps))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment