예제 #1
0
    def get_summary_analytics(self):
        self.trimp, self.hrss, self.wap, self.tss, self.ri, self.variability_index, self.efficiency_factor = None, None, None, None, None, None, None
        activity_length = self.df_samples['time'].max()

        # Calculate power metrics
        if 'weighttraining' in self.type.lower():
            self.tss, self.ri = self.wss_score()

        elif self.max_watts is not None and self.ftp is not None:
            self.wap = weighted_average_power(
                self.df_samples['watts'].to_numpy())
            self.ri = relative_intensity(self.wap, self.ftp)
            self.tss = stress_score(self.wap, self.ftp, activity_length)
            self.variability_index = self.wap / self.df_samples['watts'].mean()

        if self.max_heartrate is not None:
            # Calculate heartrate metrics
            athlete_lthr = .89 * self.athlete_max_hr
            self.df_samples['hrr'] = self.df_samples['heartrate'].apply(
                lambda x: (x - self.hr_lowest) /
                (self.athlete_max_hr - self.hr_lowest))
            self.trimp = (
                (1 / 60) * self.df_samples['hrr'] *
                (0.64 * np.exp(1.92 * self.df_samples['hrr']))).sum()
            athlete_hrr_lthr = (athlete_lthr - self.hr_lowest) / (
                self.athlete_max_hr - self.hr_lowest)
            self.hrss = (self.trimp /
                         (60 * athlete_hrr_lthr *
                          (0.64 * np.exp(1.92 * athlete_hrr_lthr)))) * 100
            self.df_samples = self.df_samples.drop(columns='hrr')

        if self.max_heartrate is not None and self.wap is not None:
            self.efficiency_factor = self.wap / self.df_samples[
                'heartrate'].mean()
예제 #2
0
    def test_normalized_power_xpower(self):
        stream = np.ones(30)
        moving = np.ones(30, dtype=bool)

        assert weighted_average_power(stream, moving, algorithm="xPower") == 1
예제 #3
0
    def test_wap(self):
        stream = np.ones(30)
        moving = np.ones(30, dtype=bool)

        assert weighted_average_power(stream, moving) == 1
예제 #4
0
 def compute_weighted_average_power(self):
     return core.weighted_average_power(self.power, type='WAP')
예제 #5
0
 def compute_weighted_average_power(self):
     return core.weighted_average_power(self.power, algorithm='WAP')