diff --git a/main.py b/main.py index 30d3e78..942b831 100644 --- a/main.py +++ b/main.py @@ -189,34 +189,38 @@ def load_data(data_to_load: list[str]) -> dict: for i, probe in enumerate(dataInfo["probe-info"]["locations"]): probeCh1 = data[x2_shot]["data"]["scope"][1] probeCh2 = data[x2_shot]["data"]["scope"][2] - - #first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh1, plot=True) - #shock_point = np.where(scope_time >= first_value)[0][0] # [BUG] Seems to give n+1 - + #[HACK] For detection if i > 0: privPoint = dataInfo["probe-info"]["locations"][i-1] - offset = data[x2_shot]["shock-point"][f"{privPoint}-g1"][0][i-1] + 50 + offset = data[x2_shot]["shock-point"][f"{privPoint}-g1"][0] + 150 #[i-1] + 25 else: offset = 0 shock_point = np.where(probeCh1[offset:] >= 0.3)[0] + offset first_value = scope_time[shock_point] - data[x2_shot]["shock-point"][f"{probe}-g1"] = shock_point, first_value - #first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh2, plot=False) - #shock_point = np.where(scope_time >= first_value)[0][0] # [BUG] Seems to give n+1 - + first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time[offset:], probeCh1[offset:], plot=False, sigma=2, post_shock_pressure=0.02) + shock_point = np.where(scope_time[offset:] >= first_value)[0][0] + offset # [BUG] Seems to give n+1 + + data[x2_shot]["shock-point"][f"{probe}-g1"] = shock_point, first_value + + #[HACK] For detection if i > 0: privPoint = dataInfo["probe-info"]["locations"][i-1] - offset = data[x2_shot]["shock-point"][f"{privPoint}-g2"][0][i-1] + 50 + offset = data[x2_shot]["shock-point"][f"{privPoint}-g2"][0] + 150 #[i-1] + 25 else: offset = 0 shock_point = np.where(probeCh2[offset:] >= 0.3)[0] + offset first_value = scope_time[shock_point] + + first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time[offset:], probeCh2[offset:], plot=False, sigma=2, post_shock_pressure=0.02) + shock_point = np.where(scope_time[offset:] >= first_value)[0][0] + offset # [BUG] Seems to give n+1 data[x2_shot]["shock-point"][f"{probe}-g2"] = shock_point, first_value + + # Return the data & the successfully loaded data keys return data, tuple(data.keys()) @@ -262,15 +266,15 @@ def genGraph(gData: dict, showPlot: bool = True): for i, probe in enumerate(gData["info"]["probe-info"]["locations"]): graphData["plots"].append({ "type": "axvLine", - "x": gData["shock-point"][f"{probe}-g1"][1][i], - "label": f"{probe}-G1 - Shock Point {gData["shock-point"][f"{probe}-g1"][1][i]:.2f}$\\mu$s", + "x": gData["shock-point"][f"{probe}-g1"][1],#[i], + "label": f"{probe}-G1 - Shock Point {gData["shock-point"][f"{probe}-g1"][1]:.2f}$\\mu$s", #"colour": "gray", "args":{"zorder":2, "linestyle":"--"} }) graphData["plots"].append({ "type": "axvLine", - "x": gData["shock-point"][f"{probe}-g2"][1][i], - "label": f"{probe}-G2 - Shock Point {gData["shock-point"][f"{probe}-g2"][1][i]:.2f}$\\mu$s", + "x": gData["shock-point"][f"{probe}-g2"][1],#[i], + "label": f"{probe}-G2 - Shock Point {gData["shock-point"][f"{probe}-g2"][1]:.2f}$\\mu$s", #"colour": "gray", "args":{"zorder":2, "linestyle":"--"} })