diff --git a/main.py b/main.py index 4b5f93b..30d3e78 100644 --- a/main.py +++ b/main.py @@ -186,7 +186,7 @@ def load_data(data_to_load: list[str]) -> dict: data[x2_shot]["shock-point"][ref] = shock_point, first_value - for probe in dataInfo["probe-info"]["locations"]: + for i, probe in enumerate(dataInfo["probe-info"]["locations"]): probeCh1 = data[x2_shot]["data"]["scope"][1] probeCh2 = data[x2_shot]["data"]["scope"][2] @@ -194,7 +194,13 @@ def load_data(data_to_load: list[str]) -> dict: #shock_point = np.where(scope_time >= first_value)[0][0] # [BUG] Seems to give n+1 #[HACK] For detection - shock_point = np.where(probeCh1 >= 0.3)[0][0] + if i > 0: + privPoint = dataInfo["probe-info"]["locations"][i-1] + offset = data[x2_shot]["shock-point"][f"{privPoint}-g1"][0][i-1] + 50 + 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 @@ -202,7 +208,12 @@ def load_data(data_to_load: list[str]) -> dict: #shock_point = np.where(scope_time >= first_value)[0][0] # [BUG] Seems to give n+1 #[HACK] For detection - shock_point = np.where(probeCh2 >= 0.3)[0][0] + if i > 0: + privPoint = dataInfo["probe-info"]["locations"][i-1] + offset = data[x2_shot]["shock-point"][f"{privPoint}-g2"][0][i-1] + 50 + else: + offset = 0 + shock_point = np.where(probeCh2[offset:] >= 0.3)[0] + offset first_value = scope_time[shock_point] data[x2_shot]["shock-point"][f"{probe}-g2"] = shock_point, first_value @@ -235,7 +246,7 @@ def genGraph(gData: dict, showPlot: bool = True): graphData["plots"].append({ "type": "axvLine", "x": gData["shock-point"][label][1], - "label": f"{label} - Shock Point {gData["shock-point"][label][1]}$\\mu$s", + "label": f"{label} - Shock Point {gData["shock-point"][label][1]:.2f}$\\mu$s", "colour": "gray", "args":{"zorder":2, "linestyle":"--"} }) @@ -248,19 +259,19 @@ def genGraph(gData: dict, showPlot: bool = True): "label": d }) - for probe in gData["info"]["probe-info"]["locations"]: + for i, probe in enumerate(gData["info"]["probe-info"]["locations"]): graphData["plots"].append({ "type": "axvLine", - "x": gData["shock-point"][f"{probe}-g1"][1], - "label": f"{label}-G1 - Shock Point {gData["shock-point"][f"{probe}-g1"][1]}$\\mu$s", - "colour": "gray", + "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", + #"colour": "gray", "args":{"zorder":2, "linestyle":"--"} }) graphData["plots"].append({ "type": "axvLine", - "x": gData["shock-point"][f"{probe}-g2"][1], - "label": f"{label}-G2 - Shock Point {gData["shock-point"][f"{probe}-g2"][1]}$\\mu$s", - "colour": "gray", + "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", + #"colour": "gray", "args":{"zorder":2, "linestyle":"--"} }) @@ -269,14 +280,10 @@ def genGraph(gData: dict, showPlot: bool = True): print("Graphing Data") -genGraph(data[loaded_data[0]], showPlot=False) -genGraph(data[loaded_data[1]], showPlot=False) +#genGraph(data[loaded_data[0]], showPlot=False) +#genGraph(data[loaded_data[1]], showPlot=False) genGraph(data[loaded_data[2]], showPlot=False) -from pprint import pprint - -pprint(data[loaded_data[0]]) - #x2_out = canny_shock_finder(x2_time, (gData["raw-data"]["x2"][16][:] - gData["raw-data"]["x2"][16][0]))