<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Lab 7 Data
Step1:  Constants
Step2:  Part 2
Step3:  Now lets get to the math.
Dynamic loading is described by the following equation.
$$ \omega_n = (\lambda L)^2 \sqrt{\frac{k}{3(M + 4.167m)}} $$
Rearranging to solve for k..
$$ k = \frac{\omega_n}{(\lambda L)^4}*(3(M+4.167m)) $$
<ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
Explanation: Lab 7 Data
End of explanation
width = 3.18  # cm
thickness = 0.46  # cm
length = 48  # cm
volume = length*width*thickness  # cm^3
density = 2.77  # g/cm
massBar = density*volume
print('mass of bar =', massBar, 'g')
gammaL = 1.88  # from lab procedures (for first harmonic)
Explanation: Constants
End of explanation
dirPath = os.path.realpath('.')
fileName = 'rawData/lab7data.xlsx'
filePath = os.path.join(dirPath, fileName)
df = pd.read_excel(filePath,sheetname="Part2",header=0)
print(df)
cols = df.columns
Explanation: Part 2: Dynamic Loading
First, lets start by importing the data from part 2
End of explanation
angularFreq = 2*np.pi*df['Frequency (Hz)']
k =  angularFreq**2/(gammaL)**4 * 3*(massBar/1000+4.167*df['Weight']/1000)
print('k average =', np.average(k), 'N/m')
print('k max =', np.max(k), 'N/m')
print('k min =', np.min(k), 'N/m')
print('k std =', np.std(k), 'N/m')
plt.figure(1)
plt.errorbar(df['Weight'], df['Frequency (Hz)'], yerr=2*df['error'], fmt='o')
plt.xlabel('Weight (g)')
plt.ylabel('Frequency (Hz)')
plt.title('Part 2: Dynamic Loading')
plt.grid()
plt.show()
Explanation: Now lets get to the math.
Dynamic loading is described by the following equation.
$$ \omega_n = (\lambda L)^2 \sqrt{\frac{k}{3(M + 4.167m)}} $$
Rearranging to solve for k..
$$ k = \frac{\omega_n}{(\lambda L)^4}*(3(M+4.167m)) $$
End of explanation
<END_TASK>