Python versions of Daimon's R Charts in CloudDB

406 views
Skip to first unread message

Ale Martinez

unread,
Aug 8, 2022, 12:23:27 PM8/8/22
to golden-cheetah-users
There are a couple of vary nice R charts in CloudDB I would like to include in v3.6 default config Perspectives for Triathlon and, even when they work very well as they are, it would be nice to have Python/Plotly versions for convenience since we are including embedded Python and R needs to be installed by the user, besides the issue that R charts trigger on compare pane.
If someone well versed in Python/Plotly is willing to collaborate it would be very useful, original charts are available for download from CloudDB:
Activities:
SS-SR.jpg
Trends:
TriMix.jpg
This last one could be a User chart, eventually.

Thanks in advance, Ale.

marcen

unread,
Aug 14, 2022, 8:55:22 PM8/14/22
to golden-cheetah-users
I have recreated the Tri mix diagram with the user chart.
As I am not a triathlete, it would be nice if a triathlete could test the chart to see if it works.
 I have only tried it with aktivities from the test files form /test/.. .
Tri mix pie.gchart

Ale Martinez

unread,
Aug 15, 2022, 10:10:01 AM8/15/22
to golden-cheetah-users
Thank you!

Fe

unread,
Aug 29, 2022, 11:23:14 AM8/29/22
to golden-cheetah-users
Hi,

SS-SR original

R_SS-SR.jpg

SS-SR Python :

Py_SS-SR.jpg

Packages required :
("lowess" function)

GoldenCheetah--Python--Lib--site-packages.jpg

You will need to install "statsmodels" and its dependencies.  (patsy, packaging)
I hope it works

Thanks

Py SS-SR 02.gchart

Ale Martinez

unread,
Aug 29, 2022, 5:43:30 PM8/29/22
to golden-cheetah-users
Thank you, much appreciated!

Fe

unread,
Aug 30, 2022, 3:00:51 PM8/30/22
to golden-cheetah-users
...updated marker symbol (circle 25, square 50, custom xx)
Py SS-SR 03.gchart

marcen

unread,
Sep 3, 2022, 2:36:28 PM9/3/22
to golden-cheetah-users
Here is an update of the chart
The time format is now shown as 00:05:02 and no longer as 0:5:2.
Is also available in the CloudDB.
Tri mix pie.gchart

pinaman

unread,
Sep 3, 2022, 5:22:20 PM9/3/22
to golden-cheetah-users
Hey Ale,

i just finished and uploaded Avg. Pace in HR Zones chart. I can write python / plotly Tri Mix pie chart if you want.

pinaman

unread,
Sep 3, 2022, 9:21:06 PM9/3/22
to golden-cheetah-users
So here is screenshot of Tri Mix chart, made with python and plotly. It is more or less done. I'm just working on few small details. It will show "Swim" as well. I just don't have any swim activities. But i'm planing to change some activities to "Swim", just to test it.

It can be used with Metric or Imperial system. No need to change/edit anything.
TriMix_pie_charts.png

Ale Martinez

unread,
Sep 3, 2022, 9:56:15 PM9/3/22
to golden-cheetah-users
It looks very nice, you can download sample swim files from https://github.com/GoldenCheetah/GoldenCheetah/tree/master/test/swims

pinaman

unread,
Sep 3, 2022, 10:31:37 PM9/3/22
to golden-cheetah-users
Thanks for link.

Updated version with dark background. Text for each slice is outside, because if slice is too thin, then text is not visible.
Added few Swim samples, to see how it looks like. I think that's pretty much it.

If you would like some other charts in python/plotly as well, let me know.
TriMix_pie_charts_dark.png

Fe

unread,
Sep 4, 2022, 9:49:00 AM9/4/22
to golden-cheetah-users
Hi,
Python chart
"Tri mix" pie and bar , same colors Daimon.  ( pie= False or True )
It was already done ...Py_Tri_mix_bar-.jpgPy_Tri_mix_pie-.jpg
Py_tri_mix_01.gchart

pinaman

unread,
Sep 4, 2022, 11:28:50 AM9/4/22
to golden-cheetah-users
Hey Fe,

if i set pie to True i get error

File "<string>", line 139, in <module>
File "<string>", line 139, in <listcomp>
ValueError: too many values to unpack (expected 4)

Fe

unread,
Sep 4, 2022, 1:14:29 PM9/4/22
to golden-cheetah-users
Hi pinaman, variable name not updated before export (grid_data)
variable name not updated before export (grid_data)
Py tri mix 01.gchart

Ale Martinez

unread,
Sep 4, 2022, 4:40:26 PM9/4/22
to golden-cheetah-users
Hi, thank you very much for your collaboration!

WRT the SS chart, is it possible to avoid the statsmodel dependency? I have not had time to check it in detail and I would prefer to avoid adding an additional module to the distribution unless it is really necessary or specially useful.

Fe

unread,
Sep 5, 2022, 9:14:28 AM9/5/22
to golden-cheetah-users
Hi, dependencies for statsmodels are required for "sm_lowess" or "plotly px.scatter(lowess)"
I found a lowess function written in python...
https://gist.github.com/agramfort/850437 ( license BSD (3-clause) )  
If you want to try take "Py_SS_SR_04" , in this case no other package...
Py SS-SR 04.gchart

Ale Martinez

