Python chart with compare intervals

398 views
Skip to first unread message

marcen

unread,
Mar 31, 2023, 5:44:35 PM3/31/23
to golden-cheetah-users
Hi,

Maybe someone can give me a tip on how I can compare intervals of different activities in a python script.

I tried to get the date and start time via GC.activityMetrics(compare=True), which also works. Then I can get the intervals with GC.activityIntervals(type="", activity=Date and start time).
With "selected" I can filter the intervals that are selected in the side bar. Since the selection in the Side Bar is not the same as in the Compare Pane. I am looking for another way to get the start and end times of the interval stored in the Compare Pane.

It would be great if someone had a tip on how to do this.

Ale Martinez

unread,
Mar 31, 2023, 7:02:34 PM3/31/23
to golden-cheetah-users
El viernes, 31 de marzo de 2023 a la(s) 18:44:35 UTC-3, marcen escribió:
Hi,

Maybe someone can give me a tip on how I can compare intervals of different activities in a python script.

I tried to get the date and start time via GC.activityMetrics(compare=True), which also works.

I think what you are looking for would be GC.activity(compare=True), which is available in R but not Python API, likely I overlooked it when "translated" R to Python API.

A possible workaround would be to use Elapsed_Time and Elapsed_Time+Duration from GC.activityMetrics(compare=True) to get interval start and stop time, but I have not tested this.

BTW, your power profile radar chart is very nice!

marcen

unread,
Apr 1, 2023, 3:05:16 PM4/1/23
to golden-cheetah-users
Many thanks for the tips.

Unfortunately, GC.activity(compare=True) only works with R.
For example, when I test print(GC.activity(compare=True)) in Python, I get the following error message: TypeError: __GCactivity() got an unexpected keyword argument 'compare'.

Elapsed_Time only shows the value in the sidebar view, in the compare pane the value is zero and GC.activityMetrics(compare=True) also returns a value of zero.

Thanks a lot. It was fun to create the Power Profile Radar Chart.

Ale Martinez

unread,
Apr 1, 2023, 5:33:57 PM4/1/23
to golden-cheetah-users
El sábado, 1 de abril de 2023 a la(s) 16:05:16 UTC-3, marcen escribió:
Many thanks for the tips.

Unfortunately, GC.activity(compare=True) only works with R.
For example, when I test print(GC.activity(compare=True)) in Python, I get the following error message: TypeError: __GCactivity() got an unexpected keyword argument 'compare'.

It is currently unsupported, I will take a look to try to understand how much work is to add it. 

marcen

unread,
Apr 1, 2023, 6:43:29 PM4/1/23
to golden-cheetah-users
Thank you for the help and your work on GC.

Ale Martinez

unread,
Apr 3, 2023, 9:49:59 AM4/3/23
to golden-cheetah-users

Ale Martinez

unread,
Apr 10, 2023, 10:56:57 PM4/10/23
to golden-cheetah-users
I created a PR to retrieve sample data for compare items: https://github.com/GoldenCheetah/GoldenCheetah/pull/4349

Basically all activity series and xdata related functions include an optional compre parameter working as an index on the compare list, for example:
GC.activity(compare=0)
Will return the sample data and xdata for the first compare item (activity or interval) if compare mode is enabled, otherwise the current activity data. And so on for compare=1, etc. matching GC.activityMetrics(compare=True) array.

A windows installer can be downloaded from https://ci.appveyor.com/project/Joern-R/goldencheetah-knhd8/builds/46747461, or the PR can be included using command line instructions in the PR for personal builds.

Ale Martinez

unread,
Apr 11, 2023, 10:49:44 AM4/11/23
to golden-cheetah-users
Perhaps compareindex, or just index, will be a better name to avoid confusion with compare (boolean) in other APIs. 

marcen

unread,
Apr 11, 2023, 11:05:25 AM4/11/23
to golden-cheetah-users
Great, thank you very much.
First tests looked good. Will test a small chart tonight.
I would prefer compareindex. As you also know what the index refers to.

Ale Martinez

unread,
Apr 11, 2023, 1:54:49 PM4/11/23
to golden-cheetah-users
New version using compareindex parameter is available from https://ci.appveyor.com/project/Joern-R/goldencheetah-knhd8/builds/46755451/artifacts

marcen

unread,
Apr 11, 2023, 4:21:44 PM4/11/23
to golden-cheetah-users
With the attached chart I could compare the activities and all kinds of intervals.
Works great, thank you.
Watt over Duration.gchart

Ale Martinez

unread,
Apr 11, 2023, 5:08:53 PM4/11/23
to golden-cheetah-users
Perfect, thank you, I added the example to tests/charts and merged, will update the wiki and generate new snapshots next weekend.

marcen

unread,
Apr 16, 2023, 3:27:00 PM4/16/23
to golden-cheetah-users
In CloudDB, the CP over under - compare chart is available. This allows activities or intervals to be compared with the new parameter compareindex .

Only compatible with version V3.6-DEV dated 15.04.2023 or later!

To use the chart, Python must be enabled in Golden Cheetah. See wiki for more: https://github.com/GoldenCheetah/GoldenCheetah/wiki/UG_Preferences_General

Fe

unread,
May 26, 2023, 4:39:50 AM5/26/23
to golden-cheetah-users
Hi Ale,
I tried 'compareindex' ... there is a problem with the gears :
'compareindex' and 'start-stop' intervals do not seem the same. (image1, script1 to check)

image1
image1.jpg

--------------------------------------------------------------------------------------------------------------------------------------------------------

I should complete a chart for the gears. (image2 ... sample)

image2
image2.jpg

-------------------------------------------------

Thanks a lot if you can check.
script1.gchart
Message has been deleted
Message has been deleted

marcen

unread,
May 26, 2023, 1:35:17 PM5/26/23
to golden-cheetah-users

I think with data that does not have the same length, the data cannot be interpolated when compareindex is used.
I have attached a file with xdata gears.

The code below shows nan with compare pane enabled.

Code:

metricsAll = GC.activity(join="repeat", compareindex=0) xdataGears = GC.xdata('GEARS', 'REAR', join="repeat", compareindex=0) print("From activity: ", list(metricsAll['GEARS_REAR'])) print("From xdata: ", list(xdataGears))
xdataGears.fit

marcen

unread,
May 26, 2023, 2:04:26 PM5/26/23
to golden-cheetah-users
Nan is only timed when the interval is between two data points.

Using the attached file in the previous post, create an interval with a from 12 minutes to 13 minutes and then compare them, then nan will be timed.
Screenshot 2023-05-26 200246.png

Fe

unread,
May 27, 2023, 7:03:29 AM5/27/23
to golden-cheetah-users
The gears are already interpolated, length is the same.  (GEARS_FRONT , GEARS_REAR)
Lap1' and 'Entire Activity' are always aligned, the other intervals are not.

Entire Activity (activity xxx example) :
image3.jpg

image4.jpg
Reply all
Reply to author
Forward
0 new messages