Counting Accelerations in a Race (e.g., Z1/Z2 to Z5+ or 0 to 500W) — Possible? Custom Script?

Hi all,

I’m curious if there’s a way in Intervals.icu to count how often I accelerate during a road bike race.

For example:

  • Going from low zones (like Z1/Z2) to high (Z5+), or
  • Surges where I jump from near 0W up to 500W or more.

Ideally, I’d like a way to count how many times this happens in a file — either by a built-in feature or perhaps using a custom script if needed.

I’m not necessarily looking for time-in-zone, but actual events where I sharply accelerate.

Is there a way to do this today, or could it be done with a custom analysis?

Thanks a lot for any pointers!

There’s a way to search for custom intervals.

But I cannot find how to set a “power difference” as a condition (I’d like to set something like Power difference between max and min ≥ 400 watts in less than 15 seconds, for example)

Sounds interesting :slight_smile:
I do not know a solution currently.

I agree, the very pragmatic approach is to count spikes on the power curve, but it’s super inefficient :slight_smile:

The reason for asking was actually inspired by Mads Pedersen, who, after a race analysis, told he was above 1000w 100 times or something, meaning that they at least have a way to calculate it.

2 Likes

You could do that with a custom field and easily iterate through the power stream (raw power or some average stream), and count every “spike” over a certain value, if the value before was in Z1/Z2.

You said easily, haha :slight_smile: Could you please provide a bit more guidance? But I’m happy to know there is a way.

It depends on your requirements :smiley: Do you want to count every little spike? Or do you want to count high efforts with a minimum duration of some seconds.

But basically as I said, you could create a custom script. A script to begin with could be this:

{
    const MIN_SECONDS = 5;
    const power = icu.stats.calcCenteredMovingAvg(icu.streams.fixed_watts, 30);
    const z4Threshold = icu.sportSettings.power_zones[3] / 100 * icu.sportSettings.ftp;
    
    let intervalCount = 0;
    let highIntensityCount = 0;
    
    power.forEach(currentPower => {
        if (currentPower >= z4Threshold) {
            intervalCount++;
        } else {
            if (intervalCount > MIN_SECONDS) {
                highIntensityCount++;
            }
            intervalCount = 0;
        }
    });
    
    highIntensityCount;
}

It increments a counter if the 30s moving average power is above Z4 for at least 5s.

1 Like

As a newbie, if I add CHARTS->CUSTOM STREAM->ADD STREAM->SCRIPT, then I cannot click OK?

It is a custom field, no stream.
Click CUSTOM → Add Field → Fill in the script in the script tab and give this thing a name. Then you can click OK

There you find a lot of links and information:

Thank you very much. It returned a value, but how do I add this to the intervals table (e.g., FIELDS) to get it for the entire workout or at laps?

That would be an interval field and you have to create it in Fields → Add Field → and so on.
Additionally you have to look only at the interval data, not the whole activity. Therefor you have to replace the power.forEach(… - line with e.g. this:

for (let i = interval.start_index; i < interval.end_index; i++) {
    const currentPower = power[i];
1 Like

Nice way to count matches burned during the workout/ride !

Thanks