In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import os
In [2]:
# sample parameters
d = 0.506 # diameter of sample in mm
A0 = np.pi*(d/2)**2 # original cross-sectional area of sample in mm^2
s = 'T568.xls'
len(s)
Out[2]:
In [3]:
os.listdir()
excel_list = [s for s in os.listdir() if len(s) == 8]
excel_list
Out[3]:
In [4]:
def plottt(file_name):
df = pd.read_excel(file_name)
# calculate stress and strain
F = np.array(df['FORCE'])
# calcuate stress and strain
stress = (F/A0)*0.001
Lstrain = np.array(df['CH5']) *0.01
Mstrain = np.array(df['EXT'])*0.01
del(df)
#plot the stress strain curve
fig, ax1= plt.subplots(1,1)
plt.plot(Lstrain,stress)
plt.xlabel('Strain $\epsilon$ (in/in)')
plt.ylabel('Stress $\sigma$ (ksi)')
plt.title(file_name)
# this is the inset axes over the main axes
ax2 = plt.axes([0.4, 0.2, .35, .35], facecolor='w')
plt.plot(Mstrain, stress)
plt.title('Inset of Elastic Region')
plt.show()
return
In [5]:
excel_file = excel_list[5]
plottt(excel_file)
In [7]:
for excel_file in excel_list:
try:
plottt(excel_file)
except:
pass
In [18]:
good_list = [638,569,639,672,697]
l = ['T'+ str(n) + '.xls' for n in good_list]
l
Out[18]:
In [19]:
for f in l:
try:
plottt(f)
except:
pass
In [ ]: