From 3efdbef19ede0ee9f5cd7f81e4a4398e15797932 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 27 Nov 2022 20:40:55 +0100 Subject: add conversion efficiency plot --- bin/korad-logger | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/bin/korad-logger b/bin/korad-logger index dcc9e54..bba0e8e 100755 --- a/bin/korad-logger +++ b/bin/korad-logger @@ -451,7 +451,7 @@ def measure_data( return output -def plot_data(data, mode): +def plot_data(data, mode, output_power=None): import matplotlib.pyplot as plt plt.style.use(matplotlib_theme) @@ -517,6 +517,26 @@ def plot_data(data, mode): plt.xlabel("Current [A]") plt.ylabel("Power [W]") + elif mode == "Up" and output_power: + plt.plot( + data[:, 1], + output_power * 100 / (data[:, 1] * data[:, 2]), + "bs", + markersize=2, + ) + plt.xlabel("Voltage [V]") + plt.ylabel("Conversion Efficiency [%]") + + elif mode == "Ip" and output_power: + plt.plot( + data[:, 2], + output_power * 100 / (data[:, 1] * data[:, 2]), + "bs", + markersize=2, + ) + plt.xlabel("Current [A]") + plt.ylabel("Conversion Efficiency [%]") + plt.show() @@ -685,9 +705,15 @@ def main(): parser.add_argument( "--plot", metavar="UNIT", - choices=["U", "I", "P", "UI", "UP", "IU", "IP"], + choices=["U", "I", "P", "UI", "UP", "Up", "IU", "IP", "Ip"], help="Plot voltage / current / power over time or voltage vs current / current vs voltage", ) + parser.add_argument( + "--converter-output-power", + type=int, + metavar="WATTS", + help="Output power for conversion efficiency calculation (--plot=Up / --plot=Ip)", + ) parser.add_argument( "--dark-mode", action="store_true", help="Show plots on a dark background" ) @@ -740,7 +766,7 @@ def main(): data = parse_data(log_data, skip=args.skip, limit=args.limit) if args.plot: - plot_data(data, args.plot) + plot_data(data, args.plot, args.converter_output_power) if __name__ == "__main__": -- cgit v1.2.3