
Ask HN: Calculating Acceleration range from json data in Python - uber1geek
I am writing a script where i have some geojson data from a gps receiver of a bike with speed, timestamp and latlong. I have so far sorted the data using natsort, which gives the output in reverse order with the relevant timestamps.<p>Basically what i want to do here is trim a video (max 60 - 90 seconds) based on when the rider accelerates. So i need to get the range of timestamps which i can pass onto another script for processing of the video. Is there any formula out there for calculating acceleration which is relevant to my problem ? How can i get the range?<p>https:&#x2F;&#x2F;github.com&#x2F;uber1geek&#x2F;Python-GPS-Data-Analysis
======
bigiain
How simplistic an answer do you need? (apologies if this way underestimates
where your question is coming from...)

Acceleration is change in speed[1] over time. Delta V over delta T. How many
meters per second did you change your speed by every second?

So for a first approximation: Take three consecutive datapoints (a, b, and c).
Calculate the distance and time between point a and b (from their lat/longs
and timestamps). Divide the distance by the time to get average speed between
a and b. Now do the same for points b and c. Now you can subtract one from the
other to get "change in speed", and you can approximate the corresponding
"change in time" several ways depending on the nature of your data (if you've
got reliable one-point-per-second datapoints, just use 1 second as your
"change in time". if your gps data isn't that consistent, I'd first try
averaging the two time intervals a-b and b-c and using that.)

Now just keep doing that iteratively for every point and the two points
following it to get a stream of acceleration datapoints and their relative
timestamps. Turning this into Python is left as an exercise for the reader :-)

 _Edit_ : I just re-read the full question after posting this - if you've got
reliable speeds for each timestamped datapoint, ignore the first half of that,
all you need to to is calculate "the speed at time b minus speed at time a
divided by time difference between time a and b" , then assign that as the
acceleration for time b (for simplicity, or for some new average time halfway
between time a and b to bet closer to "the truth"). That'll probably get you
"close enough".

Note that if you're getting typical GPS data "noise", you'll probably want to
track a moving average of the calculated accelerations. The multi rotor
controller guys seem to mostly use "kalman filters" to clean up and make sense
out of real world noisy sensor data... For your use case of algorithmicly
generating timestamps in video, you quite likely wont need to get their level
of precision. Try the easy way first...

[1] I'll handwave away the technicalities of the difference between speed and
velocity for at least the first approximation solution here...

~~~
uber1geek
Super, I really appreciate your time and effort in explaining this in a very
detailed manner. I have an insight on what to do next however turning it into
python code is going to be a big challenge as i move forward to it.

------
mjhea0
clickable > [https://github.com/uber1geek/Python-GPS-Data-
Analysis](https://github.com/uber1geek/Python-GPS-Data-Analysis)

~~~
uber1geek
Thanks :)

