Finlise Graphs?
This commit is contained in:
parent
578378f23e
commit
0921e27df6
@ -23,22 +23,22 @@ canny-args:
|
|||||||
|
|
||||||
no-graph:
|
no-graph:
|
||||||
- "None"
|
- "None"
|
||||||
# - "at1"
|
- "at1"
|
||||||
# - "at2"
|
- "at2"
|
||||||
# - "at3"
|
- "at3"
|
||||||
|
|
||||||
# - "at4"
|
- "at4"
|
||||||
# - "at5"
|
- "at5"
|
||||||
# - "at6"
|
- "at6"
|
||||||
|
|
||||||
pcb-refs:
|
pcb-refs:
|
||||||
#- "at1"
|
- "at1"
|
||||||
#- "at2"
|
- "at2"
|
||||||
#- "at3"
|
- "at3"
|
||||||
#
|
|
||||||
#- "at4"
|
- "at4"
|
||||||
#- "at5"
|
- "at5"
|
||||||
#- "at6"
|
- "at6"
|
||||||
|
|
||||||
- "st1"
|
- "st1"
|
||||||
- "st3"
|
- "st3"
|
||||||
@ -49,7 +49,7 @@ probe-info:
|
|||||||
c2c: 5.6 # mm
|
c2c: 5.6 # mm
|
||||||
gauge-diam: 3.05 # mm
|
gauge-diam: 3.05 # mm
|
||||||
gauge-c2c: 4 #mm
|
gauge-c2c: 4 #mm
|
||||||
dist-uncert: 2 #mm
|
dist-uncert: 3.05 #mm
|
||||||
|
|
||||||
gauges:
|
gauges:
|
||||||
- 1
|
- 1
|
||||||
@ -61,7 +61,7 @@ probe-info:
|
|||||||
- type: "scope"
|
- type: "scope"
|
||||||
config: "eProbe-Scope.txt"
|
config: "eProbe-Scope.txt"
|
||||||
data: "eProbe-Scope.csv"
|
data: "eProbe-Scope.csv"
|
||||||
time-uncert: 0 # s
|
time-uncert: 0.00000001428571428571 # s
|
||||||
|
|
||||||
trigger: # Redundant?
|
trigger: # Redundant?
|
||||||
type: "channel"
|
type: "channel"
|
||||||
|
@ -49,7 +49,7 @@ probe-info:
|
|||||||
c2c: 5.6 # mm
|
c2c: 5.6 # mm
|
||||||
gauge-diam: 0.8 # mm
|
gauge-diam: 0.8 # mm
|
||||||
gauge-c2c: 1.8 #mm
|
gauge-c2c: 1.8 #mm
|
||||||
dist-uncert: 0.025 #mm
|
dist-uncert: 0.8 #mm
|
||||||
|
|
||||||
gauges:
|
gauges:
|
||||||
- 1
|
- 1
|
||||||
@ -62,7 +62,7 @@ probe-info:
|
|||||||
- type: "scope"
|
- type: "scope"
|
||||||
config: "eProbe-Scope.txt"
|
config: "eProbe-Scope.txt"
|
||||||
data: "eProbe-Scope.csv"
|
data: "eProbe-Scope.csv"
|
||||||
time-uncert: 0 # s
|
time-uncert: 0.00000001428571428571 # s
|
||||||
|
|
||||||
trigger: # Redundant?
|
trigger: # Redundant?
|
||||||
type: "channel"
|
type: "channel"
|
||||||
|
@ -52,7 +52,7 @@ probe-info:
|
|||||||
c2c: 5.6 # mm
|
c2c: 5.6 # mm
|
||||||
gauge-diam: 0.8 # mm
|
gauge-diam: 0.8 # mm
|
||||||
gauge-c2c: 1.8 #mm
|
gauge-c2c: 1.8 #mm
|
||||||
dist-uncert: 0.025 #mm
|
dist-uncert: 0.8 #mm
|
||||||
|
|
||||||
gauges:
|
gauges:
|
||||||
- 1
|
- 1
|
||||||
@ -65,7 +65,7 @@ probe-info:
|
|||||||
- type: "scope"
|
- type: "scope"
|
||||||
config: "eProbe-Scope.txt"
|
config: "eProbe-Scope.txt"
|
||||||
data: "eProbe-Scope.csv"
|
data: "eProbe-Scope.csv"
|
||||||
time-uncert: 0 # s
|
time-uncert: 0.00000001428571428571 # s
|
||||||
|
|
||||||
trigger: # Redundant?
|
trigger: # Redundant?
|
||||||
type: "channel"
|
type: "channel"
|
||||||
|
@ -54,7 +54,7 @@ probe-info:
|
|||||||
c2c: 5.6 # mm
|
c2c: 5.6 # mm
|
||||||
gauge-diam: 0.8 # mm
|
gauge-diam: 0.8 # mm
|
||||||
gauge-c2c: 1.8 #mm
|
gauge-c2c: 1.8 #mm
|
||||||
dist-uncert: 0.025 #mm
|
dist-uncert: 0.8 #mm
|
||||||
|
|
||||||
gauges:
|
gauges:
|
||||||
- 1
|
- 1
|
||||||
@ -67,7 +67,7 @@ probe-info:
|
|||||||
- type: "scope"
|
- type: "scope"
|
||||||
config: "eProbe-Scope.txt"
|
config: "eProbe-Scope.txt"
|
||||||
data: "eProbe-Scope.csv"
|
data: "eProbe-Scope.csv"
|
||||||
time-uncert: 0 # s
|
time-uncert: 0.00000001428571428571 # s
|
||||||
|
|
||||||
trigger: # Redundant?
|
trigger: # Redundant?
|
||||||
type: "channel"
|
type: "channel"
|
||||||
|
@ -52,7 +52,7 @@ probe-info:
|
|||||||
c2c: 5.6 # mm
|
c2c: 5.6 # mm
|
||||||
gauge-diam: 0.8 # mm
|
gauge-diam: 0.8 # mm
|
||||||
gauge-c2c: 1.8 #mm
|
gauge-c2c: 1.8 #mm
|
||||||
dist-uncert: 0.025 #mm
|
dist-uncert: 0.8 #mm
|
||||||
|
|
||||||
gauges:
|
gauges:
|
||||||
- 1
|
- 1
|
||||||
@ -65,7 +65,7 @@ probe-info:
|
|||||||
- type: "scope"
|
- type: "scope"
|
||||||
config: "eProbe-Scope.txt"
|
config: "eProbe-Scope.txt"
|
||||||
data: "eProbe-Scope.csv"
|
data: "eProbe-Scope.csv"
|
||||||
time-uncert: 0 # s
|
time-uncert: 0.00000001428571428571 # s
|
||||||
|
|
||||||
trigger: # Redundant?
|
trigger: # Redundant?
|
||||||
type: "channel"
|
type: "channel"
|
||||||
|
@ -55,13 +55,13 @@ probe-info:
|
|||||||
c2c: 5.6 # mm
|
c2c: 5.6 # mm
|
||||||
gauge-diam: 0.8 # mm
|
gauge-diam: 0.8 # mm
|
||||||
gauge-c2c: 1.8 #mm
|
gauge-c2c: 1.8 #mm
|
||||||
dist-uncert: 0.025 #mm
|
dist-uncert: 0.8 #mm
|
||||||
|
|
||||||
data-records:
|
data-records:
|
||||||
- type: "scope"
|
- type: "scope"
|
||||||
config: "eProbe-Scope.txt"
|
config: "eProbe-Scope.txt"
|
||||||
data: "eProbe-Scope.csv"
|
data: "eProbe-Scope.csv"
|
||||||
time-uncert: 0 # s
|
time-uncert: 0.00000001428571428571 # s
|
||||||
|
|
||||||
trigger: # Redundant?
|
trigger: # Redundant?
|
||||||
type: "channel"
|
type: "channel"
|
||||||
|
@ -58,13 +58,13 @@ probe-info:
|
|||||||
c2c: 5.6 # mm
|
c2c: 5.6 # mm
|
||||||
gauge-diam: 0.8 # mm
|
gauge-diam: 0.8 # mm
|
||||||
gauge-c2c: 1.8 #mm
|
gauge-c2c: 1.8 #mm
|
||||||
dist-uncert: 0.025 #mm
|
dist-uncert: 0.8 #mm
|
||||||
|
|
||||||
data-records:
|
data-records:
|
||||||
- type: "scope"
|
- type: "scope"
|
||||||
config: "eProbe-Scope.txt"
|
config: "eProbe-Scope.txt"
|
||||||
data: "eProbe-Scope.csv"
|
data: "eProbe-Scope.csv"
|
||||||
time-uncert: 0 # s
|
time-uncert: 0.00000001428571428571 # s
|
||||||
|
|
||||||
trigger: # Redundant?
|
trigger: # Redundant?
|
||||||
type: "channel"
|
type: "channel"
|
||||||
|
53
main.py
53
main.py
@ -294,18 +294,18 @@ def load_data(data_path: str, data={}) -> dict:
|
|||||||
p1_time = data[x2_shot]["shock-point"][refProbe][1] / 1e6 # Convert to seconds
|
p1_time = data[x2_shot]["shock-point"][refProbe][1] / 1e6 # Convert to seconds
|
||||||
p2_time = data[x2_shot]["shock-point"][dataInfo["pcb-refs"][i-1]][1] / 1e6 # Convert to seconds
|
p2_time = data[x2_shot]["shock-point"][dataInfo["pcb-refs"][i-1]][1] / 1e6 # Convert to seconds
|
||||||
|
|
||||||
p2p_dist = (TUNNEL_INFO["distance"][refProbe] - TUNNEL_INFO["distance"][dataInfo["pcb-refs"][i-1]]) / 1000 # convert to m
|
p2p_dist = abs(TUNNEL_INFO["distance"][refProbe] - TUNNEL_INFO["distance"][dataInfo["pcb-refs"][i-1]]) / 1000 # convert to m
|
||||||
p2p_time = abs(p2_time - p1_time)
|
p2p_time = abs(p2_time - p1_time)
|
||||||
|
|
||||||
probe_velocity = p2p_dist / p2p_time # m/s
|
probe_velocity = p2p_dist / p2p_time # m/s
|
||||||
|
|
||||||
p1_time_uncert = data[x2_shot]["shock-point"][refProbe][2] / 1e6 # Convert to seconds
|
p1_time_uncert = data[x2_shot]["shock-point"][dataInfo["pcb-refs"][i-1]][2] / 1e6 # Convert to seconds
|
||||||
p2_time_uncert = data[x2_shot]["shock-point"][dataInfo["pcb-refs"][i-1]][2] / 1e6 # Convert to seconds
|
p2_time_uncert = data[x2_shot]["shock-point"][refProbe][2] / 1e6 # Convert to seconds
|
||||||
|
|
||||||
uncert = deltaVs(probe_velocity, p2p_dist, p2p_time, (UNCERTS["probe-dist"][refProbe], UNCERTS["probe-dist"][dataInfo["pcb-refs"][i-1]]), (p1_time_uncert, p2_time_uncert, UNCERTS["time"]["x2-daq"]))
|
uncert = deltaVs(probe_velocity, p2p_dist, p2p_time, (UNCERTS["probe-dist"][refProbe], UNCERTS["probe-dist"][dataInfo["pcb-refs"][i-1]]), (p1_time_uncert, p2_time_uncert, UNCERTS["time"]["x2-daq"]))
|
||||||
|
|
||||||
print(f"{refProbe}-{dataInfo["pcb-refs"][i-1]} Measured a shock speed of {probe_velocity:.2f} +/- {uncert:.2f} m/s ({probe_velocity/1000:.2f} +/- {uncert/1000:.2f} km/s [{uncert/probe_velocity * 100 :.2f}%])")
|
print(f"{dataInfo["pcb-refs"][i-1]}-{refProbe} Measured a shock speed of {probe_velocity:.2f} +/- {uncert:.2f} m/s ({probe_velocity/1000:.2f} +/- {uncert/1000:.2f} km/s [{uncert/probe_velocity * 100 :.2f}%])")
|
||||||
data[x2_shot]["shock-speed"][f"{refProbe}-{dataInfo["pcb-refs"][i-1]}"] = probe_velocity, uncert, True # Speed, Ref
|
data[x2_shot]["shock-speed"][f"{dataInfo["pcb-refs"][i-1]}-{refProbe}"] = probe_velocity, uncert, True # Speed, Ref
|
||||||
|
|
||||||
print()
|
print()
|
||||||
for probe in dataInfo["probe-info"]["locations"]:
|
for probe in dataInfo["probe-info"]["locations"]:
|
||||||
@ -325,7 +325,7 @@ def load_data(data_path: str, data={}) -> dict:
|
|||||||
print(f"{probe} Measured a shock speed of {probe_velocity:.2f} +/- {uncert:.2f} m/s ({probe_velocity/1000:.2f} +/- {uncert/1000:.2f} km/s)")
|
print(f"{probe} Measured a shock speed of {probe_velocity:.2f} +/- {uncert:.2f} m/s ({probe_velocity/1000:.2f} +/- {uncert/1000:.2f} km/s)")
|
||||||
data[x2_shot]["shock-speed"][probe] = probe_velocity, uncert, False # Speed, Ref # m/s
|
data[x2_shot]["shock-speed"][probe] = probe_velocity, uncert, False # Speed, Ref # m/s
|
||||||
else:
|
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"}")
|
print(f"Unable to calculate probe velocity, only have one gauge: {f"{probe}-g2" if f"{probe}-g2" in data[x2_shot]["shock-point"] else f"{probe}-g1"}")
|
||||||
|
|
||||||
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):
|
||||||
@ -378,7 +378,7 @@ print("Loaded Data")
|
|||||||
|
|
||||||
|
|
||||||
#[TODO] Refactor
|
#[TODO] Refactor
|
||||||
def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlots: bool = False):
|
def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlots: bool = False, addShockInfo: bool = True):
|
||||||
graphData = {
|
graphData = {
|
||||||
"title": f"Shock response Time\nFor {gData['info']['long_name']}",
|
"title": f"Shock response Time\nFor {gData['info']['long_name']}",
|
||||||
"xLabel": "Time ($\\mu$s)",
|
"xLabel": "Time ($\\mu$s)",
|
||||||
@ -410,12 +410,12 @@ def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlo
|
|||||||
"x": gData["shock-point"][label][1],
|
"x": gData["shock-point"][label][1],
|
||||||
"label": f"{label} - Shock Point {gData["shock-point"][label][1]:.2f}$\\mu$s",
|
"label": f"{label} - Shock Point {gData["shock-point"][label][1]:.2f}$\\mu$s",
|
||||||
"colour": "gray",
|
"colour": "gray",
|
||||||
"args":{"zorder":2, "linestyle":"--"}
|
"args":{"zorder":2, "linestyle":"--", "alpha":0.5}
|
||||||
})
|
})
|
||||||
lims.append(gData["shock-point"][label][1]) # [TODO this but better]
|
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")]:
|
for label, d in [("1 [V]", "Gauge 1"),("2 [V]", "Gauge 2")]: #, ("4 [V]", "Gauge Trigger")]:
|
||||||
graphData["plots"].append({
|
graphData["plots"].append({
|
||||||
"x": gData["time"]["scope"],
|
"x": gData["time"]["scope"],
|
||||||
"y": gData["data"]["scope"][label],
|
"y": gData["data"]["scope"][label],
|
||||||
@ -427,9 +427,9 @@ def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlo
|
|||||||
graphData["plots"].append({
|
graphData["plots"].append({
|
||||||
"type": "axvLine",
|
"type": "axvLine",
|
||||||
"x": gData["shock-point"][f"{probe}-g1"][1],#[i],
|
"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",
|
"label": f"{probe}-Gauge 1 - Shock Point {gData["shock-point"][f"{probe}-g1"][1]:.2f}$\\mu$s",
|
||||||
#"colour": "gray",
|
"colour": UQC["purple"].lighten(0.5),
|
||||||
"args":{"zorder":2, "linestyle":"--"}
|
"args":{"zorder":2, "linestyle":"--", "alpha":0.5}
|
||||||
})
|
})
|
||||||
lims.append(gData["shock-point"][f"{probe}-g1"][1])
|
lims.append(gData["shock-point"][f"{probe}-g1"][1])
|
||||||
|
|
||||||
@ -437,41 +437,50 @@ def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlo
|
|||||||
graphData["plots"].append({
|
graphData["plots"].append({
|
||||||
"type": "axvLine",
|
"type": "axvLine",
|
||||||
"x": gData["shock-point"][f"{probe}-g2"][1],#[i],
|
"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",
|
"label": f"{probe}-Gauge 2 - Shock Point {gData["shock-point"][f"{probe}-g2"][1]:.2f}$\\mu$s",
|
||||||
#"colour": "gray",
|
"colour": UQC["purple"].lighten(0.5),
|
||||||
"args":{"zorder":2, "linestyle":"--"}
|
"args":{"zorder":2, "linestyle":"--", "alpha":0.5}
|
||||||
})
|
})
|
||||||
|
|
||||||
lims.append(gData["shock-point"][f"{probe}-g2"][1])
|
lims.append(gData["shock-point"][f"{probe}-g2"][1])
|
||||||
|
|
||||||
|
|
||||||
|
if addShockInfo:
|
||||||
probeText = ""
|
probeText = ""
|
||||||
|
flag = False
|
||||||
for shock_speed_loc in gData["shock-speed"]:
|
for shock_speed_loc in gData["shock-speed"]:
|
||||||
|
if not flag and not gData["shock-speed"][shock_speed_loc][2]:
|
||||||
|
flag = True
|
||||||
|
probeText += "\n" + "-"*50
|
||||||
|
|
||||||
probeText += "\n"
|
probeText += "\n"
|
||||||
#probeText += "(Reference) " if gData["shock-speed"][shock_speed_loc][1] else ""
|
#probeText += "\\definecolor{my_gray}{rbg}{0.6, 0.5803921568627451, 0.5647058823529412}\\textcolor{my_gray}{" if gData["shock-speed"][shock_speed_loc][1] else ""
|
||||||
probeText += f"{shock_speed_loc} - {gData["shock-speed"][shock_speed_loc][0]/1000:.2f} $\\pm${gData["shock-speed"][shock_speed_loc][1]/1000:.2f} [{gData["shock-speed"][shock_speed_loc][1]/gData["shock-speed"][shock_speed_loc][0]*100:.2f}%] km/s"
|
probeText += f"{shock_speed_loc} - {gData['shock-speed'][shock_speed_loc][0]/1000:.2f} $\\pm${gData['shock-speed'][shock_speed_loc][1]/1000:.2f} [{gData['shock-speed'][shock_speed_loc][1]/gData['shock-speed'][shock_speed_loc][0]*100:.2f}%] km/s"
|
||||||
|
#probeText += "}" if gData["shock-speed"][shock_speed_loc][1] else ""
|
||||||
|
|
||||||
graphData["plots"].append({
|
graphData["plots"].append({
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"text": f"Measured Shock Speeds {probeText}",
|
"text": f"Measured Shock Speeds {probeText}",
|
||||||
"align": ("top", "right"),
|
"align": ("top", "right"),
|
||||||
"x": 0.94 if len(gData["info"]["probe-info"]["locations"]) < 3 else 0.90,
|
"alpha": 0.75,
|
||||||
|
"x": 0.94 if len(gData["info"]["probe-info"]["locations"]) < 3 else 0.885,
|
||||||
"y": 0.94
|
"y": 0.94
|
||||||
})
|
})
|
||||||
|
|
||||||
if doLimits and len(lims) > 1:
|
if doLimits and len(lims) > 1:
|
||||||
OFFSET = 10
|
OFFSET = 10 #if not forcePlots else 50
|
||||||
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=f"./images/{{0}}{"-noLims" if not doLimits else ""}.png")
|
makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath=f"./images/{gData['info']['shot-info']['name']}{'-all' if forcePlots else ''}{'-clipped' if doLimits else ''}.png") #figSavePath=f"./images/{{0}}{"-noLims" if not doLimits else ""}.png")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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[-2]: continue
|
||||||
genGraph(data[shot], showPlot=False)
|
genGraph(data[shot], showPlot=False, addShockInfo=False)
|
||||||
#genGraph(data[shot], showPlot=False, doLimits=False, forcePlots=True)
|
genGraph(data[shot], showPlot=False, forcePlots=True)
|
||||||
|
|
||||||
# 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
|
||||||
pltKeyClose()
|
pltKeyClose()
|
||||||
|
@ -67,5 +67,5 @@ uncertainties:
|
|||||||
|
|
||||||
|
|
||||||
time:
|
time:
|
||||||
x2-daq: 0
|
x2-daq: 0.00000039999999999996 # 30MHz ?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user