Graph Pressures

This commit is contained in:
Cal Wing 2024-08-26 14:38:52 +10:00
parent d838b54556
commit d670bcf26a
2 changed files with 81 additions and 26 deletions

103
main.py
View File

@ -9,7 +9,7 @@ import pandas as pd
from tqdm import tqdm from tqdm import tqdm
from numpy import sqrt from numpy import sqrt
from makeGraph import makeGraph, pltKeyClose, UQ_COLOURS as UQC # Custom Graphing Lib from makeGraph import makeGraph, pltKeyClose, UQ_COLOURS as UQC, uq_colour_cycler_factory as uqccf # Custom Graphing Lib
# Override Sin & Cos to use & return degrees # Override Sin & Cos to use & return degrees
#def sin(angle): return np.sin(np.deg2rad(angle)) #def sin(angle): return np.sin(np.deg2rad(angle))
@ -61,27 +61,27 @@ def make_pressure_graph(sheet1, aoa, rpm, air_speed, doGraph=True):
graph = { graph = {
"title": f"Pressure vs Pitot Placement along Chord\nfor a Clark Y 14% Aerofoil at:\nα = {int(aoa):d}° at {rpm:d} RPM ({air_speed:.1f}m/s)", "title": f"Pressure vs Pitot Placement along Chord\nfor a Clark Y 14% Aerofoil at:\nα = {int(aoa):d}° at {rpm:d} RPM ({air_speed:.1f}m/s)",
"windowTitle": f"Pressure along Clark Y 14% Airfoil - Alpha {int(aoa):d} Degrees - {rpm:d}rpm - {air_speed:.1f}m_s", "windowTitle": f"Pressure along Clark Y 14% Airfoil - Alpha {int(aoa):d} Degrees - {rpm:d}rpm - {air_speed:.1f}m_s",
"xLabel": "Pitot Placement [mm]", "xLabel": "Pitot Placement [mm]",
"yLabel": "Pressure [Pa]", "yLabel": "Pressure [Pa]",
"grid": True, "grid": True,
"yLim": (pressure.min()-10, pressure.max()+10), "yLim": (pressure.min()-10, pressure.max()+10),
"plots": [ "plots": [
{"x": PITOT_PLACEMENT[:10], "y":pressure[:10], "colour": UQC["purple"]}, {"x": PITOT_PLACEMENT[:10], "y":pressure[:10], "colour": UQC["purple"]},
{"x": PITOT_PLACEMENT[10:], "y":pressure[10:], "colour": UQC["purple"]}, {"x": PITOT_PLACEMENT[10:], "y":pressure[10:], "colour": UQC["purple"]},
{"x": [PITOT_PLACEMENT[0], PITOT_PLACEMENT[10]], "y": [pressure.iloc[0], pressure.iloc[10]], "colour": UQC["purple"]}, {"x": [PITOT_PLACEMENT[0], PITOT_PLACEMENT[10]], "y": [pressure.iloc[0], pressure.iloc[10]], "colour": UQC["purple"]},
{"x": [PITOT_PLACEMENT[9], PITOT_PLACEMENT[18]], "y": [pressure.iloc[9], pressure.iloc[18]], "colour": UQC["purple"]}, {"x": [PITOT_PLACEMENT[9], PITOT_PLACEMENT[18]], "y": [pressure.iloc[9], pressure.iloc[18]], "colour": UQC["purple"]},
{"x": PITOT_PLACEMENT[:10], "y":pressure[:10], "colour": UQC["purple"], "alpha":0.2, "type":"fill"}, {"x": PITOT_PLACEMENT[:10], "y":pressure[:10], "colour": UQC["purple"], "alpha":0.2, "type":"fill"},
{"x": PITOT_PLACEMENT[10:], "y":pressure[10:], "colour": "w", "type":"fill"}, {"x": PITOT_PLACEMENT[10:], "y":pressure[10:], "colour": "w", "type":"fill"},
{"x":[PITOT_PLACEMENT[0], PITOT_PLACEMENT[10]], "y":[pressure.iloc[0], pressure.iloc[10]], "colour": "w", "type":"fill"}, {"x":[PITOT_PLACEMENT[0], PITOT_PLACEMENT[10]], "y":[pressure.iloc[0], pressure.iloc[10]], "colour": "w", "type":"fill"},
{"x":PITOT_PLACEMENT, "y":pressure, "label":"Pressure Data", "type":"scatter"},
{"x":PITOT_PLACEMENT, "y":pressure, "label":"Pressure Data", "type":"scatter"}, {"label":[str(i) for i in range(1, len(PITOT_PLACEMENT)+1)], "x":PITOT_PLACEMENT, "y":pressure, "type":"annotate"},
{"label":[str(i) for i in range(1, len(PITOT_PLACEMENT)+1)], "x":PITOT_PLACEMENT, "y":pressure, "type":"annotate"} {"type":"text", "x": 0.98, "y": 0.02, "text": f"Min: {pressure.min():.3f} Pa\nMax: {pressure.max():.3f} Pa", "align": ('bottom', 'right')}
] ]
} }
if doGraph: if doGraph:
makeGraph(graph, False, figSavePath=f'./images/pressure/{{0}}.png') makeGraph(graph, False, figSavePath=f'./images/pressure/{{0}}.png')
@ -97,12 +97,67 @@ if __name__ == '__main__':
for aoa in tqdm(raw_data["AoA"], position=1): for aoa in tqdm(raw_data["AoA"], position=1):
sheet = raw_data["data"][f"{aoa} AoA"] sheet = raw_data["data"][f"{aoa} AoA"]
aoa_data[aoa] = make_pressure_graph(sheet, aoa, raw_data["rpm"], raw_data["airSpeed"], False) aoa_data[aoa] = make_pressure_graph(sheet, aoa, raw_data["rpm"], raw_data["airSpeed"], True)
data[raw_data["rpm"]] = aoa_data data[raw_data["rpm"]] = aoa_data
if True:
# All
graph = {
"title": f"Pressure vs Pitot Placement along Chord\nfor a Clark Y 14% Aerofoil at:\n{raw_data["rpm"]:d} RPM ({raw_data["airSpeed"]:.1f}m/s)",
"windowTitle": f"All Pressure along Clark Y 14% Airfoil - {raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m_s",
"xLabel": "Pitot Placement [mm]",
"yLabel": "Pressure [Pa]",
"grid": True,
"ledgLoc": 1,
"plots": []
}
colour_cycle = uqccf()
for aoa, c in zip(aoa_data, colour_cycle):
this_data = aoa_data[aoa]
pressure = this_data[0]
plts = (
{"x": PITOT_PLACEMENT[:10], "y":pressure[:10], "colour": c["color"]},
{"x": PITOT_PLACEMENT[10:], "y":pressure[10:], "colour": c["color"]},
{"x": [PITOT_PLACEMENT[0], PITOT_PLACEMENT[10]], "y": [pressure.iloc[0], pressure.iloc[10]], "colour": c["color"]},
{"x": [PITOT_PLACEMENT[9], PITOT_PLACEMENT[18]], "y": [pressure.iloc[9], pressure.iloc[18]], "colour": c["color"]},
{"x":PITOT_PLACEMENT, "y":pressure, "label":f"α = {int(aoa):d}°", "type":"scatter", "colour": c["color"]},
)
for plt in plts:
graph["plots"].append(plt)
if raw_data["rpm"] == 508:
graph['xLim'] = (
min(PITOT_PLACEMENT) - 5,
max(PITOT_PLACEMENT) + 20
)
graph["figSize"] = (8, 6)
makeGraph(graph, False, figSavePath="./images/pressure/__{0}.png")
graph["plots"] = []
graph["windowTitle"] = f"Pressure along Clark Y 14% Airfoil - {raw_data["rpm"]:d}rpm - {raw_data["airSpeed"]:.1f}m_s"
colour_cycle = uqccf()
for aoa, c in list(zip(aoa_data, colour_cycle))[1::2]:
this_data = aoa_data[aoa]
pressure = this_data[0]
plts = (
{"x": PITOT_PLACEMENT[:10], "y":pressure[:10], "colour": c["color"]},
{"x": PITOT_PLACEMENT[10:], "y":pressure[10:], "colour": c["color"]},
{"x": [PITOT_PLACEMENT[0], PITOT_PLACEMENT[10]], "y": [pressure.iloc[0], pressure.iloc[10]], "colour": c["color"]},
{"x": [PITOT_PLACEMENT[9], PITOT_PLACEMENT[18]], "y": [pressure.iloc[9], pressure.iloc[18]], "colour": c["color"]},
{"x":PITOT_PLACEMENT, "y":pressure, "label":f"α = {int(aoa):d}°", "type":"scatter", "colour": c["color"]},
)
for plt in plts:
graph["plots"].append(plt)
makeGraph(graph, False, figSavePath="./images/pressure/__{0}.png")
print("Data Loaded") print("Data Loaded")

View File

@ -112,7 +112,7 @@ colors.get_named_colors_mapping().update( uq_colour_mapping )
# +-----------------------------+-----------------------------+ # +-----------------------------+-----------------------------+
# Build a colour cycler # Build a colour cycler
uq_colour_cycler = cycler(color=[ uq_colour_cycler_factory = lambda: cycler(color=[
UQ_COLOURS["purple"], #51247A -> C00 -> uq:purple UQ_COLOURS["purple"], #51247A -> C00 -> uq:purple
UQ_COLOURS["blue"], #4085C6 -> C01 -> uq:blue UQ_COLOURS["blue"], #4085C6 -> C01 -> uq:blue
UQ_COLOURS["green"], #2EA836 -> C02 -> uq:green UQ_COLOURS["green"], #2EA836 -> C02 -> uq:green
@ -127,7 +127,7 @@ uq_colour_cycler = cycler(color=[
]) ])
# Tell MatPlotLib to use said cycler # Tell MatPlotLib to use said cycler
plt.rc('axes', prop_cycle=uq_colour_cycler) plt.rc('axes', prop_cycle=uq_colour_cycler_factory())
## UQ Colour Gradient (Not very good :( ) ## UQ Colour Gradient (Not very good :( )