Load Pressure Data & Graph
This commit is contained in:
parent
8cd2fe414b
commit
d838b54556
2
.gitignore
vendored
2
.gitignore
vendored
@ -166,4 +166,4 @@ images
|
||||
# Temp Folder
|
||||
tmp
|
||||
|
||||
~$*
|
||||
data/~$*
|
||||
|
117
main.py
117
main.py
@ -7,6 +7,7 @@ import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from tqdm import tqdm
|
||||
from numpy import sqrt
|
||||
|
||||
from makeGraph import makeGraph, pltKeyClose, UQ_COLOURS as UQC # Custom Graphing Lib
|
||||
|
||||
@ -16,7 +17,7 @@ from makeGraph import makeGraph, pltKeyClose, UQ_COLOURS as UQC # Custom Graphin
|
||||
|
||||
# Make sure the relevant folders folder exists
|
||||
#folders = ["./images", "./tmp", "./data"]
|
||||
folders = ["./images"]
|
||||
folders = ["./images", './images/pressure', './images/cp']
|
||||
for folder in folders:
|
||||
if not os.path.isdir(folder): os.mkdir(folder)
|
||||
|
||||
@ -24,60 +25,84 @@ for folder in folders:
|
||||
INCH_TO_M = 0.0254
|
||||
GRAVITY = 9.81 #m/s^2
|
||||
|
||||
PITOT_PLACEMENT = ( # mm from base
|
||||
0,
|
||||
4,
|
||||
8,
|
||||
16,
|
||||
25,
|
||||
34,
|
||||
43,
|
||||
53,
|
||||
61,
|
||||
70,
|
||||
5,
|
||||
9,
|
||||
17,
|
||||
25,
|
||||
34,
|
||||
43,
|
||||
53,
|
||||
61,
|
||||
70,
|
||||
)
|
||||
CHORD_LEN = 90 #mm
|
||||
PITOT_PLACEMENT = np.array((0,4,8,16,25,34,43,53,61,70,5,9,17,25,34,43,53,61,70)) # mm from base of chord
|
||||
PITOT_PLACEMENT_CHORD_NORM = PITOT_PLACEMENT / CHORD_LEN
|
||||
|
||||
print("Loading Data")
|
||||
data = pd.read_excel('.\\data\\508 RPM Results.xlsx', sheet_name=None, header=None)
|
||||
print("Loaded Data")
|
||||
print("="*15, "Loading Data", "="*15)
|
||||
data_508rpm = {
|
||||
"rpm": 508,
|
||||
"airSpeed": 10,
|
||||
"data": pd.read_excel('.\\data\\508 RPM Results.xlsx', sheet_name=None, header=None),
|
||||
"AoA": (0,1,2,3,4,5,6,7,8,9)
|
||||
}
|
||||
|
||||
sheet1 = data['0 AoA']
|
||||
#print(sheet1)
|
||||
data_1000rpm = {
|
||||
"rpm": 1000,
|
||||
"airSpeed": 20.40408122,
|
||||
"data": pd.read_excel('.\\data\\1000 RPM Results.xlsx', sheet_name=None, header=None),
|
||||
"AoA": (1,2,4,6,8,10,12,14,16)
|
||||
}
|
||||
|
||||
air_speed = 10 # m/s
|
||||
water_density = sheet1.iloc[0, 2] # kg/m^3
|
||||
air_density = sheet1.iloc[1, 2] # kg/m^3
|
||||
atm_presure_inch = sheet1.iloc[24, 12] # inch
|
||||
print("="*15, "Loaded Data", "="*15)
|
||||
|
||||
pitot_height_inch = sheet1.iloc[4:23, 11]
|
||||
pitot_height_m = (pitot_height_inch - atm_presure_inch)*INCH_TO_M
|
||||
def make_pressure_graph(sheet1, aoa, rpm, air_speed, doGraph=True):
|
||||
water_density = sheet1.iloc[0, 2] # kg/m^3
|
||||
air_density = sheet1.iloc[1, 2] # kg/m^3
|
||||
atm_presure_inch = sheet1.iloc[24, 12] # inch
|
||||
|
||||
pressure = water_density * GRAVITY * pitot_height_m
|
||||
pitot_height_inch = sheet1.iloc[4:23, 11]
|
||||
pitot_height_m = (pitot_height_inch - atm_presure_inch)*INCH_TO_M
|
||||
|
||||
#print(pressure)
|
||||
#print(pressure.min(), pressure.max())
|
||||
pressure = water_density * GRAVITY * pitot_height_m
|
||||
|
||||
#print(pressure)
|
||||
#print(pressure.min(), pressure.max())
|
||||
|
||||
|
||||
makeGraph({
|
||||
"title": "Simple Plot",
|
||||
"xLabel": "x label",
|
||||
"yLabel": "y label",
|
||||
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)",
|
||||
"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]",
|
||||
"yLabel": "Pressure [Pa]",
|
||||
"grid": True,
|
||||
"yLim": (pressure.min()-10, pressure.max()+10),
|
||||
"plots": [
|
||||
{"x":PITOT_PLACEMENT, "y":pressure, "label":"Linear", "type":"scatter"},
|
||||
]
|
||||
})
|
||||
{"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[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": "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"}
|
||||
]
|
||||
}
|
||||
|
||||
if doGraph:
|
||||
makeGraph(graph, False, figSavePath=f'./images/pressure/{{0}}.png')
|
||||
|
||||
return pressure, graph, (water_density, air_density, atm_presure_inch, pitot_height_inch)
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
print("Loading Data & Generating Pressure Graphs")
|
||||
data = {}
|
||||
for raw_data in tqdm((data_508rpm, data_1000rpm), position=0):
|
||||
aoa_data = {}
|
||||
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)
|
||||
|
||||
data[raw_data["rpm"]] = aoa_data
|
||||
|
||||
print("Data Loaded")
|
||||
|
||||
|
||||
|
||||
|
||||
|
34
makeGraph.py
34
makeGraph.py
@ -4,9 +4,10 @@
|
||||
#### 2023 - Added UQ Colors
|
||||
#### 2023 - Added pltKeyClose function
|
||||
#### 2023 - Added UQ Default Colours to MatPlotLib
|
||||
#### 2024 - Added Annotation & Fill
|
||||
|
||||
__author__ = "Cal Wing"
|
||||
__version__ = "0.1.10"
|
||||
__version__ = "0.1.11"
|
||||
|
||||
from collections.abc import Iterator
|
||||
import numpy as np
|
||||
@ -368,6 +369,33 @@ def makeGraph(graphData, showPlot=True, doProgramBlock=True, figSavePath=None, h
|
||||
align = getSafeValue("align", align)
|
||||
|
||||
ax.text(getSafeValue("x", 0.05), getSafeValue("y", 0.95), pData["text"], transform=ax.transAxes, fontsize=getSafeValue("fontsize", None), va=align[0], ha=align[1], bbox=props)
|
||||
elif pData["type"] == "annotate":
|
||||
if type(pData["label"]) == str:
|
||||
if "pos" in pData:
|
||||
pData["x"] = pData["pos"][0]
|
||||
pData["y"] = pData["pos"][1]
|
||||
ax.annotate(
|
||||
pData["label"], # this is the text
|
||||
(pData["x"],pData["y"]), # these are the coordinates to position the label
|
||||
textcoords=getSafeValue("offType", "offset points"), # how to position the text
|
||||
xytext=getSafeValue("offset", (0,10)), # distance from text to points (x,y)
|
||||
ha=getSafeValue("align", 'center') # horizontal alignment can be left, right or center
|
||||
)
|
||||
else:
|
||||
if "pos" not in pData:
|
||||
pData["pos"] = list(zip(pData['x'], pData['y']))
|
||||
for i, label in enumerate(pData["label"]):
|
||||
ax.annotate(
|
||||
label, # this is the text
|
||||
(pData["pos"][i][0], pData["pos"][i][1]), # these are the coordinates to position the label
|
||||
textcoords=getSafeValue("offType", "offset points"), # how to position the text
|
||||
xytext=getSafeValue("offset", (0,10)), # distance from text to points (x,y)
|
||||
ha=getSafeValue("align", 'center') # horizontal alignment can be left, right or center
|
||||
)
|
||||
elif pData["type"] == "fill":
|
||||
ax.fill_between(list(pData["x"]), list(pData["y"]), color=getSafeColour, alpha=getSafeValue("alpha", 1), linewidth=getSafeValue("linewidth", None))
|
||||
#ax.fill_between(xA, yA, color="w")
|
||||
|
||||
|
||||
|
||||
#Set extra options as needed
|
||||
@ -440,6 +468,8 @@ def makeGraph(graphData, showPlot=True, doProgramBlock=True, figSavePath=None, h
|
||||
|
||||
fig.suptitle(graphData["figTitle"], fontsize=getSafeValue("figTitleFontSize"))
|
||||
fig.canvas.manager.set_window_title(graphData["figTitle"].replace("\n", " "))
|
||||
if "windowTitle" in graphData:
|
||||
fig.canvas.manager.set_window_title(graphData["windowTitle"].replace("\n", " "))
|
||||
|
||||
fig.tight_layout() #Fix labels being cut off sometimes
|
||||
|
||||
@ -448,7 +478,7 @@ def makeGraph(graphData, showPlot=True, doProgramBlock=True, figSavePath=None, h
|
||||
flatAxes[-1].set_axis_off()
|
||||
|
||||
if figSavePath:
|
||||
fig.savefig(figSavePath)
|
||||
fig.savefig(figSavePath.format(fig.canvas.manager.get_window_title()))
|
||||
|
||||
if showPlot:
|
||||
plt.show(block=doProgramBlock) #Show the plot and also block the program - doing things OO style allow for more flexible programs
|
||||
|
Loading…
Reference in New Issue
Block a user