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

63
main.py
View File

@ -9,7 +9,7 @@ import pandas as pd
from tqdm import tqdm
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
#def sin(angle): return np.sin(np.deg2rad(angle))
@ -77,9 +77,9 @@ def make_pressure_graph(sheet1, aoa, rpm, air_speed, doGraph=True):
{"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, "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')}
]
}
@ -97,10 +97,65 @@ if __name__ == '__main__':
for aoa in tqdm(raw_data["AoA"], position=1):
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
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")

View File

@ -112,7 +112,7 @@ colors.get_named_colors_mapping().update( uq_colour_mapping )
# +-----------------------------+-----------------------------+
# 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["blue"], #4085C6 -> C01 -> uq:blue
UQ_COLOURS["green"], #2EA836 -> C02 -> uq:green
@ -127,7 +127,7 @@ uq_colour_cycler = cycler(color=[
])
# 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 :( )