xdataNames, xdataSeries and xdata refer to low level functions
activityXdata is a wrapper to obtain XData series by name without interpolation
activity includes all XData series interpolated
When name="" it returns XData names
When name is one of the names for the activity it returns valuenames
To dinamically obtain names/series for activityXdata and activityXdataSeries
Carry RideItem, Specification and Metrics to consider the cases when
the script is part of a UserMetric or an LTMPlot formula
Python series, activityWbal and activityXdata honor RideItem and Specification
Python activityMetrics honors ScriptContext RideItem and Metrics
Python activityMeanMax honors ScriptContext RideItem
Force recomputation of metrics just in case Python Scripts were used before
.. renaming the 3 metrics they trademarked in 2013:
TSS => BikeStress
IF => BikeIntensity
NP => IsoPower
.. this will break data filters, user formula and
R and Python charts.
.. in the next commit will add user metrics to ensure
backward compatibility.
.. what a clusterfuck the Python embedding API is. If you set PYTHONHOME
it loses PYTHONPATH. But only on a Mac. Go figure.
.. so we just set the environment to the user defined value in prefs.
.. fixup trivial issues like PATHSEP and separators in general.
.. it seems that Py_SetProgramName will drive the initialisation of the
Python interpreter to set sys.path, sys.prefix and sys.exec_prefix.
.. rather than trying to fixup these directly instead we set the program
name to the python installed binary (full path).
.. you still need python in your path, will fixup in part 2.
.. lastly, also added a 'printd' macro to embed debug info, which can
be enabled in gcconfig.pri via DEFINES += PYTHON_DEBUG=true
.. look for python in path and check version and module path, then
use this when initialising to ensure the installed modules
are used, not the local copy.
.. needs testing on Windows and need to enable the user to specify
the location of Python so users don't need to modify PATH.
.. allow the user to embed a python script into a datafilter.
.. this is primarily to enable the use of python when writing
user metrics.
.. the syntax is basically "%%python script %%" and it is
evaluated as an expresssion so the results can be assigned
to a variable or returned as a value.
.. additionally GC.result(double) has been added to the python
API to enable a return value to be set by the script.
.. since Python is really sensitive about white space its going
to be best practice to embed python scripts without honoring
any of the data filter spacing, for example:
{
value {
t <-
%%python
GC.result(100)
%%;
}
}
.. is likely to be a sensible way to use this.
.. also notice how the ; is needed after the expression. This
is because %%python ... %% is a numeric expression with the
same semantics as "1 + 2"
Similar to series but used to retrieve an XData series, like the R
activity.xdata counterpart, for example: GC.xdataseries("SWIM", "STROKES")
NB: I reserved xdata(name) to retrive a whole group of series by name
with its own sampling, not implemented in this commit.
.. mad conflict .. where scipy.stats.linregress conflicts
with a sndfile and crashes when calling sf_check_fpe
.. see fix stolen from here: https://github.com/scipy/scipy/issues/8130
A more efficient way to obtain a metric series for a large number
of activities, it can be converted to numpy array without copy:
import numpy as np
nparray = np.asarray(GC.metrics("Average_Power", True, "isRun=0 && isSwim=0")
.. instead of an opengl canvas lets start with a Web canvas.
.. we might have options to use QtCharts or OpenGL later.
.. not working - committed to save WIP.
.. With german translation activated GC.activity() complains about
some utf-8 decoding stuff and returns error.
First I thought came from the real activity json file, but it's
from translation: Altitude -> Höhenmeter.
Is it necessary to use toLatin1() in goldencheetah.sip? With
toUtf8() it works and you get delta symbols instead of question marks.
.. With R the series names are always in english and use a naming
convention derived from the R trackR package -- we now follow the
same in Python bindings to ensure charts created in one locale
will continue to work in another.