Skip to content
Snippets Groups Projects
Commit 70dd8d3c authored by Giulio Gaio's avatar Giulio Gaio
Browse files

Clean lp correlation history from zeros

parent aa4f229f
No related branches found
No related tags found
No related merge requests found
......@@ -811,8 +811,12 @@ class DeviceObj:
# calculate the correlation, numpy indexes start from 1
self.corr[t_idx] = np.corrcoef(sensor_array,target_array)[0,1]
# low pass filter correlation
self.old_lp_filter_corr[t_idx] = self.lp_filter_corr[t_idx];
self.lp_filter_corr[t_idx] = lp_filter * np.absolute(self.corr[t_idx]) + (1 - lp_filter) * self.old_lp_filter_corr[t_idx]
# if data is 0/inf/NaN keep the previous value in order to avoid corrupting the filtered value
if (self.corr[t_idx] == 0) or np.isnan(self.corr[t_idx]) or np.isinf(self.corr[t_idx])
self.lp_filter_corr[t_idx] = self.old_lp_filter_corr[t_idx]
else
self.old_lp_filter_corr[t_idx] = self.lp_filter_corr[t_idx];
self.lp_filter_corr[t_idx] = lp_filter * np.absolute(self.corr[t_idx]) + (1 - lp_filter) * self.old_lp_filter_corr[t_idx]
# correlation calculated with the bottom half of sensor values
self.corr_low[t_idx] = np.corrcoef(sensor_array_sort[1:int(self.valid_samples/2)],target_array_sort[1:int(self.valid_samples/2)])[0,1]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment