Generate Total Average Speed
This commit is contained in:
parent
46ef08874a
commit
df1c20f0c3
28
main.py
28
main.py
@ -605,7 +605,6 @@ def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlo
|
|||||||
|
|
||||||
|
|
||||||
lims = []
|
lims = []
|
||||||
|
|
||||||
for label, d in [("1 [V]", "Gauge 1"),("2 [V]", "Gauge 2")]: #, ("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"],
|
||||||
@ -657,9 +656,16 @@ def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlo
|
|||||||
if addShockInfo:
|
if addShockInfo:
|
||||||
probeText = ""
|
probeText = ""
|
||||||
flag = False
|
flag = False
|
||||||
|
avg_speed_lst = []
|
||||||
|
avg_uncert_lst = []
|
||||||
for shock_speed_loc in gData["shock-speed"]:
|
for shock_speed_loc in gData["shock-speed"]:
|
||||||
|
avg_speed_lst.append(gData['shock-speed'][shock_speed_loc][0])
|
||||||
|
avg_uncert_lst.append(gData['shock-speed'][shock_speed_loc][1])
|
||||||
if not flag and not gData["shock-speed"][shock_speed_loc][2]:
|
if not flag and not gData["shock-speed"][shock_speed_loc][2]:
|
||||||
flag = True
|
flag = True
|
||||||
|
avg_speed = np.array(avg_speed_lst).mean()
|
||||||
|
avg_uncert = np.sqrt(np.sum(np.pow(np.array(avg_uncert_lst), 2)))
|
||||||
|
probeText += f"\nAverage Speed - {avg_speed/1000:.2f} $\\pm${avg_uncert/1000:.2f} [{avg_uncert/avg_speed * 100:.2f}] km/s"
|
||||||
probeText += "\n" + "-"*50
|
probeText += "\n" + "-"*50
|
||||||
|
|
||||||
probeText += "\n"
|
probeText += "\n"
|
||||||
@ -718,9 +724,16 @@ def genRefGraph(gData: dict, showPlot: bool = True, addShockInfo: bool = True, f
|
|||||||
if addShockInfo:
|
if addShockInfo:
|
||||||
probeText = ""
|
probeText = ""
|
||||||
flag = False
|
flag = False
|
||||||
|
avg_speed_lst = []
|
||||||
|
avg_uncert_lst = []
|
||||||
for shock_speed_loc in gData["shock-speed"]:
|
for shock_speed_loc in gData["shock-speed"]:
|
||||||
|
avg_speed_lst.append(gData['shock-speed'][shock_speed_loc][0])
|
||||||
|
avg_uncert_lst.append(gData['shock-speed'][shock_speed_loc][1])
|
||||||
if not flag and not gData["shock-speed"][shock_speed_loc][2]:
|
if not flag and not gData["shock-speed"][shock_speed_loc][2]:
|
||||||
flag = True
|
flag = True
|
||||||
|
avg_speed = np.array(avg_speed_lst).mean()
|
||||||
|
avg_uncert = np.sqrt(np.sum(np.pow(np.array(avg_uncert_lst), 2)))
|
||||||
|
probeText += f"\nAverage Speed - {avg_speed/1000:.2f} $\\pm${avg_uncert/1000:.2f} [{avg_uncert/avg_speed * 100:.2f}%] km/s"
|
||||||
probeText += "\n" + "-"*50
|
probeText += "\n" + "-"*50
|
||||||
|
|
||||||
probeText += "\n"
|
probeText += "\n"
|
||||||
@ -823,6 +836,8 @@ def genComboRefGraph(data: dict, plotCh: list[str] = ["st1", "st2", "st3"], show
|
|||||||
shock_speeds[shock_speed_loc] = shk_sps
|
shock_speeds[shock_speed_loc] = shk_sps
|
||||||
|
|
||||||
probeText = ""
|
probeText = ""
|
||||||
|
avg_speeds = []
|
||||||
|
avg_uncerts = []
|
||||||
for shock_speed_loc in shock_speeds:
|
for shock_speed_loc in shock_speeds:
|
||||||
shock_info = np.array(shock_speeds[shock_speed_loc])
|
shock_info = np.array(shock_speeds[shock_speed_loc])
|
||||||
|
|
||||||
@ -832,10 +847,17 @@ def genComboRefGraph(data: dict, plotCh: list[str] = ["st1", "st2", "st3"], show
|
|||||||
speed = speeds.mean()
|
speed = speeds.mean()
|
||||||
uncert = np.sqrt(np.pow(uncerts, 2).sum())
|
uncert = np.sqrt(np.pow(uncerts, 2).sum())
|
||||||
|
|
||||||
|
avg_speeds.append(speed)
|
||||||
|
avg_uncerts.append(uncert)
|
||||||
|
|
||||||
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}%])")
|
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"
|
probeText += f"\n{shock_speed_loc} - {speed/1000:.2f} $\\pm${uncert/1000:.2f} [{uncert/speed*100:.2f}%] km/s"
|
||||||
|
|
||||||
|
avg_sp = np.array(avg_speeds).mean()
|
||||||
|
avg_unc = np.sqrt(np.pow(np.array(avg_uncerts), 2).sum())
|
||||||
|
probeText += f"\nAverage Speed - {avg_sp/1000:.2f} $\\pm${avg_unc/1000:.2f} [{avg_sp/avg_unc * 100:.2f}] km/s"
|
||||||
|
|
||||||
graphData["plots"].append({
|
graphData["plots"].append({
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"text": f"Average Measured Shock Speeds{probeText}",
|
"text": f"Average Measured Shock Speeds{probeText}",
|
||||||
@ -1136,5 +1158,5 @@ genComboRefGraph(ref_data, ref_data[ref_data_to_load[0]]["info"]["pcb-refs"], ad
|
|||||||
|
|
||||||
|
|
||||||
# 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()
|
||||||
print("Done")
|
print("Done")
|
Loading…
x
Reference in New Issue
Block a user