-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
Description
Is this something that could be calculated and shown in a column for running activities with heart rate data?
I have a small python script that can calculate it given a FIT file, would be nice if it could be integrated into ActivityLog2 though.
from fitparse import FitFile
def compute_frac_trimp(seconds, hr, minhr, maxhr, gender):
minutes = seconds / 60.0
hrr = (float(hr) - minhr)/(maxhr - minhr)
ret = minutes * hrr * 0.64 * math.pow(2.71828, gender * hrr)
return ret
def compute_trimp(file_name, minhr, maxhr, gender):
ret = 0
hr = None
ts = None
old_ts = None
fitfile = FitFile(file_name)
for record in fitfile.get_messages('lap'):
sport = record.get_value('sport')
if sport != SPORT:
return 0
for record in fitfile.get_messages('record'):
for record_data in record:
if record_data.name == 'heart_rate':
hr = record_data.value
elif record_data.name == 'timestamp':
old_ts = ts
ts = time.mktime(datetime.datetime.strptime(str(record_data.value), "%Y-%m-%d %H:%M:%S").timetuple())
if old_ts and hr:
trimp = compute_frac_trimp(ts - old_ts, hr, minhr, maxhr, gender)
ret += trimp
return ret