Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "res-wind-up"
version = "0.4.9"
version = "0.4.10"
authors = [
{ name = "Alex Clerc", email = "alex.clerc@res-group.com" }
]
Expand Down Expand Up @@ -97,7 +97,7 @@ max-complexity = 12 # try to bring this down to 10

[tool.ruff.lint.pylint]
max-branches = 14 # try to bring this down to 12
max-statements = 68 # try to bring this down to 50
max-statements = 69 # try to bring this down to 50
max-args = 17 # try to bring this down to 5

[tool.ruff.lint.per-file-ignores]
Expand Down
8 changes: 6 additions & 2 deletions wind_up/main_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def _calc_test_ref_results(
pre_df = pre_df.merge(ref_df, how="left", left_index=True, right_index=True)
post_df = post_df.merge(ref_df, how="left", left_index=True, right_index=True)

compare_active_and_reactive_power_pre_post(
_reactive_fig = compare_active_and_reactive_power_pre_post(
pre_df=pre_df,
post_df=post_df,
wtg_name=ref_name,
Expand All @@ -595,6 +595,8 @@ def _calc_test_ref_results(
sub_dir=f"{test_name}/{ref_name}",
is_toggle_test=cfg.toggle is not None,
)
if _reactive_fig is not None:
plt.close(_reactive_fig)

ref_ops_curve_shift_dict = _check_for_ops_curve_shift(
pre_df,
Expand Down Expand Up @@ -881,7 +883,7 @@ def run_wind_up_analysis(

test_df, pre_df, post_df = pre_post_splitter.split(test_df, test_wtg_name=test_name)

compare_active_and_reactive_power_pre_post(
_reactive_fig = compare_active_and_reactive_power_pre_post(
pre_df=pre_df,
post_df=post_df,
wtg_name=test_name,
Expand All @@ -890,6 +892,8 @@ def run_wind_up_analysis(
plot_cfg=plot_cfg,
is_toggle_test=cfg.toggle is not None,
)
if _reactive_fig is not None:
plt.close(_reactive_fig)

test_ops_curve_shift_dict = _check_for_ops_curve_shift(
pre_df,
Expand Down
10 changes: 6 additions & 4 deletions wind_up/plots/combine_results_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ def plot_combined_results(tdf: pd.DataFrame, *, plot_cfg: PlotConfig, confidence
grouped_results = tdf.index.name == "role"

plt.figure()
labels = tdf.index.to_list() if grouped_results else tdf["test_wtg"]
labels = (
[f"{i} ({int(v)} wtgs)" for i, v in zip(tdf.index, tdf["wtg_count"])] if grouped_results else tdf["test_wtg"]
)
values = tdf["p50_uplift"] * 100
yerrs = tdf["sigma"] * 100 * z_score
plt.bar(labels, values, yerr=yerrs, capsize=3)
plt.xlabel("turbine group" if grouped_results else "turbine")
plt.ylabel("uplift [%]")
plt.ylabel("uplift [%]", fontsize=12)
plot_title = f"combined uplift and {confidence * 100:.0f}% CI"
plt.title(plot_title)
plt.grid(axis="y")
plt.xticks(rotation=90, ha="right")
plt.xticks(fontsize=12)
plt.tight_layout()
if show_plots:
plt.show()
if save_plots:
plt.savefig(plot_cfg.plots_dir / f"{plot_title}.png")
plt.savefig(plot_cfg.plots_dir / f"{plot_title.replace('%', 'pct')}.png")
plt.close()


Expand Down
12 changes: 5 additions & 7 deletions wind_up/plots/scada_funcs_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def plot_toggle_active_vs_reactive_power(
t_dir = plot_cfg.plots_dir / wtg_name if sub_dir is None else plot_cfg.plots_dir / sub_dir
t_dir.mkdir(exist_ok=True, parents=True)
fig.savefig(t_dir / f"{plot_title}.png")
return None
return fig


def compare_active_and_reactive_power_pre_post(
Expand All @@ -372,7 +372,7 @@ def compare_active_and_reactive_power_pre_post(
plot_cfg: PlotConfig,
is_toggle_test: bool,
sub_dir: str | None = None,
) -> None:
) -> plt.Figure | None:
"""Plot active vs reactive power

Distinguishes data pre- and post-upgrade or toggled on/off (depending on `is_toggle_test`).
Expand All @@ -381,10 +381,10 @@ def compare_active_and_reactive_power_pre_post(
result_manager.warning(
f"Column '{reactive_power_col}' not found, skipping reactive vs active power plot for {wtg_name}"
)
return
return None

if is_toggle_test:
plot_toggle_active_vs_reactive_power(
return plot_toggle_active_vs_reactive_power(
input_df=pd.concat([pre_df, post_df]),
wtg_name=wtg_name,
toggle_name="toggle",
Expand All @@ -393,12 +393,11 @@ def compare_active_and_reactive_power_pre_post(
plot_cfg=plot_cfg,
sub_dir=sub_dir,
)
return
pre_df_fake_toggle = pre_df.copy()
post_df_fake_toggle = post_df.copy()
pre_df_fake_toggle["test_toggle_off"] = True
post_df_fake_toggle["test_toggle_on"] = True
plot_toggle_active_vs_reactive_power(
return plot_toggle_active_vs_reactive_power(
input_df=pd.concat([pre_df_fake_toggle, post_df_fake_toggle]),
wtg_name=wtg_name,
toggle_name="upgrade",
Expand All @@ -407,7 +406,6 @@ def compare_active_and_reactive_power_pre_post(
plot_cfg=plot_cfg,
sub_dir=sub_dir,
)
return


def compare_ops_curves_pre_post(
Expand Down
2 changes: 1 addition & 1 deletion wind_up/plots/ws_est_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def plot_ws_est_gain_xs_one_ttype(
plt.close()


def plot_ws_est_one_ttype_or_wtg( # noqa C901 PLR0915
def plot_ws_est_one_ttype_or_wtg(
df: pd.DataFrame,
ttype_or_wtg: str,
pc_transposed: pd.DataFrame,
Expand Down
2 changes: 1 addition & 1 deletion wind_up/plots/yaw_direction_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
logger = logging.getLogger(__name__)


def plot_yaw_direction_pre_post_per_signal( # noqa:PLR0915
def plot_yaw_direction_pre_post_per_signal(
signal_name: str,
test_wd_col: str,
*,
Expand Down
Loading