From 53e13766ecd0517f8b0708015893d56e1c6181f1 Mon Sep 17 00:00:00 2001 From: Cal W <20716204+calw20@users.noreply.github.com> Date: Sun, 2 Apr 2023 22:56:28 +1000 Subject: [PATCH] Enable generation of all graphs --- main.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index 466e6f7..448e338 100644 --- a/main.py +++ b/main.py @@ -39,6 +39,7 @@ if __name__ == "__main__": if not os.path.isdir("./images/calibration"): os.mkdir("./images/calibration") # Actual Data + print("Generating Actual Data Graphs...") pbar = tqdm(total=100) for i in [0,1]: graphData = { @@ -46,6 +47,7 @@ if __name__ == "__main__": "figTitleFontSize": 16, "figSize": (8,8), #Yay America, this is in inches :/ # Note: cm = 1/2.54 "plotDim": (2,2), + "grid": True, "subPlots":[] } @@ -74,15 +76,17 @@ if __name__ == "__main__": pbar.close() - #fig, _ = makeGraph(graphData, showPlot=False) - #fig.savefig(f"./images/actualData_Runs_{i+1}-_{i+4}.png") + fig, _ = makeGraph(graphData, showPlot=False) + fig.savefig(f"./images/actualData_Runs_{i+1}-_{i+4}.png") # Initial test Data + print("Initial Data Graph...") data1, data2 = makeActualDataGraph(8) graphData = { "title": f"Initial Test Data\n\"Run 0\"", "xLabel": "Time (ms) - Δt = 10ms", "yLabel": "Strain (ε)", + "grid": True, "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"]}, @@ -90,30 +94,33 @@ if __name__ == "__main__": {"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") + fig, _ = makeGraph(graphData, showPlot=False) + fig.savefig("./images/initTestData.png") #Force vs Pressure Graph + print("Generating Force vs Pressure Graph...") cols = [f"Unnamed: 24", f"Unnamed: 25"] - data = actualGraphData[cols].rename(columns = {cols[0]:'Force (Thrust)', cols[1]:'Pressure'}) + data = actualGraphData[cols].rename(columns = {cols[0]:'Force', cols[1]:'Pressure'}) data = data[1:10].astype({"Force":"float", "Pressure":"float"}) avgStrainGraphData = { - "title": f"Force vs Absolute Pressure", + "title": f"Force (Thrust) vs Absolute Pressure", "xLabel": "Absolute Pressure (kPa)", "yLabel": "Thrust (N)", + "grid": True, "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, _ = makeGraph(avgStrainGraphData, showPlot=False) fig.savefig("./images/ForceVsAbsPressure.png") # Calibration Data # Average Data + print("Generating Average Strain Graph...") cols = [f"force stuff", f"Unnamed: 25"] data = calibrationGraphData[cols].rename(columns = {cols[0]:'Strain', cols[1]:'Force'}) data = data[2:8].astype({"Strain":"float", "Force":"float"}) @@ -121,16 +128,18 @@ if __name__ == "__main__": "title": f"Force vs Average Strain", "xLabel": "Average Strain (με)", "yLabel": "Force (N)", + "grid": True, "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"]} ] } - #fig, _ = makeGraph(avgStrainGraphData) - #fig.savefig("./images/AverageCaliStrain.png") + fig, _ = makeGraph(avgStrainGraphData, showPlot=False) + fig.savefig("./images/AverageCaliStrain.png") - # Actual Data + # Calibration Date + print("Generating Calibration Data Graphs...") pbar = tqdm(total=100) for i in [0,1]: graphData = { @@ -147,6 +156,7 @@ if __name__ == "__main__": "title": f"Run {ii+1} - {(ii+1)*50}g", "xLabel": "Time (ms) - Δt = 10ms", "yLabel": "Strain (ε)", + "grid": True, "plots": [ {"type":"scatter", "x": data["Time"], "y": data["Strain"], "args":{"s":10, "zorder":2}, "colour": UQC["light_purple"]} ] @@ -160,9 +170,11 @@ if __name__ == "__main__": 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() \ No newline at end of file + plt.show(block=False) + input("Press enter to close all graphs...") + plt.close() \ No newline at end of file