116 lines
5.0 KiB
Python
116 lines
5.0 KiB
Python
# ENGG4900 Graph Generators
|
|
# Cal Wing 2023
|
|
|
|
import os
|
|
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
from makeGraph import makeGraph, UQ_COLOURS as UQC
|
|
|
|
DATA_FILE_PATH = ".\\data\\AERO4450-Group-10-Data-Analysis-v2.xls"
|
|
actualData = pd.read_excel(DATA_FILE_PATH, sheet_name="Actual Data")
|
|
calibrationData = 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'})
|
|
|
|
data = data[5:505].astype({"Time":"int", "Strain":"float"})
|
|
data1 = data[0::2]
|
|
data2 = data[1::2]
|
|
|
|
return data1, data2
|
|
|
|
def makeCalibrationDataGraph(testRun):
|
|
cols = [f"Unnamed: {3 + testRun*5}", f"Unnamed: {2 + testRun*5}"]
|
|
data = calibrationData[cols].rename(columns = {cols[0]:'Time', cols[1]:'Strain'})
|
|
|
|
data = data[5:505].astype({"Time":"int", "Strain":"float"})
|
|
|
|
return data
|
|
|
|
if __name__ == "__main__":
|
|
if not os.path.isdir("./images"):
|
|
os.mkdir("./images")
|
|
|
|
# Actual Data
|
|
for i in [0,1]:
|
|
graphData = {
|
|
"figTitle": f"Strain over Time (Runs {i+1} to {i+4})",
|
|
"figTitleFontSize": 16,
|
|
"figSize": (8,8), #Yay America, this is in inches :/ # Note: cm = 1/2.54
|
|
"plotDim": (2,2),
|
|
"subPlots":[]
|
|
}
|
|
|
|
for ii in range(i*4, 4 + i*4):
|
|
data1, data2 = makeActualDataGraph(ii)
|
|
newPlot = {
|
|
"title": f"Run {ii+1}",
|
|
"xLabel": "Time (ms) - Δt = 10ms",
|
|
"yLabel": "Strain (ε)" if ii % 2 == 0 else "",
|
|
"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"]},
|
|
{"type":"scatter", "x": data2["Time"], "y": data2["Strain"], "args":{"s":10, "zorder":1}, "label":"Lower", "colour": UQC["dark_grey"]},
|
|
{"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"]},
|
|
]
|
|
}
|
|
graphData["subPlots"].append(newPlot)
|
|
|
|
fig, _ = makeGraph(graphData, showPlot=False)
|
|
#fig.figlegend([ax[0], ax[0]], ['Upper','Lower'], loc=(0.85, 0.65))
|
|
# Subplots adjusted to make room
|
|
# Note bbox_extra_artists includes both the title and the legend so that neither are cut off
|
|
#fig.subplots_adjust(top=0.8, right=0.8)
|
|
fig.savefig(f"./images/actualData_Runs_{i+1}-_{i+4}.png")
|
|
|
|
# Initial test Data
|
|
data1, data2 = makeActualDataGraph(8)
|
|
graphData = {
|
|
"title": f"Initial Test Data\n\"Run 0\"",
|
|
"xLabel": "Time (ms) - Δt = 10ms",
|
|
"yLabel": "Strain (ε)",
|
|
"plots":[
|
|
{"type":"scatter", "x": data1["Time"], "y": data1["Strain"], "args":{"s":10, "zorder":2}, "label":"Upper", "colour": UQC["purple"]},
|
|
{"type":"scatter", "x": data2["Time"], "y": data2["Strain"], "args":{"s":10, "zorder":1}, "label":"Lower", "colour": UQC["dark_grey"]},
|
|
{"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)
|
|
fig.savefig("./images/initTestData.png")
|
|
|
|
# Calibration Data
|
|
# Actual Data
|
|
for i in [0,1]:
|
|
graphData = {
|
|
"figTitle": f"Calibration Data\nStrain over Time (Runs {i+1} to {i+4})",
|
|
"figTitleFontSize": 16,
|
|
"figSize": (8,8), #Yay America, this is in inches :/ # Note: cm = 1/2.54
|
|
"plotDim": (2,2),
|
|
"subPlots":[]
|
|
}
|
|
|
|
for ii in range(i*4, 4 + i*3):
|
|
data1, data2 = makeCalibrationDataGraph(ii)
|
|
newPlot = {
|
|
"title": f"Run {ii+1} - {(ii+1)*50}g",
|
|
"xLabel": "Time (ms) - Δt = 10ms",
|
|
"yLabel": "Strain (ε)" if ii % 2 == 0 else "",
|
|
"plots": [
|
|
{"type":"scatter", "x": data1["Time"], "y": data1["Strain"], "args":{"s":10, "zorder":2}, "colour": UQC["light_purple"]}
|
|
]
|
|
}
|
|
graphData["subPlots"].append(newPlot)
|
|
|
|
fig, _ = makeGraph(graphData, showPlot=False)
|
|
#fig.figlegend([ax[0], ax[0]], ['Upper','Lower'], loc=(0.85, 0.65))
|
|
# Subplots adjusted to make room
|
|
# Note bbox_extra_artists includes both the title and the legend so that neither are cut off
|
|
#fig.subplots_adjust(top=0.8, right=0.8)
|
|
fig.savefig(f"./images/calibData_Runs_{i+1}-_{i+4}.png")
|
|
|
|
|
|
plt.show() |