~cypheon/trakka

1e99856fbe117c98f7f5d872de6cede145c00534 — Johann Rudloff 2 years ago 2f4e175
Only perform HR zone analysis if HR data is available
1 files changed, 4 insertions(+), 6 deletions(-)

M activities/activity.py
M activities/activity.py => activities/activity.py +4 -6
@@ 195,10 195,14 @@ def analyse(track: Track, athlete_data: Mapping[str, float], raw: bool = False):
    for i in range(raw_hr.shape[0]):
        hr[i][0] = (raw_hr[i][0] - start_date).item().total_seconds()

    hr_zones = None
    if hr.shape[0] > 1:
        avg_hr = time_series_average(hr[:, 0], hr[:, 1])
        max_hr = np.max(hr[:, 1])
        min_hr = np.min(hr[:, 1])

        potential_max_hr = opt_max(max_hr, athlete_data.get('max_hr'))
        hr_zones = analyse_hr_zones(hr, potential_max_hr)
    elif hr.shape[0] == 1:
        avg_hr = hr[0][1]
        max_hr = hr[0][1]


@@ 208,12 212,6 @@ def analyse(track: Track, athlete_data: Mapping[str, float], raw: bool = False):
        max_hr = None
        min_hr = None

    real_max_hr = opt_max(max_hr, athlete_data.get('max_hr'))
    if real_max_hr is not None:
        hr_zones = analyse_hr_zones(hr, real_max_hr)
    else:
        hr_zones = None

    # elapsed_seconds = (pos[-1][0] - pos[0][0]).item().total_seconds()
    elapsed_seconds = dist[-1][0]