I'd like to have an array of values, a threshold and then a for loop. I'd like the for loop to look at the ith value and the ith+1 value in the array at the same time and perform an action if they are BOTH above the threshold, else assign a 0 value if they are not. The intention is to apply to a signal in order to catch the signal and not random noise spikes.
Have tried the following, where the final 7 in the array is an unwanted value:
array = [1,2,7,6,3,2,3,8,6,4,7,2,3,]
larray = array[0:len(array)-1]
rarray = array[1:len(array)]
threshold = 5
output = []
for i, j in [larray, rarray]:
if i and j > threshold:
new.append(i)
new.append(j)
else:
new.append(0)
Am expecting the output to be: output = [0,0,7,6,0,0,0,8,6,0,0,0]