Issue
I'm looking to locate the position of this purple circle and similiar situations for different datasets in which there is a (mainly) horizontal lag before the sensor starts gathering data.
Any ideas?
Solution
numpy.diff gives you the difference between each consecutive item in your array. It can be very useful but you may need to add some smoothing to prevent noise from giving false positives. Here is an easy smoothing function to use:
def moving_average(x, w):
return np.convolve(x, np.ones(w), 'valid') / w
(talken from here)
I suggest you plot np.diff(data) and see what that looks like. It will be much easier to find the purple point on that graph and it might even be easier yet to find it if you do np.diff twice.
For this single case, I would do:
purple_index = np.argmax(np.diff(data) < -1)
Answered By - Steinarr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.