Homework 8 Python & Numerical Methods 21/22 October 25, 2021 Name the Colab notebook containing only the graded exercises: HW8 PNM21 s XXXXXXXXXXipynb (s1234567 = your s-number!) If you work in a...

1 answer below »
Inly exercise 1 is needed. Thank you!


Homework 8 Python & Numerical Methods 21/22 October 25, 2021 Name the Colab notebook containing only the graded exercises: HW8 PNM21 s1234567.ipynb (s1234567 = your s-number!) If you work in a group, add all student numbers at the end of the file name. Share the notebook with [email protected] Save and pin revision before sharing Do not open or alter the file before you received feedback Share as editor if you’d like to get feedback Deadline is Monday November 1, 11.00h Grading: You must hand in all exercises for maximum points. Each of these exercises is worth 4 points if your code runs correctly. The remaining 6 points per question are earned by writing concise, elegant and efficient code. Note: points can still be earned by reflecting on why the code does not run or work as expected. The grading will occur using the rubric that can be found on Nestor. Hint: If the output of your program is a line of printed text with a result of a computation included, you can use f-strings to display a variable in a string. Exercise 1 You are a data analyst working for the Dutch junior athletics team. Your job is to analyze and visualize the movement of one of the athletes participating in the 100 m sprint. During a training session, the athlete wears three devices that measure their position: one on the right hand, one on the right foot, and one on the chest. You can find the data recorded by these devices in the 100 m sprint data.csv file on Nestor. Unfortunately though, something went wrong during the data transfer from the devices: the information was transferred at an irregular interval, so be sure to take this into account. As there is no time to redo the measurements, your supervisor asks you to do the following analysis with the data set. Figure 1: Example output of the full data set. • Create a plot that shows the position as a function of time for all three body parts. Do the same for the velocity and acceleration. You can, of course, find these quantities by numerical differentiation, and you may not use NumPy’s gradient function for this. Be sure to include legends, axes labels, and titles in your graphs. The output should look similar to Figure 1. • What is the average velocity of the runner while running the 100 m? • Determine the time at which the chest velocity was largest, and the time at which the chest acceleration was largest. Print both with times, along with their corresponding velocity and acceleration respectively, in a formatted string. Repeat this process for the foot and hand. • Since the positions of the arms and legs depend on the position of the chest, it would be interesting to study the movement of the hand and foot relative to the chest. Create the same plots as you did in the first question, but with position, velocity, and acceleration relative to the chest. Hint: You can see that the output is correct if the chest position, velocity and acceleration are 0 everywhere. The output should look similar to Figure 2. • What can you say about the movement of the arms and legs based on the velocity plot with respect to the chest? Figure 2: Example output of the full data set with respect to the chest. Exercise 2 Now that you have done some initial analysis of the data, it is time to move on to some primitive modelling of the runner. You can still complete most of this exercise if you did not get an answer for the first exercise. • Use scipy.optimize.curve fit() to fit sine waves to the relative velocities of the hand and foot with respect to the chest. Plot the data and the fitted functions in the same figure to show the fits are good. Again create legends, axes labels and titles. Hint: Define the sine function you want to fit such that all parameters that influence the wave can be adjusted, i.e. amplitude, period, and vertical and horizontal offset. The output should look similar to Figure 3, or Figure 4, or Figure 5 in the best case scenario. • Compute the distance covered by the hand with respect to the chest over the entire duration of the run. Do this by numerically integrating the function you just got from fitting – without using a built-in integration function(!). If you did not manage to fit a function in the first part of this question, you may integrate any kind of sine wave that you want over the given x-interval. Figure 3: Example output of fitting the relative velocity of the hand and foot with respect to the chest. Figure 4: Example output of fitting the relative velocity of the hand and foot with respect to the chest. Figure 5: (Best) example output of fitting the relative velocity of the hand and foot with respect to the chest. Time (s),Chest position (m),Hand position (m),Foot position (m) 0.0,0.0,0.0,0.0 0.58,3.598,3.53,3.936 0.9,6.339,6.513,6.334 1.65,12.578,12.827,12.482 1.88,14.49,14.755,14.366 2.69,21.425,21.472,21.593 2.97,23.934,23.885,24.229 3.55,28.764,28.579,29.274 3.95,32.151,32.535,31.869 4.36,35.675,35.527,36.097 4.9,40.286,40.207,40.604 5.47,45.458,45.747,45.305 6.0,50.272,50.582,50.096 6.54,54.959,54.841,55.338 6.9,58.222,58.525,58.033 7.61,64.299,64.619,64.094 7.85,66.456,66.287,66.927 8.56,72.43,72.253,72.885 8.92,75.504,75.887,75.232 9.63,81.823,82.191,81.571 10.17,86.456,86.407,86.763 10.64,90.347,90.326,90.617 10.95,93.023,93.123,93.123 11.41,96.994,96.853,97.392 12.19,100.0,100.0,100.0 12.52,100.0,100.0,100.0 13.02,100.0,100.0,100.0 13.36,100.0,100.0,100.0 13.91,100.0,100.0,100.0 14.6,100.0,100.0,100.0
Answered 1 days AfterOct 29, 2021

Answer To: Homework 8 Python & Numerical Methods 21/22 October 25, 2021 Name the Colab notebook containing only...

Sathishkumar answered on Oct 30 2021
128 Votes
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 30 19:37:43 2021
@author: -
"""
import numpy as np
import pan
das as pd
import statistics
data=pd.read_csv(filepath_or_buffer = "100meter.csv")
#print(data)
import matplotlib.pyplot as plt
x=data.loc[:,"Time (s)"]
y1=data.loc[:,"Chest position (m)"]
y2=data.loc[:,"Hand position (m)"]
y3=data.loc[:,"Foot position (m)"]
#print(x)
plt.plot(x,y1)
plt.plot(x,y2)
plt.plot(x,y3)
plt.title("Distance versus Time")
plt.xlabel("t(s)")
plt.ylabel("x(m)")
plt.legend(["Chest","Hand","Foot"])
plt.show()
m=len(x)
nt=[]
cv=[]
ch=[]
cf=[]
ac=[]
ah=[]
af=[]
for i in range(m):
if (i==0 or i==(m-1)):
nt.append(0)
cv.append(0)
ch.append(0)
cf.append(0)

else:
j=i-1
tt=(x[i]-x[j])
vc=(y1[i]-y1[j])/tt
vh=(y2[i]-y2[j])/tt
vf=(y3[i]-y3[j])/tt
cv.append(vc)
ch.append(vh)
cf.append(vf)

for i in range(m):
if (i==0 or i==(m-1)):

ac.append(0)
ah.append(0)
af.append(0)
else:
j=i-1
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here