import matplotlib.pyplot as plt import numpy as np import re class ART_plotting: def __init__(self): self.bla = 0 def plot_art(self, recording_number): """ :param recording_name: int, Choose which recording to print e.g. Recording_!1! , Recording_!2!, etc. :return: void it just plots """ """--------------- Open, format and save ART positions from text files---------------------------------------""" # Opening a recording art_recording = open('ART_IndLoc precision tests/Recording_'+str(recording_number)+'.txt', 'r') art_recording = art_recording.read() # Formatting a recording art_recording = re.split(' |\n', art_recording) # split string at whitespace and linebreak art_recording = np.array(art_recording) # list -> np.array # Count the total number of recorded positions total_pos_counter = 0 for i in art_recording: if i == '6d': # this is the flag marking a 6d position (Syntax of the ART guys in the txt files) total_pos_counter += 1 # Create an empty array which will store the ART measurement infos art_info = np.zeros((total_pos_counter, 7)) # [t, x, y, z, alpha, beta, gamma] # Fill the empty numpy array with the information's of the art_recording pos_counter = 0 for i in range(len(art_recording)): if art_recording[i] == 'ts': # following entry is timestamp art_info[pos_counter] = float(art_recording[i+1]) if art_recording[i] == '6d': # following entries are x,y,z,alpha,beta,gamma art_info[pos_counter, 1] = float(art_recording[i+3].split('[')[1]) # x (had to delete some excess text) art_info[pos_counter, 2] = float(art_recording[i+4]) # y art_info[pos_counter, 3] = float(art_recording[i+5]) # z art_info[pos_counter, 4] = float(art_recording[i+6]) # alpha art_info[pos_counter, 5] = float(art_recording[i+7]) # beta art_info[pos_counter, 6] = float(art_recording[i+8].split(']')[0]) # gamma (had to delete some excess text pos_counter += 1 """------------------- Plotting ART ----------------------------------------------------""" font = {"family":"serif", "color":"black", "size":15} plt.plot(art_info[:, 1], art_info[:, 2], color="lightgreen", label="ART System", linewidth=5, marker="x") print("x=", art_info[:, 1]) print("y=", art_info[:, 2])