Compare commits
No commits in common. "bdf25d573681e6049eb6eaf708de3281770744a3" and "a04be0889a3c7cd548cdc417ef3b553f87d48ee7" have entirely different histories.
bdf25d5736
...
a04be0889a
@ -12,11 +12,6 @@ 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,11 +12,6 @@ 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,14 +12,6 @@ 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,14 +12,6 @@ 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"
|
||||||
|
|
||||||
|
94
main.py
94
main.py
@ -24,25 +24,27 @@ DATA_PATH = "./data"
|
|||||||
DATA_INFO = "_info.yaml"
|
DATA_INFO = "_info.yaml"
|
||||||
TUNNEL_INFO_FILE = "./tunnel-info.yaml"
|
TUNNEL_INFO_FILE = "./tunnel-info.yaml"
|
||||||
SAMPLES_TO_AVG = 500
|
SAMPLES_TO_AVG = 500
|
||||||
CANNY_TIME_OFFSET = 50 #us
|
|
||||||
|
|
||||||
with open(TUNNEL_INFO_FILE, 'r') as file:
|
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",
|
||||||
]
|
]
|
||||||
|
|
||||||
# ==== Data Loading & Processing ====
|
# ==== Data Loading & Processing ====
|
||||||
def load_data(data_path: str, data={}) -> dict:
|
def load_data(data_to_load: list[str]) -> dict:
|
||||||
|
data = {}
|
||||||
|
for dp in data_to_load:
|
||||||
|
data_path = f"{DATA_PATH}/{dp}/"
|
||||||
data_info_path = data_path + DATA_INFO
|
data_info_path = data_path + DATA_INFO
|
||||||
if not os.path.exists(data_info_path):
|
if not os.path.exists(data_info_path):
|
||||||
print(f"[ERR] Could not find data info file: '{data_info_path}'")
|
print(f"[ERR] Could not find data info file: '{data_info_path}'")
|
||||||
print(f"[WARN] Not Loading Data '{data_path}'")
|
print(f"[WARN] Not Loading Data '{dp}'")
|
||||||
return None
|
continue
|
||||||
|
|
||||||
# Load Shot Data Info YAML File (Cal)
|
# Load Shot Data Info YAML File (Cal)
|
||||||
with open(data_info_path, 'r') as file:
|
with open(data_info_path, 'r') as file:
|
||||||
@ -104,8 +106,7 @@ 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 ===
|
||||||
@ -190,36 +191,38 @@ 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]
|
||||||
|
|
||||||
# Get the canny-args
|
#[HACK] For detection
|
||||||
cArgs = dataInfo["canny-args"]
|
TIME_OFFSET = 50 #us
|
||||||
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] + TIME_OFFSET
|
||||||
else:
|
post_pres = 0.03
|
||||||
|
sigma = 7
|
||||||
|
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
|
||||||
|
|
||||||
# Find G1 Shock Time
|
shock_point = np.where(probeCh1 >= 0.3)[0]
|
||||||
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 = scope_time[shock_point]
|
||||||
|
|
||||||
|
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
|
|
||||||
if i > 0:
|
|
||||||
time_offset = data[x2_shot]["shock-point"][f"{privPoint}-g2"][1] + CANNY_TIME_OFFSET
|
|
||||||
|
|
||||||
# Find G2 Shock Time
|
#[HACK] For detection
|
||||||
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)
|
if i > 0:
|
||||||
|
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, 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,7 +236,6 @@ 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):
|
||||||
@ -251,21 +253,12 @@ 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
|
||||||
return data #, tuple(data.keys())
|
return data, tuple(data.keys())
|
||||||
|
|
||||||
data = {}
|
|
||||||
for dp in data_to_load:
|
|
||||||
pdp = f"{DATA_PATH}/{dp}/"
|
|
||||||
load_data(pdp, data)
|
|
||||||
|
|
||||||
loaded_data = tuple(data.keys())
|
|
||||||
|
|
||||||
|
data, loaded_data = load_data(data_to_load)
|
||||||
print("Loaded Data")
|
print("Loaded Data")
|
||||||
|
|
||||||
|
|
||||||
@ -276,8 +269,6 @@ 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": []
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,20 +318,9 @@ 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")
|
||||||
@ -349,7 +329,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[-2]: continue
|
#if shot != loaded_data[-1]: 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", "center"),
|
getSafeValue("valign", None),
|
||||||
getSafeValue("halign", "center"),
|
getSafeValue("halign", None),
|
||||||
)
|
)
|
||||||
align = getSafeValue("align", align)
|
align = getSafeValue("align", align)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user