TNO Intern

Commit a97403f0 authored by Zanne Korevaar's avatar Zanne Korevaar
Browse files

feat: add r_out scatter plots to stochastic output

parent 3b46ce5b
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -84,16 +84,23 @@ class PlotResults:
        ]
        variable_param_names, locked_param_names = get_param_names()

        x_variables = result_variables + variable_param_names
        x_variables = result_variables + variable_param_names + ["r_out"]

        # Loop through variables and create scatterplots
        for x_variable in x_variables:
            if x_variable != y_variable and x_variable in results_df.columns:
                # only plot the variables that are truly variable (stdev != 0)
                if results_df[x_variable].std().round(7) != 0:
                    title = f"{format_dict[x_variable]} ({units_dict[x_variable]}) after {results_df.loc[0, 'hours']} hours production vs. {format_dict[y_variable]} ({units_dict[y_variable]})"
                    # Handle r_out unit conversion
                    plot_df = results_df.copy()
                    x_unit = units_dict[x_variable]
                    if x_variable == "r_out":
                        plot_df[x_variable] = plot_df[x_variable] * 1000
                        x_unit = "mm"

                    title = f"{format_dict[x_variable]} ({x_unit}) after {plot_df.loc[0, 'hours']} hours production vs. {format_dict[y_variable]} ({units_dict[y_variable]})"
                    g = sns.JointGrid(
                        results_df, x=x_variable, y=y_data[y_variable], hue="file_name"
                        plot_df, x=x_variable, y=y_data[y_variable], hue="file_name"
                    )
                    g.plot_joint(
                        sns.scatterplot, alpha=0.7, edgecolor=".2", linewidth=0.5
@@ -118,7 +125,7 @@ class PlotResults:
                        )
                        g.ax_joint.legend()  # Ensure the legend is updated
                    g.set_axis_labels(
                        xlabel=f"{format_dict[x_variable]} ({units_dict[x_variable]})",
                        xlabel=f"{format_dict[x_variable]} ({x_unit})",
                        ylabel=f"{format_dict[y_variable]} ({units_dict[y_variable]})",
                    )
                    g.fig.suptitle(title)
@@ -135,9 +142,16 @@ class PlotResults:
                in params_df.select_dtypes(include=["float64", "int64"]).columns
            ):
                if params_df[x_variable].std().round(7) != 0:
                    title = f"{format_dict[x_variable]} ({units_dict[x_variable]}) after {params_df.loc[0, 'nyear']} year production vs. {format_dict[y_variable]} ({units_dict[y_variable]})"
                    # Handle r_out unit conversion
                    plot_params_df = params_df.copy()
                    x_unit = units_dict[x_variable]
                    if x_variable == "r_out":
                        plot_params_df[x_variable] = plot_params_df[x_variable] * 1000
                        x_unit = "mm"

                    title = f"{format_dict[x_variable]} ({x_unit}) after {plot_params_df.loc[0, 'nyear']} year production vs. {format_dict[y_variable]} ({units_dict[y_variable]})"
                    g = sns.JointGrid(
                        params_df, x=x_variable, y=y_data[y_variable], hue="file_name"
                        plot_params_df, x=x_variable, y=y_data[y_variable], hue="file_name"
                    )
                    g.plot_joint(
                        sns.scatterplot, alpha=0.7, edgecolor=".2", linewidth=0.5
@@ -156,7 +170,7 @@ class PlotResults:
                        g.ax_joint.invert_yaxis()

                    g.set_axis_labels(
                        xlabel=f"{format_dict[x_variable]} ({units_dict[x_variable]})",
                        xlabel=f"{format_dict[x_variable]} ({x_unit})",
                        ylabel=f"{format_dict[y_variable]} ({units_dict[y_variable]})",
                    )
                    g.fig.suptitle(title)