Add Final values

This commit is contained in:
Cal W
2023-04-02 22:51:20 +10:00
parent 244de2b09b
commit 7e57662d7c
2 changed files with 51 additions and 11 deletions

60
main.py
View File

@@ -2,6 +2,7 @@
# Cal Wing 2023
import os
from tqdm import tqdm
import pandas as pd
import matplotlib.pyplot as plt
from makeGraph import makeGraph, UQ_COLOURS as UQC
@@ -12,7 +13,6 @@ actualGraphData = pd.read_excel(DATA_FILE_PATH, sheet_name="Actual Data Graphs")
calibrationData = pd.read_excel(DATA_FILE_PATH, sheet_name="Calibration Data")
calibrationGraphData = pd.read_excel(DATA_FILE_PATH, sheet_name="Calibration Data Graphs")
def makeActualDataGraph(testRun):
cols = [f"Unnamed: {3 + testRun*5}", f"Unnamed: {4+ testRun*5}"]
data = actualData[cols].rename(columns = {cols[0]:'Time', cols[1]:'Strain'})
@@ -34,10 +34,12 @@ def makeCalibrationDataGraph(testRun):
return data
if __name__ == "__main__":
if not os.path.isdir("./images"):
os.mkdir("./images")
if not os.path.isdir("./images"): os.mkdir("./images")
if not os.path.isdir("./images/actual"): os.mkdir("./images/actual")
if not os.path.isdir("./images/calibration"): os.mkdir("./images/calibration")
# Actual Data
pbar = tqdm(total=100)
for i in [0,1]:
graphData = {
"figTitle": f"Strain over Time (Runs {i+1} to {i+4})",
@@ -52,7 +54,7 @@ if __name__ == "__main__":
newPlot = {
"title": f"Run {ii+1}",
"xLabel": "Time (ms) - Δt = 10ms",
"yLabel": "Strain (ε)" if ii % 2 == 0 else "",
"yLabel": "Strain (ε)",
"plots": [
#{"type": "text", "text": "Δt = 10ms", "x":0.99, "y":0.03, "align":("bottom", "right")},
{"type":"scatter", "x": data1["Time"], "y": data1["Strain"], "args":{"s":10, "zorder":2}, "label":"Upper", "colour": UQC["purple"]},
@@ -60,8 +62,17 @@ if __name__ == "__main__":
{"type":"plot", "x": data1["Time"], "y": data1["Strain"], "args":{"zorder":0, "alpha":0.25}, "colour": UQC["purple"]},
{"type":"plot", "x": data2["Time"], "y": data2["Strain"], "args":{"zorder":0, "alpha":0.25}, "colour": UQC["dark_grey"]},
]
}
}
fig, _ = makeGraph(graphData, showPlot=False)
fig.savefig(f"./images/actual/Run_{ii+1}.png")
plt.close(fig)
newPlot["yLabel"] = "Strain (ε)" if ii % 2 == 0 else ""
graphData["subPlots"].append(newPlot)
pbar.update(100/8)
pbar.close()
#fig, _ = makeGraph(graphData, showPlot=False)
#fig.savefig(f"./images/actualData_Runs_{i+1}-_{i+4}.png")
@@ -82,6 +93,25 @@ if __name__ == "__main__":
#fig, _ = makeGraph(graphData)
#fig.savefig("./images/initTestData.png")
#Force vs Pressure Graph
cols = [f"Unnamed: 24", f"Unnamed: 25"]
data = actualGraphData[cols].rename(columns = {cols[0]:'Force (Thrust)', cols[1]:'Pressure'})
data = data[1:10].astype({"Force":"float", "Pressure":"float"})
avgStrainGraphData = {
"title": f"Force vs Absolute Pressure",
"xLabel": "Absolute Pressure (kPa)",
"yLabel": "Thrust (N)",
"plots":[
{"type":"scatter", "x": data["Pressure"], "y": data["Force"], "args":{"s":10, "zorder":2}, "label":"Average Strain", "colour": UQC["purple"]},
{"type":"plot", "x": data["Pressure"], "y": data["Force"], "args":{"zorder":0, "alpha":0.25}, "colour": UQC["purple"]},
]
}
fig, _ = makeGraph(avgStrainGraphData)
fig.savefig("./images/ForceVsAbsPressure.png")
# Calibration Data
# Average Data
cols = [f"force stuff", f"Unnamed: 25"]
@@ -89,8 +119,8 @@ if __name__ == "__main__":
data = data[2:8].astype({"Strain":"float", "Force":"float"})
avgStrainGraphData = {
"title": f"Force vs Average Strain",
"xLabel": "Average Strain (ε)",
"yLabel": "Weight (N)",
"xLabel": "Average Strain (με)",
"yLabel": "Force (N)",
"plots":[
{"type":"scatter", "x": data["Strain"], "y": data["Force"], "args":{"s":10, "zorder":2}, "label":"Average Strain", "colour": UQC["purple"]},
{"type":"plot", "label": "Approximation: y(x) = 0.196722x", "x": data["Strain"], "y": data["Strain"]*0.196722, "args":{"zorder":0, "alpha":0.5}, "colour": UQC["dark_grey"]}
@@ -101,6 +131,7 @@ if __name__ == "__main__":
# Actual Data
pbar = tqdm(total=100)
for i in [0,1]:
graphData = {
"figTitle": f"Calibration Data\nStrain over Time (Runs {i+1} to {i+4})",
@@ -115,16 +146,23 @@ if __name__ == "__main__":
newPlot = {
"title": f"Run {ii+1} - {(ii+1)*50}g",
"xLabel": "Time (ms) - Δt = 10ms",
"yLabel": "Strain (ε)" if ii % 2 == 0 else "",
"yLabel": "Strain (ε)",
"plots": [
{"type":"scatter", "x": data["Time"], "y": data["Strain"], "args":{"s":10, "zorder":2}, "colour": UQC["light_purple"]}
]
}
fig, _ = makeGraph(newPlot, showPlot=False)
fig.savefig(f"./images/calibration/Run_{ii+1}.png")
plt.close(fig)
newPlot["yLabel"] = "Strain (ε)" if ii % 2 == 0 else ""
graphData["subPlots"].append(newPlot)
pbar.update(100/7)
if bool(i): graphData["subPlots"].append(avgStrainGraphData)
fig, _ = makeGraph(graphData, showPlot=False)
fig.savefig(f"./images/calibData_Runs_{i+1}-_{i+(4 if i != 0 else 3)}.png")
#fig, _ = makeGraph(graphData, showPlot=False)
#fig.savefig(f"./images/calibData_Runs_{i+1}-_{i+(4 if i != 0 else 3)}.png")
pbar.close()
plt.show()

View File

@@ -1,3 +1,4 @@
colorama==0.4.6
contourpy==1.0.7
cycler==0.11.0
fonttools==4.39.3
@@ -11,4 +12,5 @@ pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2023.3
six==1.16.0
tqdm==4.65.0
xlrd==2.0.1