def get_race_paces(races): paces={} recovery_km = convert_to_time('01:15') recovery_mile = convert_to_time('02:00') plus2 = convert_to_time('00:02') for vdot, race_times in races.items(): paces[vdot] = {} for race, times in race_times.items(): if vdot == 30: print(race, convert_to_time(times), distances[race][0], distances[race][1]) paces[vdot][race + '-KM'] = time_hhmm(calculate_pace(convert_to_time(times), distances[race][0], 'km')) paces[vdot][race + '-Mile'] = time_hhmm(calculate_pace(convert_to_time(times), distances[race][1], 'mile')) if race == 'HalfMarathon': paces[vdot]['Recovery-KM'] = time_hhmm(calculate_pace(convert_to_time(times) , distances[race][0], 'km') + recovery_km) paces[vdot]['Recovery-Mile'] = time_hhmm(calculate_pace(convert_to_time(times) , distances[race][1], 'mile') + recovery_mile) if race == '15K': paces[vdot]['10Mile-Mile'] = time_hhmm( calculate_pace(convert_to_time(times), distances[race][1], 'mile') + plus2) paces[vdot]['10Mile-KM'] = time_hhmm(calculate_pace(calculate_pace( convert_to_time(times), distances[race][1], 'mile') + plus2, 1, 'mile', 'km')) return paces
def get_repetition_time(repetition, pace): """Gets the interval pace based on the longest distance.""" if repetition['Repetition800'] != '-': return time_hhmm(calculate_pace(convert_to_time(repetition['Repetition800']), 800, 'metre', pace)) elif repetition['Repetition600'] != '-': return time_hhmm(calculate_pace(convert_to_time(repetition['Repetition600']), 600, 'metre', pace)) elif repetition['Repetition400'] != '-': return time_hhmm(calculate_pace(convert_to_time(repetition['Repetition400']), 400, 'metre', pace)) elif repetition['Repetition300'] != '-': return time_hhmm(calculate_pace(convert_to_time(repetition['Repetition300']), 300, 'metre', pace)) else: return time_hhmm(calculate_pace(convert_to_time(repetition['Repetition200']), 200, 'metre', pace))
def get_interval_time(intervals, pace): """Gets the interval pace based on the longest distance.""" if intervals['IntervalM'] != '-': return intervals['IntervalM'] if pace == 'mile' \ else time_hhmm(calculate_pace(convert_to_time(intervals['IntervalM']), 1, 'mile', pace)) elif intervals['Interval1200'] != '-': return time_hhmm(calculate_pace(convert_to_time(intervals['Interval1200']), 1200, 'metre', pace)) elif intervals['IntervalKM'] != '-': return intervals['IntervalKM'] if pace == 'km' \ else time_hhmm(calculate_pace(convert_to_time(intervals['IntervalKM']), 1, 'km', pace)) else: return time_hhmm(calculate_pace(convert_to_time(intervals['Interval400']), 400, 'metre', pace))
def calculate_vdot(self, distance, time): """Calculates the vdot for a person based on the finish time of the distance.""" time_seconds = convert_to_time(time).total_seconds() vdot, max_time, min_time = self.db.vdot_range(distance, time_seconds) vdot_distance_diff = max_time - min_time finish_distance_diff = min_time - time_seconds if vdot_distance_diff == 0: self.vdot_score = int(vdot) else: self.vdot_score = int(vdot) + dec(finish_distance_diff / vdot_distance_diff, 2, 'ROUND_FLOOR') self._calculate_paces()
def format_duration(self, duration): """Formats the duration of workout.""" if type(duration) == list: # List is for distance based duration_type = 'distance' duration_value = dec(duration[0], 2) duration_unit = duration[1] if duration_unit != 'metre' and duration_unit != self.units: duration_value = convert_distance(duration_value, duration_unit, self.units) elif duration: duration_type = 'time' duration_value = convert_to_time(duration).total_seconds() duration_unit = None else: duration_type = 'none' duration_value = None duration_unit = None return duration_type, duration_value, duration_unit
from settings.converters import dec, convert_distance, convert_to_date, convert_to_time from settings.settings import Settings import os import datetime settings = Settings() threshold_time = convert_to_time('00:18:00') threshold_pace = convert_to_time('00:07:00') rest_time = convert_to_time('00:08:00') rest_pace = convert_to_time('00:09:00') rest_distance = dec(rest_time.total_seconds() / rest_pace.total_seconds(), 2) distance = dec(threshold_time.total_seconds() / threshold_pace.total_seconds(), 2) print(distance) print(rest_distance) intervals = (1500 * 3) + (1200 * 3) #+ (800) metres = convert_distance(intervals, 'metre', 'mile') miles = dec('1.5', 1) miles += dec('1.5', 1) print(distance + miles + rest_distance) settings.WORKOUT_PLANS = 'template\\plans\\' settings.WORKOUT_TEMPLATES = 'template\\workout templates.json'