def training_stress_pma_grappe_score(X, pma):
"""Compute the training stress score using the MAP.
Parameters
----------
X : array-like, shape (n_samples, )
Array containing the power intensities for a ride.
pma : float
Maximum Anaerobic Power.
Returns
-------
tss_score: float
Return the training stress score.
"""
# Check the consistency of X and pma
if len(X.shape) != 1:
raise ValueError('X should have 1 dimension. Got {}, instead'.format(
len(X.shape)))
# Compute the stress for each item of the ESIE
tss_grappe = 0.
for key_sc in TS_SCALE_GRAPPE.keys():
# Count the number of elements which corresponds to as sec
# We need to convert it to minutes
curr_stress = np.count_nonzero(
np.bitwise_and(X >= ESIE_SCALE_GRAPPE[key_sc][0] * pma,
X < ESIE_SCALE_GRAPPE[key_sc][1] * pma)) / 60
# Compute the cumulative stress
tss_grappe += curr_stress * TS_SCALE_GRAPPE[key_sc]
return tss_grappe
评论列表
文章目录