Skip to content

Instantly share code, notes, and snippets.

@btotr
Created December 29, 2022 21:24
Show Gist options
  • Save btotr/8934476340b1e5bef2842a67821f2500 to your computer and use it in GitHub Desktop.
Save btotr/8934476340b1e5bef2842a67821f2500 to your computer and use it in GitHub Desktop.
##
## Plotting velocità ascensionale media (VAM)
##
import pandas as pd
import plotly.express as px
import tempfile
import pathlib
def nonNegative(x):
if x < 0:
x = 0
return x
def cycling_vam(s):
diff = s.diff(30).apply(nonNegative)
VAM = round(diff*60/0.5,0)
return(VAM)
alts = pd.Series(np.asarray(GC.series(GC.SERIES_ALT)))
secs = pd.Series(np.asarray(GC.series(GC.SERIES_SECS)))
df = pd.concat([secs,VAMS],axis=1)
VAMS = cycling_vam(alts)
fig = px.line(df,
y=VAMS, x=secs,
line_shape="spline",
render_mode="svg",
title="velocità ascensionale media")
# Show in GoldenCheetah
tmp = tempfile.NamedTemporaryFile(mode="w+t", prefix="GC_", suffix=".html", delete=False)
plotly.offline.plot(fig, auto_open = False, filename=tmp.name)
GC.webpage(pathlib.Path(tmp.name).as_uri())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment