Using XDATA in charts

806 views
Skip to first unread message

Nigel Van de Velde

unread,
Nov 28, 2016, 2:30:53 PM11/28/16
to golden-cheetah-users
Hi,

I have some swim related charts, where I would like to show data for a specific stroke type. 
In my data I see there is an XDATA series called "TYPE" and consists of a number representing a certain stroke type.

Can I find somewhere how to use only those data that I want to be displayed? Is there a possibility to add it as a filter or should this be used somehow in a user formula?

Thanks for the info!

Kind regards,

Nigel  

Matthias

unread,
Nov 29, 2016, 4:28:22 AM11/29/16
to golden-cheetah-users
Hi Nigel,

you can use a custom formular in the charts like this   

XDATA("DEVELOPER""Form*Power", interpolate)

Nigel Van de Velde

unread,
Nov 29, 2016, 6:37:41 AM11/29/16
to golden-cheetah-users
Hi,

I already saw the autofill when typing in "XDATA" in a user data series. The autofill gives me the following: 

XDATA("xdata", "series", sparse|repeat|interpolate|resample).

I thought I should use the following to get all data points for a specific swim stroke:

XDATA("TYPE", "1", resample).

In this case "TYPE = 1" seems to be freestyle swimming. After this line I tried adding "&& followed by my formula" or "; followed by my formula", but nothing seems to happen. I also tried to replace "resample" by my formula, but again nothing.

Can you offer more specific help on how to use XDATA. I think one working, less general example could give a better insight.

Kind regards,

Nigel

Nigel Van de Velde

unread,
Nov 29, 2016, 7:20:07 AM11/29/16
to golden-cheetah-users
I think I found out how to use XDATA by using it in a User defined metric (and not directly as a formula in a user data series.

This is what I did to get a user metric for stroke rate at freestyle swimming:

{

# relevant data

relevant { XDATA("SWIM", "STROKES", repeat); }

relevant { XDATA("SWIM", "TYPE", repeat); }


# initialise aggregating variables

init { total_strokes <- 0; seconds <- 0; stroke_type <- 0; strokes <- 0; }


# fetch number of strokes for freestyle swimming (TYPE = 1 in XDATA)

sample {

stroke_type <- XDATA("SWIM", "TYPE", repeat);

if (stroke_type = 1){

strokes <- XDATA("SWIM", "STROKES", repeat);

total_strokes <- total_strokes + strokes;

seconds <- seconds + RECINTSECS;

}

}


# calculate metric value at end, total strokes multiplied by 2 to account for both arms

value { total_strokes*2 / seconds; }

count { seconds; }

}



Kind regards,


Nigel


Mark Liversedge

unread,
Nov 29, 2016, 8:54:46 AM11/29/16
to golden-cheetah-users
My apologies, I really need to document the user metrics.

For the developers it is obvious because they use the same approach as the internal ones, but if you are a user its all greek !

relevant - is a function that returns non-zero if this metric is relevant for the activity - and should be declared only once.

it might need power, cadence etc and will check that. The idea is that when a metric is NOT relevant it saves compute time by just skipping the rest.

Assuming an activity is relevant then the user metric is computed by calling each function:

First "init" is called to setup any totals / counters etc you might use when computing the metric.

Secondly "sample" is called repeatedly for every sample, from the first to the last. In the code you can look at a variable "INDEX" to see where you are, and can use that to reference a sample directly i.e POWER[INDEX] is the power value for the current sample, POWER[INDEX-1] for prior etc. 

During this iteration it is expected you will update some kind of aggregating values. You can also reference metrics too in this calculation as builtin metrics are also available. If you do not need to aggregate values you don't need a sample {} function.

Finally, a function called "value" is called to get the actual computed value; it may return the aggregated/computed value you updated during the sample {} function or it might just perform a computation using an existing metric; e.g. TSS/(Duration/3600) for TSS per hour (all time values are stored as seconds).

The "count" function is used when aggregating metrics to ensure the average is computed properly. Usually, count will just be the duration of the activity, so when averaging a metric from a 5hr ride with one from a 1hr ride you get the right result.

Hope this helps, but will update the wiki and record a video too.

Mark

Nigel Van de Velde

unread,
Dec 2, 2016, 6:02:09 PM12/2/16
to golden-cheetah-users
Hi,

Meanwhile I added a Swim chart to the cloud database. It has swim time, stroke rate, stroke distance and swolf for both freestyle and breaststroke shown per length. 
My swim data are recorded with a Garmin 735. Possibly other watches will have differrent XDATA series names.

I created some user defined metrics as well to use in trend charts for both freestyle and breaststroke swimming:

- Stroke Rate
- SWolf (average)
- SWolf (best value)

Maybe some of you would find them useful as well. You can find them below.








I am still working on something to detect the best pace over a certain distance for a specific swim stroke. That doesn't seem as easy though :D

Kind regards,

Nigel



Reply all
Reply to author
Forward
0 new messages