unread,
Sep 5, 2022, 10:25:47 AM9/5/22
to golden-cheetah-users
El lunes, 5 de septiembre de 2022 a la(s) 10:14:28 UTC-3, Fe escribió:
Hi, dependencies for statsmodels are required for "sm_lowess" or "plotly px.scatter(lowess)"
I found a lowess function written in python...
https://gist.github.com/agramfort/850437 ( license BSD (3-clause) )  
If you want to try take "Py_SS_SR_04" , in this case no other package...

Perfect, that's what I was looking for, I will add both charts to default layouts to replace the R versions, than you very much for your collaboration!

mondoshiwan

unread,
Sep 9, 2022, 7:47:55 AM9/9/22
to golden-cheetah-users
the StrokerateChart is one of my favorites.
Nice to have a python version.

This will only work for my Ambit files, if i put Pool_Lenght to 25 in line 227 otherwise i will get this error:
Bildschirmfoto 2022-09-09 um 10.46.49.png
Found out that Pool_Lenght in metrics has no value - in all of my swim activities. But at the DetailChart the value is there. Don't know why.
The R-Chart still works fine.

When setting Pool_Lenght to 25 in line 227 the the Python Chart looks similar to the R-Chart, except a few white dots:
Bildschirmfoto 2022-09-09 um 10.41.53.png

Carsten

for testing here is an activity file:
2022_09_02_07_05_48.json.zip

mondoshiwan

unread,
Sep 9, 2022, 9:35:27 AM9/9/22
to golden-cheetah-users
Found out that the R-Chart is working cause all values in metrics are present.

I'm on a Mac with the latest Snapshotbuild and embedded Python, as well as an older build with python 3.6.4
On both machines the Pool_Length is missing in metrics and still 2 Datafields more (Workout_Code & VO2max_detected).
Don't know why…

Ale Martinez

unread,
Sep 9, 2022, 9:55:18 AM9/9/22
to golden-cheetah-users
El viernes, 9 de septiembre de 2022 a la(s) 10:35:27 UTC-3, mondoshiwan escribió:
Found out that the R-Chart is working cause all values in metrics are present.

I'm on a Mac with the latest Snapshotbuild and embedded Python, as well as an older build with python 3.6.4
On both machines the Pool_Length is missing in metrics and still 2 Datafields more (Workout_Code & VO2max_detected).
Don't know why…

Likely because they are not included in your Data Fields config, updated config file is https://github.com/GoldenCheetah/GoldenCheetah/blob/master/src/Resources/xml/metadata.xml 

mondoshiwan

unread,
Sep 9, 2022, 3:06:21 PM9/9/22
to golden-cheetah-users
It could have been easy, but it isn't. Datafields are included at the config file:
Bildschirmfoto 2022-09-09 um 20.46.24.png

I just tested the Gchart on a Linux Appimage and there everything is fine with the same config file.
So it must be a Mac related issue?

Ale Martinez

unread,
Sep 9, 2022, 3:21:03 PM9/9/22
to golden-cheetah-users
El viernes, 9 de septiembre de 2022 a la(s) 16:06:21 UTC-3, mondoshiwan escribió:
It could have been easy, but it isn't. Datafields are included at the config file:
Bildschirmfoto 2022-09-09 um 20.46.24.png

I just tested the Gchart on a Linux Appimage and there everything is fine with the same config file.
So it must be a Mac related issue?

I don't think so. Beware metadata.xml is global in v3.6, and located parallel to your athletes folders, older config/metadata.xml inside athlete folders are not used anymore. 

mondoshiwan

unread,
Sep 10, 2022, 4:29:41 AM9/10/22
to golden-cheetah-users

Thx Ale for pointing me to this, but it didn't help either.
Everything is there: the global metadata.xml file with all defined datafields. Even restoring the global one to its defaults and deleting the old one in the athlete directory didn't help.

The point is that on a Mac in

R
metrics<-GC.activity.metrics(compare=TRUE)

gets all metrics with values.

whereas in python
metrics=GC.activityMetrics(compare=True)

some are missing.
I'm giving up now ;-)

Fe

unread,
Sep 10, 2022, 5:52:54 AM9/10/22
to golden-cheetah-users
Hi , i replaced the 'lowess gramfort' function with an old python version of 'lowess statsmodels'. ('standard_lowess' for python embedded)
External Python users can try a faster lowess statsmodels version. ('fast_lowess' optional)

Compare execution times :
( File 2022_09_02_07_05.json )

R SS-SR :
- def : lowess  (100% R)
- package :  NO  
- time : 0.03 sec ~

Py SS-SR 03 :
- def :  lowess (Python and Cython)
- package :  statsmodels (+dependencies)
- time :  0.06 sec ~

Py SS-SR 04 :
- def : gramfort_lowess (100% python)
- package :  NO (gramfort script)
- time : 3.8 sec ~

Py SS-SR 05 :
- def : lowess  (100% python)
- package :  NO 'standard_lowess'  (statsmodels lowess - old version script)  
- time : 2.5 sec ~
Update:
lowess_function = 'standard_lowess'  
## 'standard_lowess' = standard -> no packages/python embedded
## 'fast_lowess' = optional -> install 'statsmodels' package + python external

Fe
Py SS-SR 05.gchart
Reply all
Reply to author
Forward
0 new messages