diff --git a/main.py b/main.py index 2feb8db..0155fdc 100644 --- a/main.py +++ b/main.py @@ -605,7 +605,6 @@ def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlo lims = [] - for label, d in [("1 [V]", "Gauge 1"),("2 [V]", "Gauge 2")]: #, ("4 [V]", "Gauge Trigger")]: graphData["plots"].append({ "x": gData["time"]["scope"], @@ -657,9 +656,16 @@ def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlo if addShockInfo: probeText = "" flag = False + avg_speed_lst = [] + avg_uncert_lst = [] 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]: 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" @@ -718,9 +724,16 @@ def genRefGraph(gData: dict, showPlot: bool = True, addShockInfo: bool = True, f if addShockInfo: probeText = "" flag = False + avg_speed_lst = [] + avg_uncert_lst = [] 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]: 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" @@ -823,6 +836,8 @@ def genComboRefGraph(data: dict, plotCh: list[str] = ["st1", "st2", "st3"], show shock_speeds[shock_speed_loc] = shk_sps probeText = "" + avg_speeds = [] + avg_uncerts = [] for shock_speed_loc in shock_speeds: 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() 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}%])") 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({ "type": "text", "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 -#pltKeyClose() +pltKeyClose() print("Done") \ No newline at end of file