apopt.comCBE 493R Data-Driven Athletics

Course / Tutorials / Week 6 / Q-40

Quick tutorial Q-40 · Week 2 and 6 and 7 · about 20 min · Core

Export a run from the running simulator and read it

Run a two-stage treadmill test in the running simulator, export the CSV, and read the heart-rate time constant, the lactate trend and a critical-speed forecast from it, each checked against values the model knows.

  1. 1Gather (used)
  2. 2Statistics
  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-6 A first-order response: heart rate after a step.

The decision

A runner wants to know whether a pace can be held, and for how long if it cannot. A simulated step test answers both, and because the simulator also logs what it knows, you can see how close each method gets.

The raw data

Try it

A treadmill you can run in a browser

The running simulator puts a modeled runner on a treadmill. You set the belt speed; the model answers with heart rate, blood lactate, oxygen uptake, core temperature, fuel and an anaerobic reserve, once a second. Its Export CSV button writes every logged second to a file. This page reads one such file.

The file comes from the simulator's scenario 2 · A speed step by hand: a minute standing, then the belt steps to 9.4 km/h, and at 15 minutes it steps to 11.2 km/h and stays there until the runner drifts off the back of the belt. The runner is the simulator's recreational male preset. Every number is simulated. That is the point of the exercise: the file holds both what a sensor would read (hr_meas_bpm, with noise) and what the model knows and no real test can give you (hr_bpm, the true value, and wp_J, the anaerobic reserve). You can check each method against the truth.

To make the file yourself: open the simulator, choose that scenario, press Run (the fastest speed is fine), wait for the runner to go off the back, and press Export CSV.

PythonOpen the export and keep the columns you need

Type a prediction to enable Run.

Show the expected result without running
1470 rows, 124 columns; time column 'Time (min)'
        t_s  speed_kmh  hr_bpm  lac_mmol  hr_true  reserve_J
min     0.0        0.0    59.6       0.9     60.0      206.4
max  1468.2       11.2   178.1       6.1    177.4    59137.5
the run ended at 1468 s after 3.93 km

A one-second log of 24.5 minutes is 1,470 rows. The export has 124 columns: the settings (param_…), the controllers (ctrl_…), scores (metric_…) and the signals. Reading the header for the time unit matters: a run under a minute is written in seconds and a run over an hour in hours, so a fixed * 60 would be wrong for someone else's file.

Look before you fit

PythonBelt speed, heart rate and lactate on one time axis

Show the expected result without running
heart rate at 14.9 min 156 bpm, at 24 min 177 bpm
Three stacked panels against minutes, 0 to 25. Top, belt speed steps from 0 to 9.4 km/h at 1 minute and to 11.2 km/h at 15 minutes. Middle, heart rate climbs from 60 to about 156 beats per minute and levels off, then climbs again to about 177. Bottom, lactate rises to about 3 mmol/L and levels off in the first stage, then climbs without leveling to about 6.1 in the second.

Both curves bend toward a level in the first stage. In the second, heart rate nearly levels off but lactate keeps climbing. Heart rate alone would not tell you the second stage was too fast.

How fast does heart rate answer?

Q-6 fitted a first-order response. The belt takes a few seconds to reach speed and the heart lags behind the legs, so this fit adds a dead time θ (theta), a delay before the curve starts.

PythonFit a first-order response with a dead time to the first stage

Type a prediction to enable Run.

Show the expected result without running
hr_bpm  gain 92.9 bpm, tau 67.6 +/- 0.3 s, dead time 30.6 s
hr_true gain 92.4 bpm, tau 67.6 +/- 0.3 s, dead time 24.7 s
strap: within 5% of the new level 3.9 min after the belt starts

The noisy strap and the true value give the same time constant, 68 s, to within its standard error: one-second noise of about 1 bpm averages out over 840 points. The dead time does not agree: 31 s for the strap and 25 s for the true value. The simulated strap smooths its readings with a 6 s filter, as a real one smooths its beat-to-beat values, and smoothing delays a signal. In the chart above the gray dots run just to the right of the black line on the climb. Three time constants after the delay, heart rate is within 5% of its new level: about four minutes after the belt starts, so a heart rate read in the first three minutes of a stage is too low.

Steady or not, and how long is left?

A stage is below the threshold if lactate levels off. Measure that as the slope over the last five minutes of each stage. Then use the critical-speed model of Section 6.5: t_lim = D′ / (v − CS). The export carries both numbers: speed_sus_mps is the model's critical speed and param_dprime_m its D′.

PythonLactate slope in each stage, and the critical-speed forecast

Type a prediction to enable Run.

Show the expected result without running
10-15 min at 9.4 km/h: lactate +0.07 mmol/L per min
19-24 min at 11.2 km/h: lactate +0.24 mmol/L per min
CS 10.03 km/h, D' 190 m, belt 11.16 km/h
forecast: off the back at 25.1 min; the simulator says 24.5 min

The first stage gains 0.07 mmol/L a minute, close to level; the second gains 0.24, more than three times as fast. The critical-speed forecast says 25.1 minutes and the runner actually went off at 24.5, 38 s early. The miss has a cause you can find in the file: the model's critical speed is not fixed. Plot speed_sus_mps and you will see it fall from 10.03 to 9.77 km/h as the runner heats up and tires, so the reserve drains a little faster than the forecast assumed.

For the athlete: "At 9.4 km/h your lactate settles near 3 mmol/L and you could hold it; at 11.2 km/h it never settles, and you have about ten minutes before you must slow down."

With your own data

Make your own export and test a prediction. In the running simulator switch the units to SI, choose scenario 2 · A speed step by hand and press Run. When the second step lands at 15 minutes, press Pause, set Belt speed to about 10.6 km/h, and write down when t_lim = D′ / (v − CS), with this page's CS and D′, says the runner will go off the back. Press Run, wait, export, and load your file here in place of the one above. Is your miss bigger or smaller than 38 s, and why?

Check yourself

  1. A runner's critical speed is 4.0 m/s and D′ is 200 m. How long can they hold 4.5 m/s?

    s

  2. Why does the critical-speed forecast say 25.1 minutes when the runner went off at 24.5?

  3. The fit to the noisy strap and the fit to the true heart rate give the same time constant. Why?

0 of 3 answered · 0 right the first time

The same method in another field

A first-order fit with a dead time is how process engineers describe a heat exchanger or a tank level after a valve moves; the same three numbers (gain, time constant, delay) tune its controller. The simulator's own scenarios tune a heart-rate controller from them. See the Dynamic Data Engineering course for the same fit on plant data.

Acknowledgements

Data made with the running simulator at apmonitor.com/apps/treadmill-runner.

References

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