TNO Intern

Commit 2d9e1946 authored by Zanne Korevaar's avatar Zanne Korevaar
Browse files

Plot time-variable COP in the timeplots and add textbox with the mean COP value over time.

parent 09540cb2
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ class PlotResults:
        -------
        None
        """
        out_path_prefix = out_path.with_name(out_path.name + "timeplot")
        out_path_prefix = out_path.with_name(out_path.name + "_timeplot")

        # Ensure results_dfs is a list of dataframes
        if isinstance(results_dfs, pd.DataFrame):
@@ -237,12 +237,7 @@ class PlotResults:
                and "Q_b" in df.columns
                and "qloop" in df.columns
            ):
                mean_Q = df["Q_b"].mean()
                mean_q = df["qloop"].mean()
                mean_COP = mean_Q / mean_q
                df["COP"] = mean_COP  # abs(df['Q_b'] / df['qloop'])
                # df['COP'] = abs(df['Q_b']) / df['qloop']
                # print(df["COP"].min())
                df['COP'] = abs(df['Q_b']) / df['qloop']
            if (
                "Delta_T" in plot_parameters
                and "T_fi" in df.columns
@@ -253,7 +248,7 @@ class PlotResults:
        plots = [
            ("Q_b", "Heat Load [W]", "Q_b", None, None),
            ("flowrate", "Flowrate [kg/s]", "flowrate", None, None),
            ("COP", "Coefficient of Performance", "COP", None, None),
            ("COP", "Coefficient of Performance", "COP", None, None)
        ]

        plotted_params = []
@@ -320,7 +315,7 @@ class PlotResults:
                ax_twin.grid(axis="both")

            file_name = out_path.with_name(
                out_path.name + f"timeplot_{'_'.join(sorted(set(plotted_params)))}.png"
                out_path.name + f"_timeplot_{'_'.join(sorted(set(plotted_params)))}.png"
            )

            fig.tight_layout()
@@ -474,6 +469,15 @@ class PlotResults:
                        label=labels[idx][param],
                        color=next(color_iter),
                    )
                    if param=="COP":
                        if param == "COP":
                            ax.text(
                                0.7, 0.9,  # 2% from left and bottom of the axes
                                f"mean COP: {df['COP'].mean():.2f}",
                                transform=ax.transAxes,
                                bbox=dict(boxstyle="round,pad=0.3", facecolor="white", alpha=0.7),
                                fontsize=12
                            )

            ax.legend(loc=(-0.07, -0.17 - (0.08 * len(results_dfs))))
            ax.grid()