Inial plotting

This commit is contained in:
Cal Wing 2024-08-26 12:15:12 +10:00
parent 23b1831c96
commit 8cd2fe414b
3 changed files with 61 additions and 27 deletions

1
.gitignore vendored
View File

@ -166,3 +166,4 @@ images
# Temp Folder # Temp Folder
tmp tmp
~$*

83
main.py
View File

@ -1,15 +1,15 @@
# Mech3410-P1-Graphs # Mech3410-P1-Graphs
# Cal # Cal Wing - Aug 2024
# #
import os, time import os, time
import numpy as np import numpy as np
import pandas as pd
from tqdm import tqdm from tqdm import tqdm
from makeGraph import makeGraph, pltKeyClose, UQ_COLOURS as UQC # Custom Graphing Lib from makeGraph import makeGraph, pltKeyClose, UQ_COLOURS as UQC # 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))
#def cos(angle): return np.cos(np.deg2rad(angle)) #def cos(angle): return np.cos(np.deg2rad(angle))
@ -20,31 +20,64 @@ folders = ["./images"]
for folder in folders: for folder in folders:
if not os.path.isdir(folder): os.mkdir(folder) if not os.path.isdir(folder): os.mkdir(folder)
if __name__ == '__main__':
#This is an example of drawing 4 plots by generating them INCH_TO_M = 0.0254
graphData = { GRAVITY = 9.81 #m/s^2
"figTitle": "Simple Plot",
"figTitleFontSize": 16, PITOT_PLACEMENT = ( # mm from base
"figSize": (8,8), #Yay America, this is in inches :/ # Note: cm = 1/2.54 0,
4,
8,
16,
25,
34,
43,
53,
61,
70,
5,
9,
17,
25,
34,
43,
53,
61,
70,
)
print("Loading Data")
data = pd.read_excel('.\\data\\508 RPM Results.xlsx', sheet_name=None, header=None)
print("Loaded Data")
sheet1 = data['0 AoA']
#print(sheet1)
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
pitot_height_inch = sheet1.iloc[4:23, 11]
pitot_height_m = (pitot_height_inch - atm_presure_inch)*INCH_TO_M
pressure = water_density * GRAVITY * pitot_height_m
#print(pressure)
#print(pressure.min(), pressure.max())
makeGraph({
"title": "Simple Plot",
"xLabel": "x label", "xLabel": "x label",
"yLabel": "y label", "yLabel": "y label",
"plotDim": (2,2),
"subPlots":[]
}
#Create 4 identical plots with different names
for i in range(4):
newPlot = {
"title": f"Graph {i+1}",
"plots": [ "plots": [
{"x":[0,1,2,3,4], "y":[0,1,2,3,4], "label":"Linear"}, {"x":PITOT_PLACEMENT, "y":pressure, "label":"Linear", "type":"scatter"},
{"x":[0,1,2,3,4], "y":[5,5,5,5,5]},
{"x":[4,3,2,1,0], "y":[4,3,2,1,0], "label":"Linear2"},
{"x":0, "type":"axvLine", "label":"Red Vertical Line", "color":"red"},
{"y":6, "type":"axhLine", "label":"Dashed Horizontal Line", "args":{"linestyle":"--"}},
{"type":"scatter", "x":4, "y":4, "label":"A Random Point", "colour":"purple", "args":{"zorder":2}}
] ]
} })
graphData["subPlots"].append(newPlot)
makeGraph(graphData, figSavePath="./images/example.png") def main():
pass
if __name__ == '__main__':
main()

Binary file not shown.