Use all speed values
This commit is contained in:
parent
50e1ea4eae
commit
b86694e603
@ -23,25 +23,25 @@ canny-args:
|
||||
|
||||
no-graph:
|
||||
- "None"
|
||||
# - "at1"
|
||||
# - "at2"
|
||||
# - "at3"
|
||||
- "at1"
|
||||
- "at2"
|
||||
- "at3"
|
||||
|
||||
# - "at4"
|
||||
# - "at5"
|
||||
# - "at6"
|
||||
- "at4"
|
||||
- "at5"
|
||||
- "at6"
|
||||
|
||||
pcb-refs:
|
||||
#- "at1"
|
||||
#- "at2"
|
||||
#- "at3"
|
||||
#
|
||||
#- "at4"
|
||||
#- "at5"
|
||||
#- "at6"
|
||||
|
||||
- "st1"
|
||||
- "st3"
|
||||
|
||||
- "at1"
|
||||
- "at2"
|
||||
- "at3"
|
||||
|
||||
- "at4"
|
||||
- "at5"
|
||||
- "at6"
|
||||
|
||||
probe-info:
|
||||
type: "Thin"
|
||||
|
@ -26,24 +26,25 @@ canny-args:
|
||||
|
||||
no-graph:
|
||||
- "None"
|
||||
# - "at1"
|
||||
# - "at2"
|
||||
# - "at3"
|
||||
- "at1"
|
||||
- "at2"
|
||||
- "at3"
|
||||
|
||||
# - "at4"
|
||||
# - "at5"
|
||||
# - "at6"
|
||||
- "at4"
|
||||
- "at5"
|
||||
- "at6"
|
||||
|
||||
pcb-refs:
|
||||
#- "at1"
|
||||
#- "at2"
|
||||
#- "at3"
|
||||
#
|
||||
#- "at4"
|
||||
#- "at5"
|
||||
#- "at6"
|
||||
|
||||
- "st1"
|
||||
|
||||
- "at1"
|
||||
- "at2"
|
||||
- "at3"
|
||||
|
||||
- "at4"
|
||||
- "at5"
|
||||
- "at6"
|
||||
|
||||
|
||||
probe-info:
|
||||
type: "Thin"
|
||||
|
@ -28,24 +28,25 @@ pcb-canny:
|
||||
|
||||
no-graph:
|
||||
- "None"
|
||||
# - "at1"
|
||||
# - "at2"
|
||||
# - "at3"
|
||||
- "at1"
|
||||
- "at2"
|
||||
- "at3"
|
||||
|
||||
# - "at4"
|
||||
# - "at5"
|
||||
# - "at6"
|
||||
- "at4"
|
||||
- "at5"
|
||||
- "at6"
|
||||
|
||||
pcb-refs:
|
||||
#- "at1"
|
||||
#- "at2"
|
||||
#- "at3"
|
||||
#
|
||||
#- "at4"
|
||||
#- "at5"
|
||||
#- "at6"
|
||||
|
||||
- "st1"
|
||||
|
||||
- "at1"
|
||||
- "at2"
|
||||
- "at3"
|
||||
|
||||
- "at4"
|
||||
- "at5"
|
||||
- "at6"
|
||||
|
||||
|
||||
probe-info:
|
||||
type: "Thin"
|
||||
|
@ -35,6 +35,8 @@ no-graph:
|
||||
- "at6"
|
||||
|
||||
pcb-refs:
|
||||
- "st1"
|
||||
|
||||
- "at1"
|
||||
- "at2"
|
||||
- "at3"
|
||||
@ -43,7 +45,6 @@ pcb-refs:
|
||||
- "at5"
|
||||
- "at6"
|
||||
|
||||
- "st1"
|
||||
|
||||
probe-info:
|
||||
type: "Thin"
|
||||
|
@ -13,6 +13,10 @@ shot-info:
|
||||
config: "{0}.config"
|
||||
info: "{0}.txt"
|
||||
|
||||
pcb-canny:
|
||||
- sigma: 4
|
||||
post_pres: 0.05
|
||||
|
||||
# Canny Args
|
||||
canny-args:
|
||||
- sigma: 2
|
||||
|
@ -29,13 +29,13 @@ canny-args:
|
||||
|
||||
no-graph:
|
||||
- "None"
|
||||
# - "at1"
|
||||
# - "at2"
|
||||
# - "at3"
|
||||
- "at1"
|
||||
- "at2"
|
||||
- "at3"
|
||||
|
||||
# - "at4"
|
||||
# - "at5"
|
||||
# - "at6"
|
||||
- "at4"
|
||||
- "at5"
|
||||
- "at6"
|
||||
|
||||
pcb-refs:
|
||||
- "at1"
|
||||
|
65
main.py
65
main.py
@ -266,6 +266,8 @@ def load_data(data_path: str, data={}) -> dict:
|
||||
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
|
||||
print("="*30, x2_shot, "="*30)
|
||||
print("--", dataInfo["long_name"], "--")
|
||||
@ -278,7 +280,7 @@ def load_data(data_path: str, data={}) -> dict:
|
||||
|
||||
probe_velocity = p2p_dist / abs(p2_time - p1_time) # m/s
|
||||
print(f"{refProbe}-{dataInfo["pcb-refs"][i-1]} Measured a shock speed of {probe_velocity:.2f} m/s ({probe_velocity/1000:.2f} km/s)")
|
||||
|
||||
data[x2_shot]["shock-speed"][f"{refProbe}-{dataInfo["pcb-refs"][i-1]}"] = probe_velocity, True # Speed, Ref
|
||||
|
||||
print()
|
||||
for probe in dataInfo["probe-info"]["locations"]:
|
||||
@ -290,7 +292,7 @@ def load_data(data_path: str, data={}) -> dict:
|
||||
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)")
|
||||
data[x2_shot]["shock-speed"][probe] = probe_velocity # m/s
|
||||
data[x2_shot]["shock-speed"][probe] = probe_velocity, False # Speed, Ref # m/s
|
||||
else:
|
||||
print(f"Unable to calculate probe velocity, only have one probe: {f"{probe}-g2" if f"{probe}-g2" in data[x2_shot]["shock-point"] else f"{probe}-g1"}")
|
||||
|
||||
@ -304,16 +306,17 @@ def load_data(data_path: str, data={}) -> dict:
|
||||
p1_g1_time = data[x2_shot]["shock-point"][f"{probe_locs[i]}-g1"][1] / 1e6 # Convert to seconds
|
||||
p2_g1_time = data[x2_shot]["shock-point"][f"{probe_locs[i+1]}-g1"][1] / 1e6 # Convert to seconds
|
||||
p2p_1 = p2p / abs(p2_g1_time - p1_g1_time) # m/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)")
|
||||
data[x2_shot]["shock-speed"][f"{probe_locs[i]}-{probe_locs[i + 1]}-g2"] = p2p_2
|
||||
data[x2_shot]["shock-speed"][f"{probe_locs[i]}-{probe_locs[i + 1]}-g1"] = p2p_1, False # Speed, Ref
|
||||
|
||||
if f"{probe_locs[i]}-g2" in data[x2_shot]["shock-point"] and f"{probe_locs[i+1]}-g2" in data[x2_shot]["shock-point"]:
|
||||
p1_g2_time = data[x2_shot]["shock-point"][f"{probe_locs[i]}-g2"][1] / 1e6 # Convert to seconds
|
||||
p2_g2_time = data[x2_shot]["shock-point"][f"{probe_locs[i+1]}-g2"][1] / 1e6 # Convert to seconds
|
||||
p2p_2 = p2p / abs(p2_g2_time - p1_g2_time) # m/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, False # Speed, Ref
|
||||
print()
|
||||
|
||||
# Return the data & the successfully loaded data keys
|
||||
@ -330,7 +333,7 @@ print("Loaded Data")
|
||||
|
||||
|
||||
#[TODO] Refactor
|
||||
def genGraph(gData: dict, showPlot: bool = True):
|
||||
def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlots: bool = False):
|
||||
graphData = {
|
||||
"title": f"Shock response Time\nFor {gData['info']['long_name']}",
|
||||
"xLabel": "Time ($\\mu$s)",
|
||||
@ -344,7 +347,7 @@ def genGraph(gData: dict, showPlot: bool = True):
|
||||
lims = []
|
||||
|
||||
for label in gData["info"]["pcb-refs"]: # + ["trigbox"]:
|
||||
if label in gData["info"]["no-graph"]: continue
|
||||
if not forcePlots and label in gData["info"]["no-graph"]: continue
|
||||
graphData["plots"].append({
|
||||
"x": gData["time"]["x2"],
|
||||
"y": gData["data"]["x2"][label],
|
||||
@ -370,27 +373,32 @@ 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]:.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]:.2f}$\\mu$s",
|
||||
#"colour": "gray",
|
||||
"args":{"zorder":2, "linestyle":"--"}
|
||||
})
|
||||
if f"{probe}-g1" in gData["shock-point"]:
|
||||
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]:.2f}$\\mu$s",
|
||||
#"colour": "gray",
|
||||
"args":{"zorder":2, "linestyle":"--"}
|
||||
})
|
||||
lims.append(gData["shock-point"][f"{probe}-g1"][1])
|
||||
|
||||
lims.append(gData["shock-point"][f"{probe}-g2"][1])
|
||||
lims.append(gData["shock-point"][f"{probe}-g1"][1])
|
||||
if f"{probe}-g2" in gData["shock-point"]:
|
||||
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]:.2f}$\\mu$s",
|
||||
#"colour": "gray",
|
||||
"args":{"zorder":2, "linestyle":"--"}
|
||||
})
|
||||
|
||||
lims.append(gData["shock-point"][f"{probe}-g2"][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"
|
||||
probeText += "\n"
|
||||
#probeText += "(Reference) " if gData["shock-speed"][shock_speed_loc][1] else ""
|
||||
probeText += f"{shock_speed_loc} - {gData["shock-speed"][shock_speed_loc][0]/1000:.2f} km/s"
|
||||
|
||||
graphData["plots"].append({
|
||||
"type": "text",
|
||||
@ -399,12 +407,12 @@ def genGraph(gData: dict, showPlot: bool = True):
|
||||
"x": 0.94, "y": 0.94
|
||||
})
|
||||
|
||||
#if len(lims) > 1:
|
||||
# OFFSET = 10
|
||||
# graphData["xLim"] = (float(min(lims) - OFFSET), float(max(lims) + OFFSET))
|
||||
if doLimits and 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")
|
||||
makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath=f"./images/{{0}}{"-noLims" if not doLimits else ""}.png")
|
||||
|
||||
|
||||
|
||||
@ -412,6 +420,7 @@ print("Graphing Data")
|
||||
for shot in loaded_data:
|
||||
#if shot != loaded_data[-2]: continue
|
||||
genGraph(data[shot], showPlot=False)
|
||||
genGraph(data[shot], showPlot=False, doLimits=False, forcePlots=True)
|
||||
|
||||
# This forces matplotlib to hang until I tell it to close all windows
|
||||
pltKeyClose()
|
||||
|
Loading…
x
Reference in New Issue
Block a user