-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |