craft-software/Legacy/TF_Control/scripts/plot_raw_data.py
2025-07-04 15:52:40 +02:00

63 lines
1.7 KiB
Python

import numpy as np
import sys,os
import matplotlib.pyplot as plt
# Get the current script's directory
current_dir = os.path.dirname(os.path.abspath(__file__))
# Get the parent directory by going one level up
parent_dir = os.path.dirname(current_dir)
# Add the parent directory to sys.path
sys.path.append(parent_dir)
from scripts import import_txt
#import "raw" data from file
path = r"D:\Glaskryostat\Data\2025-04-01 Nb3SN-Nb-Cu-HZB-SI\calibrated_data_2025_04_02_correct_time.csv"
path_points = r"D:\Glaskryostat\Data\2025-04-01 Nb3SN-Nb-Cu-HZB-SI\points\TF-v-DT.txt"
[header,data,times] = import_txt.read_wdate(path,'timestamp',delim=' ')
#extract times from points file if it exists to plot them
point_times = []
try:
[header,data_arr,point_times] = import_txt.read_w3dates(path_points, '%Y-%m-%d_%H-%M-%S',delim = '\t')
point_times = [x for xs in point_times for x in xs] #flatten list
except:
pass
#plot tempeature data versus time
plt.figure(1)
for i in range(8):
plt.plot(times,data[:,i],label=str(i+1))
try:
for i in range(len(point_times)):
plt.axvline(x=point_times[i],color='black',linestyle='dashed')
except:
pass
plt.legend()
plt.show(block=False)
plt.title('Temperature')
#plot AMR_x data versus time
plt.figure(2)
plt.plot(times,data[:,8:23])
plt.show(block=False)
plt.title('AMR_x')
#plot AMR_y data versus time
plt.figure(3)
plt.plot(times,data[:,23:38])
plt.show(block=False)
plt.title('AMR_y')
#plot AMR_z data versus time
plt.figure(4)
plt.plot(times,data[:,38:53])
plt.show(block=False)
plt.title('AMR_z')
#plot fluxgate data versus time
plt.figure(5)
plt.plot(times,data[:,53:56])
plt.show()
plt.title('Fluxgate')