Skip to content

Commit

Permalink
Merge pull request #196 from MihaMi27/main
Browse files Browse the repository at this point in the history
Add cadence and watts to integral metrics (TCXFile)
  • Loading branch information
firefly-cpp authored Nov 26, 2024
2 parents 3c2e2e9 + b007fe2 commit 78084bf
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion sport_activities_features/tcx_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ def extract_integral_metrics(self, filename: str) -> dict:
'altitude_min': altitude_min,
'ascent': ascent,
'descent': descent,
'steps' : steps
'steps' : steps,
'cadence_avg': cadence_avg,
'cadence_max': cadence_max,
'watts_avg': watts_avg,
'watts_max': watts_max
}.
"""
tcx = TCXReader().read(filename)
Expand Down Expand Up @@ -210,6 +214,27 @@ def extract_integral_metrics(self, filename: str) -> dict:
steps = tcx.lx_ext['Steps']
except BaseException:
steps = None

try:
cadence_avg = tcx.cadence_avg
except BaseException:
cadence_avg = None

try:
cadence_max = tcx.cadence_max
except BaseException:
cadence_max = None

try:
watts_avg = tcx.tpx_ext_stats['Watts']['avg']
except BaseException:
watts_avg = None

try:
watts_max = tcx.tpx_ext_stats['Watts']['max']
except BaseException:
watts_max = None


int_metrics = {
'activity_type': activity_type,
Expand All @@ -225,6 +250,10 @@ def extract_integral_metrics(self, filename: str) -> dict:
'ascent': ascent,
'descent': descent,
'steps': steps,
'cadence_avg': cadence_avg,
'cadence_max': cadence_max,
'watts_avg': watts_avg,
'watts_max': watts_max,
}
return int_metrics

Expand Down

0 comments on commit 78084bf

Please sign in to comment.