# Q-28: Height from flight time, with one frame of error

Data-Driven Athletics tutorial · Week 10 · Chapter 10 · about 15 min · workflow steps: Cleanse, Features

Web page: https://apopt.com/course/tutorials/q28-flight-height/ · Data: https://apopt.com/data/tutorials/q28-flight-height/

## The decision

An athlete's countermovement jump went from 0.165 m last week to 0.18 m today. Before calling
it progress, find out how much one frame of timing moves the number at the frame rate you
filmed at.

## The raw data

- `raw/jump2_hand_count.csv`: a hand count of the takeoff and landing frames in the course clip `jump2_120fps.mp4`, with the stored and capture frame rates The worked example "A hand count on the course's example clip" in Chapter 1 of *Data-Driven Athletics*.

Once the feet leave the ground the body is a projectile. If it lands in the same position it
took off in, the rise and the fall each take half the flight time t, so the center of mass
rises

h = g t² / 8, with g = 9.80665 m/s² (the value the jump app uses).

The raw file is a hand count from Chapter 1: someone stepped through the course's clip
`jump2_120fps.mp4`, a jump filmed in slow motion at 120 frames per second and stored at 30,
and wrote down the frame where the shoes first cleared the grass and the frame where the first
shoe came back.

*Predict first:* The file's header says 30 frames per second, but the camera filmed at 120. How high would the jump look if you used 30?

```python
import numpy as np
import pandas as pd

G = 9.80665
def height(t): return G * t ** 2 / 8

count = pd.read_csv("raw/jump2_hand_count.csv").iloc[0]
frames = count["landing_frame"] - count["takeoff_frame"]
for label, fps in (("capture rate", count["capture_fps"]), ("stored rate", count["stored_fps"])):
    t = frames / fps
    print(f"{label} {fps} fps: {frames} frames = {t:.3f} s -> h = {height(t):.3f} m")
```

Output:

```
capture rate 120 fps: 44 frames = 0.367 s -> h = 0.165 m
stored rate 30 fps: 44 frames = 1.467 s -> h = 2.637 m
```

At the capture rate the flight is 0.367 s and the jump 0.165 m. At the stored rate the same
count gives 1.467 s and 2.637 m, an impossible jump: the jump app refuses any flight over 1.1 s or
height over 1.5 m (`jump/src/lib/metrics.ts`) and asks you to check the rate. Always divide by
the rate the camera filmed at.

### One frame either way

An event between two frames can only be placed on one of them, so a flight time is uncertain by
about one frame. Height grows with the square of time, so the height moves by more than the
time does, in percent.

```python
rows = []
t = frames / count["capture_fps"]
for fps in (30, 60, 120, 240):
    lo, hi = height(t - 1 / fps), height(t + 1 / fps)
    rows.append({"fps": fps, "frames in flight": round(t * fps, 1), "h one short (m)": round(lo, 3),
                 "h one long (m)": round(hi, 3), "span (cm)": round(100 * (hi - lo), 1),
                 "span (% of h)": round(100 * (hi - lo) / height(t), 1)})
budget = pd.DataFrame(rows)
print(f"flight {t:.3f} s, height {height(t):.3f} m")
print(budget.to_string(index=False))
print(f"hand count +/- 2 frames at 120 fps: {height(42 / 120):.3f} to {height(46 / 120):.3f} m")
```

Output:

```
flight 0.367 s, height 0.165 m
 fps  frames in flight  h one short (m)  h one long (m)  span (cm)  span (% of h)
  30              11.0            0.136           0.196        6.0           36.4
  60              22.0            0.150           0.180        3.0           18.2
 120              44.0            0.157           0.172        1.5            9.1
 240              88.0            0.161           0.169        0.7            4.5
hand count +/- 2 frames at 120 fps: 0.150 to 0.180 m
```

```python
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(6, 3.2))
ax.errorbar(budget["fps"], [height(t)] * 4,
            yerr=[height(t) - budget["h one short (m)"], budget["h one long (m)"] - height(t)],
            fmt="o", color="black", capsize=6)
ax.set_xscale("log", base=2); ax.set_xticks([30, 60, 120, 240], ["30", "60", "120", "240"])
ax.set(xlabel="capture rate (frames per second)", ylabel="height (m)")
plt.tight_layout()
```

![The height of the 0.367 s jump at 30, 60, 120 and 240 frames per second, with bars from one frame short to one frame long; the bars halve in length each time the frame rate doubles.](https://apopt.com/course/tutorials/q28-flight-height/c04-1.png)

At 120 frames per second, one frame either way spans 1.5 cm, 9.1% of this 0.165 m jump; at 30
it would span 6.0 cm, 36.4%. Each doubling of the frame rate halves the span. A short jump
suffers more than a high one, because one frame is a bigger share of a short flight (Chapter
10's 0.50 s example spans 8.2 cm at 30 frames per second). The grass adds its own error here:
two frames either way, 0.150 to 0.180 m. And Chapter 8 found that this file repeats every
sixth frame, so the 44 frames may hold only about 37 distinct ones: check that frames are
distinct before trusting any count.

**For the athlete:** this jump was 0.165 m, give or take a centimeter or two; film at the
highest frame rate your phone offers, and tell the app the rate you filmed at.

## With your own data

Film your own jump from the side at the highest frame rate your phone offers, step through it
(Q-2), write down the takeoff and landing frames in the same two-column way, and run this page
with your numbers. Use the rate the camera filmed at.

## The same method in another field

Any quantity that goes with the square of a measured time, a fall height or a distance under
constant acceleration, doubles the percent timing error. Carrying a measurement error through
a formula is the same in a lab as here.

## Acknowledgements

The hand count is Chapter 1's worked example on the course clip `jump2_120fps.mp4`.

## References

- Chapter 10 of *Data-Driven Athletics*: Height from flight time; One frame of error in a jump.

---
Text CC BY 4.0, code MIT. IRSRI Sports Research Institute.
