Add canny args to _info.yaml
This commit is contained in:
parent
ba1136b0ea
commit
bdf25d5736
@ -12,6 +12,11 @@ shot-info:
|
|||||||
config: "x2s5823.config"
|
config: "x2s5823.config"
|
||||||
info: "x2s5823.txt"
|
info: "x2s5823.txt"
|
||||||
|
|
||||||
|
# Canny Args
|
||||||
|
canny-args:
|
||||||
|
- sigma: 2
|
||||||
|
post_pres: 0.03
|
||||||
|
|
||||||
pcb-refs:
|
pcb-refs:
|
||||||
- "st1"
|
- "st1"
|
||||||
- "st3"
|
- "st3"
|
||||||
|
@ -12,6 +12,11 @@ shot-info:
|
|||||||
config: "x2s5824.config"
|
config: "x2s5824.config"
|
||||||
info: "x2s5824.txt"
|
info: "x2s5824.txt"
|
||||||
|
|
||||||
|
# Canny Args
|
||||||
|
canny-args:
|
||||||
|
- sigma: 2
|
||||||
|
post_pres: 0.03
|
||||||
|
|
||||||
pcb-refs:
|
pcb-refs:
|
||||||
- "st1"
|
- "st1"
|
||||||
- "st3"
|
- "st3"
|
||||||
|
@ -12,6 +12,14 @@ shot-info:
|
|||||||
config: "x2s5827.config"
|
config: "x2s5827.config"
|
||||||
info: "x2s5827.txt"
|
info: "x2s5827.txt"
|
||||||
|
|
||||||
|
# Canny Args
|
||||||
|
canny-args:
|
||||||
|
- sigma: 2
|
||||||
|
post_pres: 0.03
|
||||||
|
|
||||||
|
- sigma: 0.75
|
||||||
|
post_pres: 0.1
|
||||||
|
|
||||||
pcb-refs:
|
pcb-refs:
|
||||||
- "st1"
|
- "st1"
|
||||||
|
|
||||||
|
@ -12,6 +12,14 @@ shot-info:
|
|||||||
config: "x2s5829.config"
|
config: "x2s5829.config"
|
||||||
info: "x2s5829.txt"
|
info: "x2s5829.txt"
|
||||||
|
|
||||||
|
# Canny Args
|
||||||
|
canny-args:
|
||||||
|
- sigma: 2
|
||||||
|
post_pres: 0.03
|
||||||
|
|
||||||
|
- sigma: 1
|
||||||
|
post_pres: 0.2
|
||||||
|
|
||||||
pcb-refs:
|
pcb-refs:
|
||||||
- "st1"
|
- "st1"
|
||||||
|
|
||||||
|
67
main.py
67
main.py
@ -30,9 +30,9 @@ with open(TUNNEL_INFO_FILE, 'r') as file:
|
|||||||
TUNNEL_INFO = yaml.safe_load(file)
|
TUNNEL_INFO = yaml.safe_load(file)
|
||||||
|
|
||||||
data_to_load = [
|
data_to_load = [
|
||||||
#"x2s5823",
|
"x2s5823",
|
||||||
#"x2s5824",
|
"x2s5824",
|
||||||
#"x2s5827",
|
"x2s5827",
|
||||||
"x2s5829",
|
"x2s5829",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -104,7 +104,8 @@ def load_data(data_path: str, data={}) -> dict:
|
|||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"x2": {} # Only pop channels with a voltage scale in ./tunnel-info.yaml
|
"x2": {} # Only pop channels with a voltage scale in ./tunnel-info.yaml
|
||||||
}
|
},
|
||||||
|
"shock-speed": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
# === Process the data ===
|
# === Process the data ===
|
||||||
@ -189,37 +190,36 @@ def load_data(data_path: str, data={}) -> dict:
|
|||||||
probeCh1 = data[x2_shot]["data"]["scope"][1]
|
probeCh1 = data[x2_shot]["data"]["scope"][1]
|
||||||
probeCh2 = data[x2_shot]["data"]["scope"][2]
|
probeCh2 = data[x2_shot]["data"]["scope"][2]
|
||||||
|
|
||||||
#[HACK] For detection
|
# Get the canny-args
|
||||||
|
cArgs = dataInfo["canny-args"]
|
||||||
|
doCannyPlot = False
|
||||||
|
doCannyPlot = i > 0 and x2_shot == "x2s5827"
|
||||||
|
if i in range(len(cArgs)):
|
||||||
|
sigma = cArgs[i]["sigma"]
|
||||||
|
post_pres = cArgs[i]["post_pres"]
|
||||||
|
else:
|
||||||
|
sigma = cArgs[-1]["sigma"]
|
||||||
|
post_pres = cArgs[-1]["post_pres"]
|
||||||
|
|
||||||
|
# If this _isn't_ the first probe then apply a time offset
|
||||||
if i > 0:
|
if i > 0:
|
||||||
privPoint = dataInfo["probe-info"]["locations"][i-1]
|
privPoint = dataInfo["probe-info"]["locations"][i-1]
|
||||||
time_offset = data[x2_shot]["shock-point"][f"{privPoint}-g1"][1] + CANNY_TIME_OFFSET
|
time_offset = data[x2_shot]["shock-point"][f"{privPoint}-g1"][1] + CANNY_TIME_OFFSET
|
||||||
post_pres = 0.2
|
else:
|
||||||
sigma = 1
|
|
||||||
doPlot = True
|
|
||||||
else: # These work for the first probe int he chain
|
|
||||||
time_offset = None
|
time_offset = None
|
||||||
post_pres = 0.03
|
|
||||||
sigma = 2
|
|
||||||
doPlot = False
|
|
||||||
|
|
||||||
shock_point = np.where(probeCh1 >= 0.3)[0]
|
# Find G1 Shock Time
|
||||||
first_value = scope_time[shock_point]
|
first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh1, sigma=sigma, post_suppression_threshold=post_pres, 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_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
|
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
|
data[x2_shot]["shock-point"][f"{probe}-g1"] = shock_point, first_value
|
||||||
|
|
||||||
|
# Do the same for G2
|
||||||
#[HACK] For detection
|
|
||||||
if i > 0:
|
if i > 0:
|
||||||
time_offset = data[x2_shot]["shock-point"][f"{privPoint}-g2"][1] + CANNY_TIME_OFFSET
|
time_offset = data[x2_shot]["shock-point"][f"{privPoint}-g2"][1] + CANNY_TIME_OFFSET
|
||||||
|
|
||||||
|
# Find G2 Shock Time
|
||||||
shock_point = np.where(probeCh2 >= 0.3)[0] # + offset
|
first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh2, sigma=sigma, post_suppression_threshold=post_pres, plot=doCannyPlot, start_time=time_offset, print_func=None)
|
||||||
first_value = scope_time[shock_point]
|
|
||||||
|
|
||||||
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
|
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
|
data[x2_shot]["shock-point"][f"{probe}-g2"] = shock_point, first_value
|
||||||
|
|
||||||
@ -233,6 +233,7 @@ def load_data(data_path: str, data={}) -> dict:
|
|||||||
probe_velocity = c2c_dist / abs(g2_time - g1_time) # m/s
|
probe_velocity = c2c_dist / abs(g2_time - g1_time) # m/s
|
||||||
|
|
||||||
print(f"{probe} Measured a shock speed of {probe_velocity:.2f} m/s ({probe_velocity/1000:.2f} km/s)")
|
print(f"{probe} Measured a shock speed of {probe_velocity:.2f} m/s ({probe_velocity/1000:.2f} km/s)")
|
||||||
|
data[x2_shot]["shock-speed"][probe] = probe_velocity # m/s
|
||||||
|
|
||||||
if len(dataInfo["probe-info"]["locations"]) > 1:
|
if len(dataInfo["probe-info"]["locations"]) > 1:
|
||||||
for i in range(len(dataInfo["probe-info"]["locations"]) - 1):
|
for i in range(len(dataInfo["probe-info"]["locations"]) - 1):
|
||||||
@ -250,6 +251,9 @@ def load_data(data_path: str, data={}) -> dict:
|
|||||||
|
|
||||||
print(f"{probe_locs[i]}-{probe_locs[i + 1]} - G1 - Measured a shock speed of {p2p_1:.2f} m/s ({p2p_1/1000:.2f} km/s)")
|
print(f"{probe_locs[i]}-{probe_locs[i + 1]} - G1 - Measured a shock speed of {p2p_1:.2f} m/s ({p2p_1/1000:.2f} km/s)")
|
||||||
print(f"{probe_locs[i]}-{probe_locs[i + 1]} - G2 - Measured a shock speed of {p2p_2:.2f} m/s ({p2p_2/1000:.2f} km/s)")
|
print(f"{probe_locs[i]}-{probe_locs[i + 1]} - G2 - Measured a shock speed of {p2p_2:.2f} m/s ({p2p_2/1000:.2f} km/s)")
|
||||||
|
data[x2_shot]["shock-speed"][f"{probe_locs[i]}-{probe_locs[i + 1]}-g1"] = p2p_1
|
||||||
|
data[x2_shot]["shock-speed"][f"{probe_locs[i]}-{probe_locs[i + 1]}-g2"] = p2p_2
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Return the data & the successfully loaded data keys
|
# Return the data & the successfully loaded data keys
|
||||||
@ -272,6 +276,8 @@ def genGraph(gData: dict, showPlot: bool = True):
|
|||||||
"xLabel": "Time ($\\mu$s)",
|
"xLabel": "Time ($\\mu$s)",
|
||||||
"yLabel": "Voltage Reading (V)",
|
"yLabel": "Voltage Reading (V)",
|
||||||
"grid": True,
|
"grid": True,
|
||||||
|
"figSize": (8,6.5),
|
||||||
|
"ledgLoc": 'upper left',
|
||||||
"plots": []
|
"plots": []
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,9 +327,20 @@ def genGraph(gData: dict, showPlot: bool = True):
|
|||||||
lims.append(gData["shock-point"][f"{probe}-g2"][1])
|
lims.append(gData["shock-point"][f"{probe}-g2"][1])
|
||||||
lims.append(gData["shock-point"][f"{probe}-g1"][1])
|
lims.append(gData["shock-point"][f"{probe}-g1"][1])
|
||||||
|
|
||||||
|
probeText = ""
|
||||||
|
for shock_speed_loc in gData["shock-speed"]:
|
||||||
|
probeText += f"\n{shock_speed_loc} - {gData["shock-speed"][shock_speed_loc]/1000:.2f} km/s"
|
||||||
|
|
||||||
|
graphData["plots"].append({
|
||||||
|
"type": "text",
|
||||||
|
"text": f"Measured Shock Speeds{probeText}",
|
||||||
|
"align": ("top", "right"),
|
||||||
|
"x": 0.94, "y": 0.94
|
||||||
|
})
|
||||||
|
|
||||||
if len(lims) > 1:
|
if len(lims) > 1:
|
||||||
OFFSET = 10
|
OFFSET = 10
|
||||||
#graphData["xLim"] = (float(min(lims) - OFFSET), float(max(lims) + OFFSET))
|
graphData["xLim"] = (float(min(lims) - OFFSET), float(max(lims) + OFFSET))
|
||||||
|
|
||||||
|
|
||||||
makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath="./images/{0}.png")
|
makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath="./images/{0}.png")
|
||||||
@ -332,7 +349,7 @@ def genGraph(gData: dict, showPlot: bool = True):
|
|||||||
|
|
||||||
print("Graphing Data")
|
print("Graphing Data")
|
||||||
for shot in loaded_data:
|
for shot in loaded_data:
|
||||||
#if shot != loaded_data[-1]: continue
|
if shot != loaded_data[-2]: continue
|
||||||
genGraph(data[shot], showPlot=False)
|
genGraph(data[shot], showPlot=False)
|
||||||
|
|
||||||
# This forces matplotlib to hang until I tell it to close all windows
|
# This forces matplotlib to hang until I tell it to close all windows
|
||||||
|
@ -378,8 +378,8 @@ def makeGraph(graphData, showPlot=True, doProgramBlock=True, figSavePath=None, h
|
|||||||
}
|
}
|
||||||
|
|
||||||
align = (
|
align = (
|
||||||
getSafeValue("valign", None),
|
getSafeValue("valign", "center"),
|
||||||
getSafeValue("halign", None),
|
getSafeValue("halign", "center"),
|
||||||
)
|
)
|
||||||
align = getSafeValue("align", align)
|
align = getSafeValue("align", align)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user