add basic tunnel info

This commit is contained in:
Cal Wing 2024-10-16 20:57:25 +10:00
parent a95399fb04
commit 5a24ab0bc1
4 changed files with 73 additions and 36 deletions

View File

@ -465,10 +465,10 @@ def canny_shock_finder(time_list, pressure_list, sigma = 4, derivative_threshold
ax.tick_params(which='both', direction='out') ax.tick_params(which='both', direction='out')
ax.yaxis.set_ticks_position('left') ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom') ax.xaxis.set_ticks_position('bottom')
for tick in ax.yaxis.get_major_ticks(): #for tick in ax.yaxis.get_major_ticks():
tick.label.set_fontsize(font_sizes['tick_size']) # tick.label.set_fontsize(font_sizes['tick_size'])
for tick in ax.xaxis.get_major_ticks(): #for tick in ax.xaxis.get_major_ticks():
tick.label.set_fontsize(font_sizes['tick_size']) # tick.label.set_fontsize(font_sizes['tick_size'])
ax.legend(prop={'size':font_sizes['legend_text_size']}, loc = 'best') ax.legend(prop={'size':font_sizes['legend_text_size']}, loc = 'best')

View File

@ -12,7 +12,6 @@ shot-info:
config: "x2s5823.config" config: "x2s5823.config"
info: "x2s5823.txt" info: "x2s5823.txt"
probe-info: probe-info:
type: "Fat" type: "Fat"
locations: # In order of pulse locations: # In order of pulse

66
main.py
View File

@ -22,6 +22,10 @@ for folder in folders:
# Load Data # Load Data
DATA_PATH = "./data" DATA_PATH = "./data"
DATA_INFO = "_info.yaml" DATA_INFO = "_info.yaml"
PCB_INFO_FILE = "./pcb-info.yaml"
with open(PCB_INFO_FILE, 'r') as file:
PCB_INFO = yaml.safe_load(file)
data_to_load = [ data_to_load = [
"x2s5823", "x2s5823",
@ -85,46 +89,46 @@ for dp in data_to_load:
loaded_data = list(data.keys()) loaded_data = list(data.keys())
print("Loaded Data") print("Loaded Data")
foo = data[loaded_data[0]]["x2"][0]
bar = foo[:].seconds
baz = bar[0]
print(foo)
print(bar)
print(baz)
pass
def process_data(gData: dict): def process_data(gData: dict):
x2_time = (gData["x2"][0][:] - gData["x2"][0][0]).astype('timedelta64[ns]') # Convert x2 to timedelta64[ns] #x2_time = (gData["x2"][0][:] - gData["x2"][0][0]).astype('timedelta64[ns]') # Convert x2 to timedelta64[ns]
time_data = data[loaded_data[0]]["x2"][0]
second_fractions = np.array(time_data[:].second_fractions, dtype=int)
seconds = (second_fractions - second_fractions[0]) * (2**(-64))
ns_seconds = seconds * 1E9
x2_time = ns_seconds
trigger_info = gData["info"]["probe-info"]["data-record"]["trigger"] # Get the scope trigger info trigger_info = gData["info"]["probe-info"]["data-record"]["trigger"] # Get the scope trigger info
# Convert the scope times into timedelta64 & apply config offsets & delays # Convert the scope times into timedelta64 & apply config offsets & delays
scope_time = np.array([ pd.Timedelta(t, 's').to_numpy() for t in (gData["probes"][:, 0] - gData["probes"][0, 0])]) #scope_time = np.array([ pd.Timedelta(t, 's').to_numpy() for t in (gData["probes"][:, 0] - gData["probes"][0, 0])])
scope_time -= np.timedelta64(trigger_info["alignment-offset"], 'ns') #scope_time -= np.timedelta64(trigger_info["alignment-offset"], 'ns')
scope_time += np.timedelta64(trigger_info["delay"], 'us') #scope_time += np.timedelta64(trigger_info["delay"], 'us')
scope_time = (gData["probes"][:, 0] - gData["probes"][0, 0]) * 1E9 # to ns
scope_time -= trigger_info["alignment-offset"]
scope_time += trigger_info["delay"] * 1000 # us -> ns
start_timestamp = np.datetime64(f"{gData["info"]["date"]}T{gData["info"]["time"]}") start_timestamp = np.datetime64(f"{gData["info"]["date"]}T{gData["info"]["time"]}")
start_time = 0 # start_time = 0
x2_timesteps = np.array([0 for _ in x2_time]) # x2_timesteps = np.array([0 for _ in x2_time])
for i, dt in enumerate(x2_time): # for i, dt in enumerate(x2_time):
dt = dt.astype("int") # dt = dt.astype("int")
if i == 0: # if i == 0:
x2_timesteps[i] = start_time + dt # should be 0 # x2_timesteps[i] = start_time + dt # should be 0
else: # else:
x2_timesteps[i] = x2_timesteps[i-1] + dt # x2_timesteps[i] = x2_timesteps[i-1] + dt
test = x2_time.cumsum() # test = x2_time.cumsum()
return x2_time, scope_time, x2_timesteps return x2_time, scope_time
def genGraph(gData: dict, showPlot: bool = True): def genGraph(gData: dict, showPlot: bool = True):
x2_time, scope_time, _ = process_data(gData) x2_time, scope_time = process_data(gData)
graphData = { graphData = {
"title": f"Shock response Time\nFor {gData['info']['long_name']}", "title": f"Shock response Time\nFor {gData['info']['long_name']}",
@ -176,13 +180,13 @@ genGraph(data[loaded_data[1]], showPlot=False)
# Try to process things # Try to process things
gData = data[loaded_data[0]] gData = data[loaded_data[0]]
x2_time, scope_time, x2_timestamps = process_data(gData) x2_time, scope_time = process_data(gData)
time = (gData["x2"][0][:] - gData["x2"][0][0]) #time = (gData["x2"][0][:] - gData["x2"][0][0])
#x2_out = canny_shock_finder(time, (gData["x2"][4][:] - gData["x2"][4][0]) * 0.0148) x2_out = canny_shock_finder(x2_time, (gData["x2"][4][:] - gData["x2"][4][0]) * 0.0148)
#print(x2_out) print(x2_out)
# This forces matplotlib to hang untill I tell it to close all windows # This forces matplotlib to hang untill I tell it to close all windows
pltKeyClose() pltKeyClose()

34
pcb-info.yaml Normal file
View File

@ -0,0 +1,34 @@
distance:
sd1: 2577 #mm
sd2: 2810 #mm
sd3: 3043 #mm
st1: 4231 #mm
st2: 4746 #mm
st3: 5260 #mm
at1: 6437 #mm
at2: 6615 #mm
at3: 6796 #mm
at4: 7590 #mm
at5: 7846 #mm
at6: 8096 #mm
volt-scale:
sd1: 0.00095 #V/kPa
sd2: 0.00095 #V/kPa
sd3: 0.000682 #V/kPa
st1: 0.01482 #V/kPa
st2: 0.011687 #V/kPa
st3: 0.0145 #V/kPa
at1: 0.01443 #V/kPa
at2: 0.0145 #V/kPa
at3: 0.0144798 #V/kPa
at4: 0.01435 #V/kPa
at5: 0.01447 #V/kPa
at6: 0.01442 #V/kPa