diff --git a/src/stats/index.ts b/src/stats/index.ts index 2e8c0fa..1570606 100644 --- a/src/stats/index.ts +++ b/src/stats/index.ts @@ -2,7 +2,6 @@ import { Workout } from "../ast"; import { averageIntensity } from "./averageIntensity"; import { normalizedIntensity } from "./normalizedIntensity"; import { totalDuration } from "./totalDuration"; -import { tss } from "./tss"; import { tss2 } from "./tss2"; import { zoneDistribution } from "./zoneDistribution"; @@ -19,8 +18,7 @@ Total duration: ${(duration.seconds / 60).toFixed()} minutes Average intensity: ${(avgIntensity.value * 100).toFixed()}% Normalized intensity: ${(normIntensity.value * 100).toFixed()}% -TSS #1: ${tss(intervals).toFixed()} -TSS #2: ${tss2(duration, normIntensity).toFixed()} +TSS: ${tss2(duration, normIntensity).toFixed()} Zone Distribution: ${zones.map(({ name, duration }) => `${(duration.seconds / 60).toFixed().padStart(3)} min - ${name}`).join("\n")} diff --git a/src/stats/tss.ts b/src/stats/tss.ts deleted file mode 100644 index 2c95478..0000000 --- a/src/stats/tss.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Interval } from "../ast"; -import { Duration } from "../Duration"; - -// Training Stress Score formula from Training and Racing with a Power Meter: -// -// TSS = (s * W * IF) / (FTP * 3600) * 100 -// -// s - duration in seconds -// W - power in watts -// IF - intensity factor (power / FTP) - -const steadyTss = (duration: Duration, intensity: number): number => { - return ((duration.seconds * intensity * intensity) / 3600) * 100; -}; - -const rangeTss = (duration: Duration, from: number, to: number): number => { - let score = 0; - const step = new Duration(1); - for (let i = 0; i < duration.seconds; i += step.seconds) { - const intensity = from + (to - from) * (i / duration.seconds); - score += steadyTss(step, intensity); - } - return score; -}; - -const intervalTss = ({ duration, intensity }: Interval): number => { - if (intensity.start === intensity.end) { - return steadyTss(duration, intensity.value); - } else { - return rangeTss(duration, intensity.start, intensity.end); - } -}; - -export const tss = (intervals: Interval[]): number => { - return intervals.map(intervalTss).reduce((a, b) => a + b, 0); -}; diff --git a/test/__snapshots__/cli.test.ts.snap b/test/__snapshots__/cli.test.ts.snap index 1819f81..9596e3b 100644 --- a/test/__snapshots__/cli.test.ts.snap +++ b/test/__snapshots__/cli.test.ts.snap @@ -245,8 +245,7 @@ Total duration: 24 minutes Average intensity: 60% Normalized intensity: 74% -TSS #1: 17 -TSS #2: 22 +TSS: 22 Zone Distribution: 15 min - Z1: Recovery @@ -265,8 +264,7 @@ Total duration: 43 minutes Average intensity: 79% Normalized intensity: 84% -TSS #1: 48 -TSS #2: 51 +TSS: 51 Zone Distribution: 10 min - Z1: Recovery @@ -285,8 +283,7 @@ Total duration: 45 minutes Average intensity: 36% Normalized intensity: 71% -TSS #1: 21 -TSS #2: 37 +TSS: 37 Zone Distribution: 35 min - Z1: Recovery @@ -305,8 +302,7 @@ Total duration: 62 minutes Average intensity: 74% Normalized intensity: 81% -TSS #1: 62 -TSS #2: 68 +TSS: 68 Zone Distribution: 22 min - Z1: Recovery @@ -325,8 +321,7 @@ Total duration: 79 minutes Average intensity: 69% Normalized intensity: 78% -TSS #1: 69 -TSS #2: 81 +TSS: 81 Zone Distribution: 42 min - Z1: Recovery