You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ART.py 2.6KB

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