Custom interval fields

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

Is there any way to access the custom (or standard) interval fields in the custom charts on the fitness page? I have some specific use cases for tracking training blocks which I would love it be able to do but requires access to the interval fields.

Not directly. But you can create a custom activity field that stores data computed from the interval fields (standard and custom) and use that on the /fitness page. Not sure if that will work for your use-case.

1 Like

Yes, that sounds like it would work…now just to figure out how to do that :slight_smile:

Essentially, I want to be able to capture this information from work intervals, into activity fields so that I can chart them on the /fitness page…

Is that possible?

Yes sort of. You would need to add a custom activity field for each and compute it from the intervals yourself. This will work best if there is only one activity for the sport on each day. I suggest testing with just one field before doing all the work.

1 Like

That is great thanks @david - I need to do some digging on how to create the script to do as such then…starting from zero :slight_smile:

If anyone has any examples of creating an activity field by computing it from an interval they could share to get me start that would be fantastic.