Intervals.icu now supports custom fields for intervals. You can enter the values manually (e.g. from a test of some kind) or compute them using JavaScript code. Click “Fields” on the activity timeline page and then “Add Field” to create a new field or search for an existing field:
Note that the fields are specific to the athlete being edited. So if you are coaching people, create fields for yourself and then use the search button to add copies to your athletes.
streams: the power, heart rate and so on traces for the activity
sportSettings: for the sport of the activity
wellness: for the day of the activity
field: the field being evaluated
The last expression in the script is the value stored for the field.
Variables are implicitly declared. Don’t use ‘let’ or ‘var’ etc… The script is invoked once for each interval using the same sandbox and this fails if it declares fields.
If you do need to declare things wrap the script in a block:
{
activity.average_stride * 2
}
The JavaScript code runs in a sandbox on the server when the activity is analysed. If anyone figures out how to escape that sandbox I want to know first!
The data model is here:
The custom interval fields are also available as columns on the activity data page. You can edit the values on the grid:
Sure. I added a new public interval field “Average Core Temp” and added that to your interval fields. You should see it in the “Fields” list. The script looks like this:
temp = streams.get("core_temperature").data
tot = 0
c = 0
for (let i = interval.start_index; i < interval.end_index; i++) {
let v = temp[i]
if (v) {
tot += v
++c
}
}
c ? tot/c : null
I also added “Max Core Temp” if that is what you are after:
temp = streams.get("core_temperature").data
max = 0
for (let i = interval.start_index; i < interval.end_index; i++) {
let v = temp[i]
if (v > max) max = v
}
max > 0 ? max : null
Hi @david
I have created Interval Field for swimming: “Interval Swim Stroke” with select list. Is it possible to map fit file for this specific stroke type ? I can find it in file at the end of each inerval:
It defines running as anything over a 60 cadence, and walking as anything over a 10 cadence. It will also ignore any data during the warmup and cooldown periods defined for your running activity.
The running time calculated is usually a little lower than the one shown by Garmin - not sure why but its usually <1m of difference.
You will be able to do that when I finally find time to complete support for mapping custom fields from records to activity traces. You will need to create a trace for it and then a custom activity/interval field to calculate the average.
Dear all,
I am trying to add an interval field which should be apparently pretty simple:
(Work above FTP/Total Work*100) > its simply the percentage of W>FTP to the Wtot for that interval.
I have found the “joules_above_ftp Integer” on the script page, but I must confess, my scripting-skills are pretty poor
Any help is much appreciated.
@david:
brief question to your “All Work >FTP” field:
it is described as “…This measure includes the below the line portion when operating at or above FTP.”
Does this mean that power AT FTP is also accounted for (i.e. FTP 250W > the script also calculates when working at 250W and not starts at 251W as the Work>FTP would do?).
And what means “…below the line portion…”? Does it also calculate 249 or 248, which is, by definition below FTP. Is there any trade-off in the script (e.g. if power is below FTP for xxx seconds > then calculate > else not).
Sorry for my simplified coding language, hope the question is clear enough.
hi again, sorry a little too late yesterday evening to think clear
Soon became clear afterwards that “All Work>FTP” calculate ALL power*t, whereas “W>FTP” use the typical Wbal calculation where W=(P-FTP)*t.
The former is obviously much higher.