Commit c408a08b authored by Nathan Coppin's avatar Nathan Coppin
Browse files

adding plot.py

parent b73b598c
......@@ -5,27 +5,32 @@ import shutil
import random
import csv
import matplotlib.pyplot as plt
filename = "fric/1output005r=6e-3mu=3171/Drag.csv"
filename = "../../../../../media/coppinn/Maxtor/Hopper/hopper04/2/Drag.csv"
filename = "../../../Latex/ArticleContacts/Drag/noRelaxStressDrag64/2/Drag.csv"
with open(filename) as file1:
reader = csv.reader(file1,delimiter = ";",quoting=csv.QUOTE_NONNUMERIC)
data = [r for r in reader]
data = np.array(data);
react = data[:,1]
prod = np.zeros_like(react)
ranges = 25
startMean=6000
ranges = 500
startMean=7000
endMean = 20000
endMean2 = 4500
print(react)
for i in range(len(react)):
if i <ranges:
prod[i] = np.sum(react[0:i+ranges])/(i+ranges)
elif len(react)-i<ranges:
prod[i] = np.sum(react[i-ranges:])/((len (react)-i)+ranges)
else:
prod[i] = np.sum(react[i-ranges:i+ranges])/(2*ranges)
print("Mean :",np.mean(prod[startMean:]),"\nVelocity :",np.mean(data[startMean:, 4])*1000, "mm/s")
mean = np.ones_like(prod[startMean:])*np.mean(prod[startMean:])
plt.plot(data[:, 3],-prod,color='black')
plt.plot(data[startMean:, 3],-mean,color = 'red')
prod[i] = np.sum(react[i-ranges:i])/(ranges)
#print("Mean :",np.mean(prod[startMean:]),"\nVelocity :",np.mean(data[startMean:, 4])*1000, "mm/s")
mean = np.ones_like(react[startMean:endMean])*np.mean(react[startMean:endMean])
plt.plot(data[:, 3],-prod,color='black',linewidth=2)
plt.plot(data[:, 3],-react,'.',color='black',alpha=0.03,markersize=2.5)
plt.plot(data[startMean:endMean, 3],-mean,color = 'darkorange',linewidth=2.5)
mean2 = np.ones_like(react[:endMean2])*np.mean(react[:endMean2])
plt.plot(data[:endMean2, 3],-mean2,color = 'darkturquoise',linewidth=2.5)
plt.xlabel("Time [s]",size=15)
plt.ylabel("Drag force [N]",size=15)
plt.title("v = %.1f mm/s"%(np.mean(data[startMean:, 4])*1000),size=19)
plt.ylabel("F [N]",size=15,rotation=0)
plt.ylim([0,25])
plt.show()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment