Skip to content

Commit

Permalink
Create long_term_plots.py
Browse files Browse the repository at this point in the history
  • Loading branch information
aclerc committed Apr 22, 2024
1 parent dbd79d5 commit 50d9656
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions wind_up/plots/long_term_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import matplotlib as mpl
import pandas as pd
from matplotlib import pyplot as plt

from wind_up.models import PlotConfig

mpl.use("Agg")


def plot_lt_ws(
lt_df: pd.DataFrame,
*,
turbine_or_wf_name: str,
title_end: str,
plot_cfg: PlotConfig,
one_turbine: bool = False,
) -> None:
plt.figure()
plt.plot(lt_df["bin_mid"], lt_df["hours_per_year"], marker="s", label="hours per year")
plt.plot(
lt_df["bin_mid"],
lt_df["mwh_per_year_per_turbine"],
marker="s",
label=f"MWh per year{one_turbine * ' per turbine'}",
)
title_end = f" {title_end}" if len(title_end) > 0 else ""
plot_title = f"{turbine_or_wf_name} long term distribution{title_end}"
plt.title(plot_title)
plt.xlabel("wind speed bin middle [m/s]")
plt.ylabel("hours per year, MWh per year")
plt.legend()
plt.grid()
plt.tight_layout()
if plot_cfg.show_plots:
plt.show()
if plot_cfg.save_plots:
if one_turbine:
plt.savefig(plot_cfg.plots_dir / turbine_or_wf_name / f"{plot_title}.png")
else:
plt.savefig(plot_cfg.plots_dir / f"{plot_title}.png")
plt.close()


def plot_lt_ws_raw_filt(
*,
lt_df_raw: pd.DataFrame,
lt_df_filt: pd.DataFrame,
turbine_or_wf_name: str,
plot_cfg: PlotConfig,
one_turbine: bool = False,
) -> None:
plt.figure()
plt.plot(lt_df_raw["bin_mid"], lt_df_raw["hours_per_year"], marker="s", label="before filter")
plt.plot(lt_df_filt["bin_mid"], lt_df_filt["hours_per_year"], marker="s", label="after filter")
plot_title = f"{turbine_or_wf_name} long term hours distribution"
plt.title(plot_title)
plt.xlabel("wind speed bin middle [m/s]")
plt.ylabel("hours per year")
plt.legend()
plt.grid()
plt.tight_layout()
if plot_cfg.show_plots:
plt.show()
if plot_cfg.save_plots:
if one_turbine:
plt.savefig(plot_cfg.plots_dir / turbine_or_wf_name / f"{plot_title}.png")
else:
plt.savefig(plot_cfg.plots_dir / f"{plot_title}.png")
plt.close()

plt.figure()
plt.plot(lt_df_raw["bin_mid"], lt_df_raw["mwh_per_year_per_turbine"], marker="s", label="before filter")
plt.plot(lt_df_filt["bin_mid"], lt_df_filt["mwh_per_year_per_turbine"], marker="s", label="after filter")
plot_title = f"{turbine_or_wf_name} long term MWh per year{one_turbine * ' per turbine'}"
plt.title(plot_title)
plt.xlabel("wind speed bin middle [m/s]")
plt.ylabel("MWh per year")
plt.legend()
plt.grid()
plt.tight_layout()
if plot_cfg.show_plots:
plt.show()
if plot_cfg.save_plots:
if one_turbine:
plt.savefig(plot_cfg.plots_dir / turbine_or_wf_name / f"{plot_title}.png")
else:
plt.savefig(plot_cfg.plots_dir / f"{plot_title}.png")
plt.close()

0 comments on commit 50d9656

Please sign in to comment.