AERO4200-Ass3/main.py

86 lines
3.0 KiB
Python
Raw Normal View History

2023-10-22 14:40:10 +10:00
# Aero4200-Ass3
2023-10-22 17:25:20 +10:00
# Cal Wing, Sem 2 2023
2023-10-22 14:40:10 +10:00
2023-10-22 17:25:20 +10:00
# Import System / Common Libs
2023-10-22 14:40:10 +10:00
import os, time
import numpy as np
2023-10-22 17:25:20 +10:00
import pandas as pd
2023-10-22 14:40:10 +10:00
from tqdm import tqdm
2023-10-22 17:25:20 +10:00
#Import MakeGraph, a custom graphing wrapper I developed, refer to it for documentation
2023-10-22 14:40:10 +10:00
from makeGraph import makeGraph, pltKeyClose, UQ_COLOURS as UQC # Custom Graphing Lib
# Override Sin & Cos to use & return degrees
#def sin(angle): return np.sin(np.deg2rad(angle))
#def cos(angle): return np.cos(np.deg2rad(angle))
# Make sure the relevant folders folder exists
folders = ["./images"]
for folder in folders:
if not os.path.isdir(folder): os.mkdir(folder)
2023-10-22 17:25:20 +10:00
# IMU Data Loading
# I map in to a heading to add units / make things make more sense
## The gyroscopic body angular rates from the IMU are given:
# - WBE_1 (in rad/s) - the roll rate about the body-fixed x-axis
# - WBE_2 (in rad/s) - the pitch rate about the body-fixed y-axis
# - WBE_3 (in rad/s) - the yaw rate about the body-fixed z-axis
## Specific forces:
# - FSP_X (in m/s2) - the specific force in the body-fixed x-direction
# - FSP_Y (in m/s2) - the specific force in the body-fixed y-direction
# - FSP_Z (in m/s2) - the specific force in the body-fixed z-direction
IMU_DATA_HEADER = [
"Time [s]",
"WBE_1 [rad/s]", "WBE_2 [rad/s]", "WBE_3 [rad/s]",
"FSP_X [m/s^2]", "FSP_Y [m/s^2]", "FSP_Z [m/s^2]"
]
def importIMUData(mission, imu):
# If IMU is not a string, then convert based on bool eval where "H" == True
if type(imu) != str: imu = "H" if imu else "L"
2023-10-22 17:25:43 +10:00
data = pd.read_csv(
2023-10-22 17:25:20 +10:00
f"./data/IMU_M{str(mission) + str(imu)}.txt",
header=None, skiprows=1,
names=IMU_DATA_HEADER,
dtype=[float, float, float, float, float, float, float],
)
2023-10-22 17:25:43 +10:00
return data
2023-10-22 17:25:20 +10:00
m1_IMUData = importIMUData(1, 0), importIMUData(1, 1) #(L, H) Data
m2_IMUData = importIMUData(2, 0), importIMUData(2, 1)
2023-10-22 14:46:20 +10:00
2023-10-22 14:40:10 +10:00
if __name__ == '__main__':
2023-10-22 17:25:20 +10:00
input("Damn")
2023-10-22 14:46:20 +10:00
if __name__ == '__main__1':
2023-10-22 14:40:10 +10:00
#This is an example of drawing 4 plots by generating them
graphData = {
"figTitle": "Simple Plot",
"figTitleFontSize": 16,
"figSize": (8,8), #Yay America, this is in inches :/ # Note: cm = 1/2.54
"xLabel": "x 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": [
{"x":[0,1,2,3,4], "y":[0,1,2,3,4], "label":"Linear"},
{"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")