Recording field and calculation

Hi,

From Coros, the value of the ‘avg_vertical_oscillation’ recording field is expressed in mm. How can I divide this value by 10 to display it in cm?

Thank you.

Best,

You could do this by extracting the value using a script instead of using the field drop down. But I have added some options to the convert drop down instead.

Choose “x/10” to divide by 10.

1 Like

It was right in front of my eyes, and I didn’t even see it. My apologies. Thank you very much. Where can I find the documentation that will help me understand how to extract the value and thus use a JavaScript code ?

It wasn’t there before, I added those in response to your post. Here is the Javascript info:

2 Likes

David,

for (let m of icu.fit.record) {
  if (m.speed?.value && m.power?.value) {
    const speedValue = m.speed.value;
    const powerValue = m.power.value;
    
    const result = speedValue / powerValue;

    data.setAt(m.timestamp.value, result);
  }
}

I reprocessed the activity to see a new stream but no graph is displayed.

Where’s my mistake?

Thanks.

{
let speed = icu.paceCurve.getSpeed;
let power = icu.streams.fixed_watts;

for (let i = 0; i < data.length; i++) {
  if (power[i] !== null && power[i] !== 0 && speed(i) !== null && isFinite(power[i]) && isFinite(speed(i))) {
    let result = speed(i) / power[i];
    console.log(result);
  }
}
}

Perhaps using this source code? Not sure if it makes sense, and then how would we plot it?

The goal is to monitor and plot the speed (meters per minute) per watt.

For that you are better off working with the streams instead of processing fit messages directly. Untick the “Processes fit file messages” box and use code like this:

{
  let speed = icu.streams.velocity_smooth
  let watts = icu.streams.fixed_watts
  // dont include Z1 because then y-axis has very high numbers and you don't see anything much
  let minWatts = (activity.icu_power_zones[0] / 100) * activity.icu_ftp
  console.log("minWatts " + minWatts)
  for (let i = 0; i < data.length; i++) {
    let w = watts[i]
    if (w <= minWatts) continue
    let mps = speed[i]
    let v = mps * 60 / w
    console.log(i + ": " + mps + " mps " + w + " w = " + v)
    data[i] = v
  }
}

I put in a filter for min power because the y-axis has very high numbers otherwise (going fast but very low power).

2 Likes

A big thank you, David. That helped me understand quite a few things.

1 Like

In Jim Vance’s book ‘Run With Power,’ it is mentioned that it is preferable to calculate the average over a 30-second window (rEI or rolling EI).

I took the liberty of modifying the code as follows:

{
  let speed = icu.streams.velocity_smooth;
  let watts = icu.streams.fixed_watts;
  // dont include Z1 because then y-axis has very high numbers and you don't see anything much
  let minWatts = (activity.icu_power_zones[0] / 100) * activity.icu_ftp;
  console.log("minWatts " + minWatts);

  let windowSize = 30; // Rolling window size in seconds
  let rollingWindow = [];
  let rollingSum = 0;

  for (let i = 0; i < data.length; i++) {
    let w = watts[i];
    if (w <= minWatts) continue;

    let mps = speed[i];
    let v = mps * 60 / w;
    console.log(i + ": " + mps + " mps " + w + " w = " + v);

    // Add the new value to the rolling window
    rollingWindow.push(v);
    rollingSum += v;

    // Remove the oldest value if the rolling window size exceeds the desired size
    if (rollingWindow.length > windowSize) {
      rollingSum -= rollingWindow.shift();
    }

    // Calculate the rolling average and update data with the average value
    let rollingAverage = rollingSum / rollingWindow.length;
    data[i] = rollingAverage;
  }
}
1 Like