Graph everything
This commit is contained in:
parent
e653885de1
commit
8125efa26a
167
main.py
167
main.py
@ -557,7 +557,7 @@ def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlo
|
||||
"x": gData["shock-point"][f"{probe}-g2"][1],#[i],
|
||||
"label": f"{probe}-Gauge 2 - Shock Point {gData['shock-point'][f'{probe}-g2'][1]:.2f}$\\mu$s",
|
||||
"colour": UQC["purple"].lighten(0.5),
|
||||
"args":{"zorder":2, "linestyle":"--", "alpha":0.5}
|
||||
"args":{"zorder":2, "linestyle":":", "alpha":0.5}
|
||||
})
|
||||
|
||||
lims.append(gData["shock-point"][f"{probe}-g2"][1])
|
||||
@ -576,7 +576,7 @@ def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlo
|
||||
"x": gData["shock-point"][label][1],
|
||||
"label": f"{label} - Shock Point {gData['shock-point'][label][1]:.2f}$\\mu$s",
|
||||
"colour": "gray",
|
||||
"args":{"zorder":2, "linestyle":"--", "alpha":0.5}
|
||||
"args":{"zorder":2, "linestyle":"-.", "alpha":0.5}
|
||||
})
|
||||
lims.append(gData["shock-point"][label][1]) # [TODO this but better]
|
||||
|
||||
@ -637,7 +637,7 @@ def genRefGraph(gData: dict, showPlot: bool = True, addShockInfo: bool = True, f
|
||||
"x": gData["shock-point"][label][1],
|
||||
"label": f"{label} - Shock Point {gData['shock-point'][label][1]:.2f}$\\mu$s",
|
||||
"colour": "gray",
|
||||
"args":{"zorder":2, "linestyle":"--", "alpha":0.5}
|
||||
"args":{"zorder":2, "linestyle":"-.", "alpha":0.5}
|
||||
})
|
||||
lims.append(gData["shock-point"][label][1]) # [TODO this but better]
|
||||
|
||||
@ -721,6 +721,150 @@ def genComboRefGraph(data: dict, plotCh: list[str] = ["st1", "st2", "st3"], show
|
||||
|
||||
for line_sty, shot in enumerate(data):
|
||||
gData = data[shot]
|
||||
for col, label in enumerate(plotCh):
|
||||
if label in plotCh:
|
||||
graphData["plots"].append({
|
||||
"type": "axvLine",
|
||||
"x": gData["shock-point"][label][1],
|
||||
"colour": "gray",
|
||||
"args":{"zorder":2, "linestyle":"-.", "alpha":0.5}
|
||||
})
|
||||
|
||||
if doShockLabels:
|
||||
graphData["plots"][-1]["label"] = f"{label} - Ref Shot {line_sty + 1} - Shock Point {gData['shock-point'][label][1]:.2f}$\\mu$s"
|
||||
|
||||
lims.append(gData["shock-point"][label][1]) # [TODO this but better]
|
||||
|
||||
if addShockInfo:
|
||||
print("============================== Reference Shots ==============================")
|
||||
shock_speeds = {}
|
||||
|
||||
for shot_id, shot in enumerate(data):
|
||||
shot_id += 1
|
||||
|
||||
gData = data[shot]
|
||||
for shock_speed_loc in gData['shock-speed']:
|
||||
shk_sps = shock_speeds.get(shock_speed_loc, [])
|
||||
shk_sps.append((gData['shock-speed'][shock_speed_loc][0], gData['shock-speed'][shock_speed_loc][1]))
|
||||
shock_speeds[shock_speed_loc] = shk_sps
|
||||
|
||||
probeText = ""
|
||||
for shock_speed_loc in shock_speeds:
|
||||
shock_info = np.array(shock_speeds[shock_speed_loc])
|
||||
|
||||
speeds = shock_info[:, 0]
|
||||
uncerts = shock_info[:, 1]
|
||||
|
||||
speed = speeds.mean()
|
||||
uncert = np.sqrt(np.pow(uncerts, 2).sum())
|
||||
|
||||
print(f"{shock_speed_loc} Measured a mean shock speed of {speed:.2f} +/- {uncert:.2f} m/s ({speed/1000:.2f} +/- {uncert/1000:.2f} km/s [{uncert/speed * 100 :.2f}%])")
|
||||
|
||||
probeText += f"\n{shock_speed_loc} - {speed/1000:.2f} $\\pm${uncert/1000:.2f} [{uncert/speed*100:.2f}%] km/s"
|
||||
|
||||
graphData["plots"].append({
|
||||
"type": "text",
|
||||
"text": f"Average Measured Shock Speeds{probeText}",
|
||||
"align": ("top", "right"),
|
||||
"alpha": 0.8,
|
||||
"x": 0.9,
|
||||
"y": 0.9
|
||||
})
|
||||
|
||||
if len(lims) > 1:
|
||||
OFFSET = 10 #if not forcePlots else 50
|
||||
graphData["xLim"] = (float(min(lims) - OFFSET), float(max(lims) + OFFSET))
|
||||
|
||||
|
||||
makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath=f"./images/ref-combo-{'_'.join(plotCh)}.png")
|
||||
|
||||
def genComboDataGraph(data: dict, showPlot: bool = False, doShockLabels:bool = False, addShockInfo:bool = False):
|
||||
shots = ""
|
||||
names = ""
|
||||
for i, shot in enumerate(data):
|
||||
shots += ('' if i == 0 else ', ') + f"{data[shot]['info']['name'][-1]}"
|
||||
names += ('' if i == 0 else ', ') + shot
|
||||
|
||||
graphData = {
|
||||
"title": f"Shock Response Time\nFor Shots {shots} ({names})\nVarious Probe Locations - Mars Entry Conditions",
|
||||
"xLabel": "Time ($\\mu$s)",
|
||||
"yLabel": "Voltage Reading (V)",
|
||||
"grid": True,
|
||||
"figSize": (16, 6.8), #(8,6.5),
|
||||
"ledgLoc": (0.6, 0.075) if doShockLabels else 'upper left',
|
||||
"yLim": (-1.5, 11),
|
||||
"plots": []
|
||||
}
|
||||
|
||||
LINESTYLES = (
|
||||
'solid',
|
||||
'dotted',
|
||||
'dashed',
|
||||
'dashdot'
|
||||
)
|
||||
|
||||
COLOURS = (
|
||||
#UQC["purple"],
|
||||
#UQC["blue"],
|
||||
UQC["green"],
|
||||
UQC["red"],
|
||||
UQC["light_purple"],
|
||||
UQC["dark_grey"],
|
||||
UQC["orange"],
|
||||
UQC["yellow"],
|
||||
UQC["aqua"],
|
||||
UQC["gold"],
|
||||
UQC["neutral"]
|
||||
)
|
||||
|
||||
|
||||
lims = []
|
||||
for line_sty, shot in enumerate(data):
|
||||
gData = data[shot]
|
||||
for label, d in [("1 [V]", "Gauge 1"),("2 [V]", "Gauge 2")]:
|
||||
graphData["plots"].append({
|
||||
"x": gData["time"]["scope"],
|
||||
"y": gData["data"]["scope"][label],
|
||||
#"label": d,
|
||||
"colour": UQC["purple"] if label[0] == "1" else UQC["blue"],
|
||||
"args":{"zorder":1, "linestyle": LINESTYLES[line_sty % len(LINESTYLES)]}
|
||||
})
|
||||
|
||||
if line_sty == 0:
|
||||
graphData["plots"][-2]["label"] = "Gauge 1"
|
||||
graphData["plots"][-1]["label"] = "Gauge 2"
|
||||
|
||||
for _, probe in enumerate(gData["info"]["probe-info"]["locations"]):
|
||||
if f"{probe}-g1" in gData["shock-point"]:
|
||||
graphData["plots"].append({
|
||||
"type": "axvLine",
|
||||
"x": gData["shock-point"][f"{probe}-g1"][1],
|
||||
"colour": UQC["purple"].lighten(0.5),
|
||||
"args":{"zorder":2, "linestyle":"--", "alpha":0.5}
|
||||
})
|
||||
lims.append(gData["shock-point"][f"{probe}-g1"][1])
|
||||
|
||||
if doShockLabels:
|
||||
graphData["plots"][-1]["label"] = f"{probe}-Gauge 1 - {shot} - Shock Point {gData['shock-point'][f'{probe}-g1'][1]:.2f}$\\mu$s"
|
||||
|
||||
if f"{probe}-g2" in gData["shock-point"]:
|
||||
graphData["plots"].append({
|
||||
"type": "axvLine",
|
||||
"x": gData["shock-point"][f"{probe}-g2"][1],
|
||||
"colour": UQC["purple"].lighten(0.5),
|
||||
"args":{"zorder":2, "linestyle":":", "alpha":0.5}
|
||||
})
|
||||
|
||||
lims.append(gData["shock-point"][f"{probe}-g2"][1])
|
||||
|
||||
if doShockLabels:
|
||||
graphData["plots"][-1]["label"] = f"{probe}-Gauge 2 - {shot} - Shock Point {gData['shock-point'][f'{probe}-g2'][1]:.2f}$\\mu$s"
|
||||
|
||||
|
||||
if False:
|
||||
for line_sty, shot in enumerate(data):
|
||||
gData = data[shot]
|
||||
plotCh = gData["info"]["pcb-refs"]
|
||||
for col, label in enumerate(plotCh):
|
||||
if label in plotCh:
|
||||
graphData["plots"].append({
|
||||
@ -764,7 +908,7 @@ def genComboRefGraph(data: dict, plotCh: list[str] = ["st1", "st2", "st3"], show
|
||||
|
||||
graphData["plots"].append({
|
||||
"type": "text",
|
||||
"text": f"Average Measured Shock Speeds {probeText}",
|
||||
"text": f"Average Measured Shock Speeds{probeText}",
|
||||
"align": ("top", "right"),
|
||||
"alpha": 0.8,
|
||||
"x": 0.9,
|
||||
@ -776,8 +920,7 @@ def genComboRefGraph(data: dict, plotCh: list[str] = ["st1", "st2", "st3"], show
|
||||
graphData["xLim"] = (float(min(lims) - OFFSET), float(max(lims) + OFFSET))
|
||||
|
||||
|
||||
makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath=f"./images/ref-combo-{'_'.join(plotCh)}.png")
|
||||
|
||||
makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath=f"./images/combo-my-data.png")
|
||||
|
||||
print("Loading Data")
|
||||
|
||||
@ -806,10 +949,16 @@ for shot in loaded_data:
|
||||
genGraph(data[shot], showPlot=False, addShockInfo=False)
|
||||
genGraph(data[shot], showPlot=False, forcePlots=True)
|
||||
|
||||
combo_data = data.copy()
|
||||
combo_data.pop(loaded_data[-2])
|
||||
combo_data.pop(loaded_data[-1])
|
||||
|
||||
genComboDataGraph(combo_data, doShockLabels=True)
|
||||
|
||||
# Reference Data
|
||||
#for shot in ref_data:
|
||||
# genRefGraph(ref_data[shot], showPlot=False, addShockInfo=False)
|
||||
# genRefGraph(ref_data[shot], showPlot=False, forcePlots=True)
|
||||
for shot in ref_data:
|
||||
genRefGraph(ref_data[shot], showPlot=False, addShockInfo=False)
|
||||
genRefGraph(ref_data[shot], showPlot=False, forcePlots=True)
|
||||
|
||||
genComboRefGraph(ref_data, doShockLabels=True)
|
||||
genComboRefGraph(ref_data, ref_data[ref_data_to_load[0]]["info"]["pcb-refs"], addShockInfo=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user