-
Notifications
You must be signed in to change notification settings - Fork 11
/
hill_data_extraction.py
27 lines (23 loc) · 1.02 KB
/
hill_data_extraction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from sport_activities_features.hill_identification import HillIdentification
from sport_activities_features.tcx_manipulation import TCXFile
from sport_activities_features.topographic_features import TopographicFeatures
# read TCX file
tcx_file = TCXFile()
activity = tcx_file.read_one_file('path_to_the_data')
# detect hills in data
Hill = HillIdentification(activity['altitudes'], 30)
Hill.identify_hills()
all_hills = Hill.return_hills()
# extract features from data
Top = TopographicFeatures(all_hills)
num_hills = Top.num_of_hills()
avg_altitude = Top.avg_altitude_of_hills(activity['altitudes'])
avg_ascent = Top.avg_ascent_of_hills(activity['altitudes'])
distance_hills = Top.distance_of_hills(activity['positions'])
hills_share = Top.share_of_hills(distance_hills, activity['total_distance'])
print('num hills: ', num_hills)
print('avg_altitude: ', avg_altitude)
print('avg_ascent: ', avg_ascent)
print('total distance: ', activity['total_distance'] / 1000)
print('distance_hills: ', distance_hills)
print('hills_share: ', hills_share)