apopt.comCBE 493R Data-Driven Athletics

Course / Tutorials / Week 6 / Q-17

Quick tutorial Q-17 · Week 6 · about 15 min · Foundation

Split a run into laps

Assign every one-second watch record to a lap from the lap start times, rebuild the watch's lap table with pauses removed, and pick out the fast repeats.

  1. 1Gather (used)
  2. 2Statistics (used)
  3. 3Visualize (used)
  4. 4Cleanse
  5. 5Features (used)
  6. 6Balance
  7. 7Scale
  8. 8Split
  9. 9Deploy
  1. Ask
  2. Collect (this week)
  3. Check (this week)
  4. Interpret (this week)
  5. Coach
  6. Reassess

Every cell runs in this page; the first run downloads Python (about 30 s). Nothing you load leaves your browser. Helpful first: Q-16 Open an activity file and list its fields.

The decision

A coach wants each repeat of an interval session as one row: distance, time and speed. The watch has one record a second and its own lap summaries. Can you rebuild the laps, and do they match?

The raw data

Try it

On 11 May 2026 the instructor ran a session with a set of short, fast repeats in the middle, pressing the lap button at the start and end of each. The watch saved one record a second and a summary of each lap. You will split the records into the laps yourself, check your laps against the watch's, and pick out the fast ones.

Open the records and the laps

PythonOne record a second, and the watch's laps

Type a prediction to enable Run.

Show the expected result without running
3746 records over 94 min of clock time; 22 laps
21 pauses (gaps over 1 s), adding up to 32 min

The watch was paused 21 times, for over half an hour in all: a pause between repeats is normal in a session like this. Time running is what matters for pace, so count only the one-second steps.

Put each record in its lap

A record belongs to the last lap that started at or before it. np.searchsorted finds that lap for every record at once. Then each lap's running time is the sum of its one-second steps, and its distance is the watch's distance at the next lap's start minus at its own.

PythonSplit by the lap marks and compare with the watch

Type a prediction to enable Run.

Show the expected result without running
largest difference from the watch's laps: time 6.4 s, distance 3.3 m
lap             1        2       3       4       5       6       7       8       9       10     11      12      13      14      15      16      17      18      19      20       21       22
time_s      557.00   501.00  275.00   54.00   68.00   32.00  110.00   15.00  146.00   55.00   73.0   51.00  157.00   31.00   97.00   33.00  103.00   32.00  113.00   31.00   726.00   464.00
dist_m     1606.00  1611.00  793.00  298.00  125.00  195.00  243.00   95.00  280.00  311.00  102.0  299.00  327.00  199.50  219.50  194.50  215.50  199.00  219.00  192.00  1609.00  1153.00
hr_bpm      132.00   132.00  129.00  126.00  150.00  146.00  154.00  163.00  135.00  135.00  154.0  155.00  145.00  120.00  163.00  170.00  168.00  155.00  162.00  155.00   131.00   129.00
speed_mps     2.88     3.22    2.88    5.52    1.84    6.09    2.21    6.33    1.92    5.65    1.4    5.86    2.08    6.44    2.26    5.89    2.09    6.22    1.94    6.19     2.22     2.48

The distances agree within a few metres. The times agree within a second on most laps and within about 6 seconds on the long ones: the watch counts fractions of a second around each pause that whole-second records cannot see.

The fast laps

PythonSpeed lap by lap

Show the expected result without running
9 fast laps: 95 to 311 m at 5.5 to 6.4 m/s
A step chart of speed in metres per second against running time in minutes, one step per lap. Nine short steps rise to between 5.5 and 6.4 m/s, separated by slow recovery laps near 2 m/s, between longer laps near 3 m/s at the start and 2.2 to 2.5 m/s at the end.

Nine fast laps stand out, 95 to 311 m each, separated by slow recovery jogs. A lap table is the step between a one-second record and a training question: each fast lap is now one row with a distance, a time and a speed, ready for the case study CS-7.

For the athlete: "Your nine repeats on 11 May ran at 5.5 to 6.4 metres a second; the lap button did its job, and the laps we rebuilt from your records match your watch's."

Action card

Action card
Finding
The session held nine fast repeats of 95 to 311 m at 5.5 to 6.4 m/s.
Evidence
The laps rebuilt from the records match the watch's within 3.3 m and about 6 s.
How sure
High for distance and lap boundaries; lap times carry up to a second per pause.
Action
Use the rebuilt lap table, one row per repeat, for pacing questions.
Test again
Press the lap button at the start and end of every repeat in the next session too.

With your own data

Export one of your own interval sessions (Q-16 shows how to turn a FIT file into CSV), with the lap button pressed at the start and end of each repeat, and run the same cells on it.

Check yourself

  1. Why is a lap's time the sum of its one-second steps rather than the clock time from its first to its last record?

  2. A lap of 199.5 m took 31 s. What was its speed, in m/s?

    m/s

0 of 2 answered · 0 right the first time

References

Built 2026-11-30 with Python packages numpy 2.5.5, pandas 3.1.1, matplotlib 3.11.2. In the browser the same code runs on Pyodide, so the last digit can differ.