try to do better canning edge
This commit is contained in:
parent
feee9efa44
commit
764c617780
51
main.py
51
main.py
@ -29,9 +29,9 @@ with open(TUNNEL_INFO_FILE, 'r') as file:
|
||||
TUNNEL_INFO = yaml.safe_load(file)
|
||||
|
||||
data_to_load = [
|
||||
"x2s5823",
|
||||
"x2s5824",
|
||||
"x2s5827",
|
||||
#"x2s5823",
|
||||
#"x2s5824",
|
||||
#"x2s5827",
|
||||
"x2s5829",
|
||||
]
|
||||
|
||||
@ -192,32 +192,38 @@ def load_data(data_to_load: list[str]) -> dict:
|
||||
probeCh2 = data[x2_shot]["data"]["scope"][2]
|
||||
|
||||
#[HACK] For detection
|
||||
TIME_OFFSET = 10 #us
|
||||
if i > 0:
|
||||
privPoint = dataInfo["probe-info"]["locations"][i-1]
|
||||
offset = data[x2_shot]["shock-point"][f"{privPoint}-g1"][0] + 150 #[i-1] + 25
|
||||
else:
|
||||
offset = 0
|
||||
time_offset = data[x2_shot]["shock-point"][f"{privPoint}-g1"][1] + TIME_OFFSET
|
||||
post_pres = 0.03
|
||||
sigma = 7
|
||||
doPlot = True
|
||||
else: # These work for the first probe int he chain
|
||||
time_offset = None
|
||||
post_pres = 0.03
|
||||
sigma = 2
|
||||
doPlot = False
|
||||
|
||||
shock_point = np.where(probeCh1[offset:] >= 0.3)[0] + offset
|
||||
shock_point = np.where(probeCh1 >= 0.3)[0]
|
||||
first_value = scope_time[shock_point]
|
||||
|
||||
first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time[offset:], probeCh1[offset:], plot=False, sigma=2, post_shock_pressure=0.02, print_func=None)
|
||||
shock_point = np.where(scope_time[offset:] >= first_value)[0][0] + offset # [BUG] Seems to give n+1
|
||||
first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh1, sigma=sigma, post_suppression_threshold=post_pres, plot=doPlot, start_time=time_offset, print_func=None)
|
||||
shock_point = np.where(scope_time >= first_value)[0][0] # [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] + 150 #[i-1] + 25
|
||||
else:
|
||||
offset = 0
|
||||
shock_point = np.where(probeCh2[offset:] >= 0.3)[0] + offset
|
||||
time_offset = data[x2_shot]["shock-point"][f"{privPoint}-g2"][1] + TIME_OFFSET
|
||||
|
||||
|
||||
shock_point = np.where(probeCh2 >= 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, print_func=None)
|
||||
shock_point = np.where(scope_time[offset:] >= first_value)[0][0] + offset # [BUG] Seems to give n+1
|
||||
first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh2, sigma=sigma, post_suppression_threshold=post_pres, plot=doPlot, start_time=time_offset, print_func=None)
|
||||
shock_point = np.where(scope_time >= first_value)[0][0] # [BUG] Seems to give n+1
|
||||
data[x2_shot]["shock-point"][f"{probe}-g2"] = shock_point, first_value
|
||||
|
||||
# Calculate Shock Speeds
|
||||
@ -265,6 +271,8 @@ def genGraph(gData: dict, showPlot: bool = True):
|
||||
"grid": True,
|
||||
"plots": []
|
||||
}
|
||||
|
||||
lims = []
|
||||
|
||||
for label in gData["info"]["pcb-refs"] + ["trigbox"]:
|
||||
graphData["plots"].append({
|
||||
@ -281,6 +289,7 @@ def genGraph(gData: dict, showPlot: bool = True):
|
||||
"colour": "gray",
|
||||
"args":{"zorder":2, "linestyle":"--"}
|
||||
})
|
||||
lims.append(gData["shock-point"][label][1]) # [TODO this but better]
|
||||
|
||||
|
||||
for label, d in [("1 [V]", "G1"),("2 [V]", "G2"), ("4 [V]", "Gauge Trigger")]:
|
||||
@ -305,6 +314,14 @@ def genGraph(gData: dict, showPlot: bool = True):
|
||||
#"colour": "gray",
|
||||
"args":{"zorder":2, "linestyle":"--"}
|
||||
})
|
||||
|
||||
lims.append(gData["shock-point"][f"{probe}-g2"][1])
|
||||
lims.append(gData["shock-point"][f"{probe}-g1"][1])
|
||||
|
||||
if len(lims) > 1:
|
||||
OFFSET = 10
|
||||
#graphData["xLim"] = (float(min(lims) - OFFSET), float(max(lims) + OFFSET))
|
||||
|
||||
|
||||
makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath="./images/{0}.png")
|
||||
|
||||
@ -312,7 +329,7 @@ def genGraph(gData: dict, showPlot: bool = True):
|
||||
|
||||
print("Graphing Data")
|
||||
for shot in loaded_data:
|
||||
if shot != loaded_data[-1]: continue
|
||||
#if shot != loaded_data[-1]: continue
|
||||
genGraph(data[shot], showPlot=False)
|
||||
|
||||
# This forces matplotlib to hang until I tell it to close all windows
|
||||
|
Loading…
x
Reference in New Issue
Block a user