From 5a24ab0bc12f9c696f8e457331d59c8f0ab9be73 Mon Sep 17 00:00:00 2001 From: Cal Wing <20716204+calw20@users.noreply.github.com> Date: Wed, 16 Oct 2024 20:57:25 +1000 Subject: [PATCH] add basic tunnel info --- canny_shock_finder.py | 8 ++--- data/x2s5823/_info.yaml | 1 - main.py | 66 ++++++++++++++++++++++------------------- pcb-info.yaml | 34 +++++++++++++++++++++ 4 files changed, 73 insertions(+), 36 deletions(-) create mode 100644 pcb-info.yaml diff --git a/canny_shock_finder.py b/canny_shock_finder.py index 2d78492..5d96d05 100644 --- a/canny_shock_finder.py +++ b/canny_shock_finder.py @@ -465,10 +465,10 @@ def canny_shock_finder(time_list, pressure_list, sigma = 4, derivative_threshold ax.tick_params(which='both', direction='out') ax.yaxis.set_ticks_position('left') ax.xaxis.set_ticks_position('bottom') - for tick in ax.yaxis.get_major_ticks(): - tick.label.set_fontsize(font_sizes['tick_size']) - for tick in ax.xaxis.get_major_ticks(): - tick.label.set_fontsize(font_sizes['tick_size']) + #for tick in ax.yaxis.get_major_ticks(): + # tick.label.set_fontsize(font_sizes['tick_size']) + #for tick in ax.xaxis.get_major_ticks(): + # tick.label.set_fontsize(font_sizes['tick_size']) ax.legend(prop={'size':font_sizes['legend_text_size']}, loc = 'best') diff --git a/data/x2s5823/_info.yaml b/data/x2s5823/_info.yaml index 86721ed..6e45217 100644 --- a/data/x2s5823/_info.yaml +++ b/data/x2s5823/_info.yaml @@ -12,7 +12,6 @@ shot-info: config: "x2s5823.config" info: "x2s5823.txt" - probe-info: type: "Fat" locations: # In order of pulse diff --git a/main.py b/main.py index 8f39694..15ec95e 100644 --- a/main.py +++ b/main.py @@ -22,6 +22,10 @@ for folder in folders: # Load Data DATA_PATH = "./data" 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 = [ "x2s5823", @@ -85,46 +89,46 @@ for dp in data_to_load: loaded_data = list(data.keys()) 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): - 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 - + # 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.timedelta64(trigger_info["alignment-offset"], 'ns') - scope_time += np.timedelta64(trigger_info["delay"], 'us') + #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["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_time = 0 - x2_timesteps = np.array([0 for _ in x2_time]) + # start_time = 0 + # x2_timesteps = np.array([0 for _ in x2_time]) - for i, dt in enumerate(x2_time): - dt = dt.astype("int") - if i == 0: - x2_timesteps[i] = start_time + dt # should be 0 - else: - x2_timesteps[i] = x2_timesteps[i-1] + dt + # for i, dt in enumerate(x2_time): + # dt = dt.astype("int") + # if i == 0: + # x2_timesteps[i] = start_time + dt # should be 0 + # else: + # 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): - x2_time, scope_time, _ = process_data(gData) + x2_time, scope_time = process_data(gData) graphData = { "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 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 pltKeyClose() diff --git a/pcb-info.yaml b/pcb-info.yaml new file mode 100644 index 0000000..6ffcddc --- /dev/null +++ b/pcb-info.yaml @@ -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