Custom interval fields

yes, with hindsight it is clear and thank you for this. As an advocate for the CP-concept I haven’t considered to use all work at first sight…

Hello!

I’m playing with a custom interval field that calculates the % of power related to ftp
this is the script (that doesn’t work :smiley: )

power=interval.power_average
ftp=activity.icu_ftp

(power/ftp)*100

Somebody can help me?

thanks a lot!

Here you go:

{
  interval.average_watts * 100 / activity.icu_ftp
}
1 Like

Hi all

I like the feature to have custom fields - great!!
Unfortunately I cannot program Java.

I would like to have a field that shows the “total weekly load” divided by the “total weekly training hours”

If anybody could help me with the code - that would be fanatstic!

Cheers Andy

Andy,
if you mean a custom activity field, there is a public activity field (Load/h) you can add to your activities.

Once activated, it shows the metric on top of your activity.

image

If you would like to average, summarise etc. on a customised fitness page, you can do so on a custom chart just like that

was it this what you are after?

cheers
alfred

1 Like

Hey Alfred,

That’s exactly what I was looking for.
Tried it briefly and it seems to work only sometimes.
Some activities show only load/h=?

I try further and let you know.

Cheers
Andy

It seems that you have to „run“ the script manually for each single past activity…

Reanalyze in bulk from the Activities List View to get them all at once.

1 Like

Thanks!! It works

That’s interesting …re-analyze from the activities list works - but not the analyze within the single activity…

This is awesome. Is there a lookup table somewhere for variables (or manual for scripting)? Was able to learn a thing or two from existing scripts, but still struggling. Looking to call ‘Fitness’, ‘FTP’ and ‘Weight’.

Edit: I found the parameters and got the script up and running. It 99% there, but still have one small issue.
The parameter activity.icu_ftp returns either the indoor or outdoor FTP depending on the activity. Would prefer to always call the outdoor FTP, is there a parameter for that?

Tx. You can use icu.sportSettings.ftp (or indoor_ftp). Note that the icu_ftp on the activity is copied from the sport settings when it is first analysed (choosing ftp or indoor_ftp) so history of FTP is preserved. If you use FTP from sport settings directly you are getting the current setting, not what it was when the activity was done.

You can find docs for what you can get from the icu object for an custom activity, interval or stream here: Server side data model for scripts

Thank you, David. In that case the only option is to work with the existing script and use a moving average to filter out the jitters from the slight difference in FTPs.

Hi David,
The ‘Join Score’ script runs well on historical data but noticed an issue with it when new rides are uploaded. With a new ride an incorrect number is calculated, but when opening the script and then running it again it does produce the correct value. My first guess is that the variable activity.icu_ctl is creating the issue. Is it possible that this value is first generated for the single ride (low number), and later overridden for the full history (higher number)?
Jan

Edit: Tested a bit more. The parameter activity.icu_ctl comes back empty when a new activity is uploaded but loads correctly when re-running the script. The parameters activity.icu_ftp and activity.icu_weight do load correctly when a new activity is uploaded.

Hey @david,
I’ve written a script which finds a given number of intervals of the given duration with max average power on them. It works fine locally (who would have doubted :grin:), but it fails in the sandbox. I go through watts array (streams.get(“watts”).data) and it throws a memory leak error. I try to split event loop into separate chunks by using setTimeout, but it is not available in the sandbox : (
Could you give any advice on how to deal with that?

Unfortunately the longitudinal fitness things like CTL are computed asynchronously after activity analysis has been completed. Those calculations need icu_training_load from the activity. So first time the activity is analysed that will be empty, after that it will reflect the value last time which might change (e.g. if training load is updated).

What you can get at is the fields on icu.wellness e.g. icu.wellness.ctl. The first time the activity is analysed this will have the value before the activity was uploaded. So you could use that if the activity field is null. You can adjust it using the training load on the activity:

let ctl = activity.icu_ctl
if (ctl == null) {
  let w = Math.exp(-1 / 42.0)
  ctl = icu.wellness.ctl * w + activity.icu_training_load * (1 - w)
}

Could you please message me the script. I wouldn’t expect that to run out of memory. Tx.

1 Like

Is it possible to calculate standing time and rolling time for an interval? I use intervals to analyzing performance between checkpoints on long distance audaxes etc.

Good morning!

I would like to know if it’s possible to calculate the incline of a slope (% grade slope). For example, I want to select a piece of the graphic and measure the % grade slope.

So if I zoom in this graphic I know the altitude starts with 956m and end with 1046m. The distance starts at 5.45km and end with 6.35km.

So the % grade slope is 10% → (1046-956)/(6350-5450)*100

I don’t know if I can take this data, and how to use it in the script. Anyone can help me?

Thanks.

You don’t need a script or custom field, it’s already there.
Add Avg Gradient as a field, then select the part of interest or define it as an interval and the avg gradient will be in the metrics.

1 Like

Thank you very much… And I entered in that field but couldn’t find. :rofl:

I’m also looking forward to this. In FIT File Viewer I see it’s also in the ‘lap’ messages, but I can’t figure out how to create the custom field