From 7d6b3403f54ff7b9151c244852282a1de9b77e8e Mon Sep 17 00:00:00 2001 From: Cal Wing <20716204+calw20@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:20:57 +1000 Subject: [PATCH] Make nice canning graph --- canny_shock_finder.py | 3 +++ main.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/canny_shock_finder.py b/canny_shock_finder.py index b8298bb..f6e4841 100644 --- a/canny_shock_finder.py +++ b/canny_shock_finder.py @@ -360,6 +360,9 @@ def canny_shock_finder(time_list, pressure_list, sigma = 4, derivative_threshold data_ax.plot(time_list*plot_time_scale, pressure_list, '-o', label = 'original data') + data_ax.grid(True) + convolution_ax.grid(True) + convolution_ax.plot(time_list*plot_time_scale, first_order_data, '-o', label='first order gaussian (sigma = {0})'.format(sigma)) convolution_ax.plot(time_list*plot_time_scale, second_order_data, '-o', label='second order gaussian (sigma = {0})'.format(sigma)) convolution_ax.plot(time_list*plot_time_scale, suppressed_data, '-o', label='first order with non-max suppression') diff --git a/main.py b/main.py index 42a00a0..41584e5 100644 --- a/main.py +++ b/main.py @@ -319,7 +319,12 @@ def load_data(data_path: str, data={}) -> dict: for i, probe in enumerate(dataInfo["probe-info"]["locations"]): # Get the canny-args cArgs = dataInfo["canny-args"] - doCannyPlot = False + doCannyPlot = x2_shot == "x2s5829" and probe == "st2" and False + plotValues = { + "plot_title": f"Canny Shock Finding Result for {x2_shot} - ST1 Gauge 1", + "plot_time_unit": "$\\mu$s", + "y_label": "Voltage Reading (V)", + } if i in range(len(cArgs)): sigma = cArgs[i]["sigma"] post_sup_thresh = cArgs[i]["post_pres"] @@ -336,7 +341,7 @@ def load_data(data_path: str, data={}) -> dict: # Find G1 Shock Time if 1 in dataInfo["probe-info"]["gauges"]: - first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh1, sigma=sigma, post_suppression_threshold=post_sup_thresh, plot=doCannyPlot, start_time=time_offset, print_func=None) + first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh1, sigma=sigma, post_suppression_threshold=post_sup_thresh, plot=doCannyPlot, start_time=time_offset, print_func=None, **plotValues) if first_value is None: print(f"[ERROR] {x2_shot} - {probe}-g1 could not be detected using: Sigma = {sigma}, post_suppression_threshold = {post_sup_thresh}") raise ValueError(f"{probe}-g1 not detected")