Homework Help Global logo
  • Home
  • Coursework Help
  • Dissertation Help
  • Homework Help
  • My account
  • Order now
Order Now
Uncategorized

CPSC 250 Fit parsing

4 min read
Posted on 
December 2nd, 2021
Home Uncategorized CPSC 250 Fit parsing
Learning Goal: I’m working on a python exercise and need an explanation and answer to help me learn.

In this lab, we will make use of an open-source Python module https://github.com/dtcooper/python-fitparse.git

I have given you this code in the fitparse folder so you do not need to install the module.

The module is written to parse Fit files (https://developer.garmin.com/fit/overview/).

In this lab, we will be parsing files generated by the Zwift (https://www.zwift.com/) virtual reality cycling app.

Our goal is to extract data (time, speed, heart_rate, altitude, power, and cadence) and calculate accumulated distance and exertion points.

I have given you a sample script, display_fit.py that parses a fit file, and displays the relevant data.

From there, you need to organize the data, do the calculations, and then plot.

For distance, we will be numerically integrating (as in calculus class) the speed to find the distance. Use the Trapezoid rule (https://en.wikipedia.org/wiki/Trapezoidal_rule) to numerically integrate the speed (in meters per second) to find the total distance traveled. To do this, you will need to calculate the elapsed time between samples. The time_stamp data value is of type ‘datetime.datetime’, which has an overloaded minus (-) operator that will calculate the elapsed time between consecutive samples. The resulting time interval (timedelta) object has a total_seconds method that will give elapsed time in seconds. See https://docs.python.org/3/library/datetime.html for more information.

Once all data is loaded, you will want to have arrays (I suggest Numpy) of cumulative elapsed time from start, speed, distance, power, altitude, cadence, and heart_rate.

For plotting purposes, convert speed from meters per second (m/s) to kilometers per hour (km/hr) and distance to km.

To calculate our exertion score, we will use the concept of aerobic training heart rate zones.

We will use Robergs & Landwehr’s formula to calculate the maximum heart rate based on age as HRmax = 205.8 − (0.685 × age), and heart rate reserve as HRreserve = HRmax − HRrest given an individuals measured resting heart rate. See https://en.wikipedia.org/wiki/Heart_rate#Heart_rate_reserve.

Given the following values for the bottom value of ranges of

  • 20% of HRreserve for endurance,
  • 40% for tempo,
  • 58% for threshold,
  • 72% for VO2 max, and
  • 90% for anaerobic So, the tempo range covers heart rates of HRrest + 0.4*HRreserve to HRrest + 0.58*HRreserve.

These zones are based on Zwift calculations but are similar to https://www.triathlete.com/training/how-to-use-heart-rate-training-zones-for-triathlon/. We will define exertion points based on the total time spent in a given range.

Assign one point (use fractional values for partial elapsed time) for every:

  • 15 minutes in endurance
  • 6 minutes in tempo
  • 3 minutes in threshold
  • 45 seconds in VO2 max
  • 10 seconds in anaerobic

Keep track of the cumulative points at each distance/time point and the final exertion total.

For each data file, plot exertion, speed, power, altitude, cadence, and heart_rate vs. both time and distance. To plot on one plot (desired), you’ll need to scale the data to plot on a common axis from minimum to maximum. Label each with the appropriate units and times the scaling factor. For scaling factor use the max value rounded to the next highest increment of 10.
For example, if maximum cadence is 103, use a scaling factor of 110 to plot.

The fit data files are names as GENDER_AGE_RESTINGHR_EVENT, so that male_54_66_5.fit was the fifth event captured from an anonymous 54 year old male with a resting heart rate of 66.

Label each plot the name of the file file, total exertion points, and your (first.last.yy).

Afterwards, on separate plots for each variable (exertion, speed, power, altitude, cadence, and heart_rate), plot these vs. both time and distance for each fit file. Title appropriately, and label each line with the base name of the fit file.

For full credit, you should be generating these plots with labels and titles programmatically, that is you should not be manually defining each and every plot occurrence.

attachment_1
attachment_2
attachment_3

Order an Essay Now & Get These Features For Free:

Turnitin Report

Formatting

Title Page

Citation

Outline

Place an Order
Share
Tweet
Share
Tweet
Calculate the price
Pages (275 words)
$0.00
Homework Help Global
Company
  • Coursework Help
  • Law Homework Help
  • Business Paper Help
  • Thesis Writing Help
Legal
  • Dissertation Help
  • Homework Help
  • Essay Writing
  • Custom Writing
How Our Service is Used:
Homework Help Global essays are NOT intended to be forwarded as finalized work as it is only strictly meant to be used for research and study purposes. Homework Help Global does not endorse or condone any type of plagiarism.
Subscribe
No Spam
© 2023 Homework Help Global. All rights reserved.
Homework Help Global will be listed as ‘Homework Help Global’ on your bank statement.