Compare commits

..

2 commits

Author SHA1 Message Date
Nicolas Rohrbeck
8dcfa7ce42 Added line parser method 2025-03-31 11:27:10 +02:00
Nicolas Rohrbeck
fb1cd7d491 initial commit 2025-03-13 15:11:34 +01:00
3 changed files with 52 additions and 0 deletions

1
.gitignore vendored Executable file
View file

@ -0,0 +1 @@
data/

4
README.md Normal file → Executable file
View file

@ -1 +1,5 @@
Repository for the development of an Attitude Determination System for the SETH experiment. This is Nicolas Bachelor Thesis.
I have a directory data/ in the repo in which all data for the junior flight is in a sub-directory called junior/
att_eval.py i the main script for evaluation

47
att_eval.py Executable file
View file

@ -0,0 +1,47 @@
#!/usr/bin/env python
"""
Author: Nicolas Rohrbeck
Program to read .EI files of SETH jr. (CRYSTAL) to determine the gondolas attitude
"""
import numpy as np
def twos_complement(input: np.ndarray) -> np.ndarray:
"""
Converts a 16 bit unsigned integer to a signed integer with respect to the twos complement origin of the number
"""
vhex = np.vectorize(hex)
return vhex(input)
def line_parser(line: str) -> tuple[np.ndarray, np.ndarray]:
"""
Parses magnetometer and accelerometer vectors from a line of data and returns a tuple of two numpy arrays
"""
if line.split(" ")[0] == "ID": # only perfrom on ID lines maybe put this in the function calling the parser?
split_line = line.split(" ")
mag1: np.ndarray = np.array(split_line[12:66], dtype=np.uint16).reshape(18, 3) # np.array with 18 rows of 3 vectors
mag2: np.ndarray = np.array(split_line[131:], dtype=np.uint16).reshape(1, 3) # the slices differ from i2c.py by 1 because of the line header, "ID"
mags: np.ndarray = np.vstack((mag1, mag2)) # now has shape (19, 3)
accs : np.ndarray = np.array(split_line[68:131], dtype=np.uint16).reshape(21, 3)
return (mags, accs)
def gauss_converter(input: np.ndarray) -> np.ndarray:
"""
Converts array of raw magnetometer data (two's complement) to array in gauss with formula: magnetic_intensity (in gauss) = raw_data / sensitivity
"""
sensitivity = 6842 # LSB/gauss
return twos_complement(input) #/ sensitivity
class ads:
def __init__(self, filepath: str, verbosity: int = 0) -> None:
self.filepath: str = filepath
self.filename: str = filepath.split("/")[-1].split(".")[0]
self.v: int = verbosity # how much info is to be printed, 0 is the lowest
def __str__(self):
return f"path: {self.filepath} \nfilename: {self.filename}"
if __name__ == "__main__" :
an_instance = ads("c:/Users/nicol/OneDrive/Dokumente/Python Scripts/ADS/data/junior/2025-03-12-pizerotest-1.EI")
longstring = "ID 4805 132 167 64916 63426 56860 0 135 0 0 0 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 64916 63426 56860 8239 167 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64916 63426 56860"
print(gauss_converter(line_parser(longstring)[0]))