Skip to content

Commit

Permalink
update models and misc_plots
Browse files Browse the repository at this point in the history
  • Loading branch information
aclerc committed May 16, 2024
1 parent 6053578 commit 0783a26
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
5 changes: 0 additions & 5 deletions wind_up/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,6 @@ def check_non_wtg_ref_names(self: "WindUpConfig") -> "WindUpConfig":
raise ValueError(msg)
return self

@model_validator(mode="after")
def make_out_dir(self: "WindUpConfig") -> "WindUpConfig":
self.out_dir.mkdir(parents=True, exist_ok=True)
return self

@model_validator(mode="after")
def print_summary(self: "WindUpConfig") -> "WindUpConfig":
logger.info(f"loaded WindUpConfig assessment_name: {self.assessment_name}")
Expand Down
25 changes: 8 additions & 17 deletions wind_up/plots/misc_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ def rescale_vector(
lowthres: float = 0,
highthres: float = 1,
) -> pd.Series | np.ndarray:
"""
Initially copied from AnemoTools/Math/Math.py
Rescales a vector to the specified interval. By default to (0,1)
:param vector: pd.Series or np.ndarray, vector to rescale
:param float/int, lowthres: minimum value of the rescaled vector
:param float/int, highthres: maximum value of the rescaled vector
:return: pd.Series or np.ndarray, rescaled vector
"""
if isinstance(vector, list):
vector = np.array(vector)

Expand Down Expand Up @@ -54,8 +46,7 @@ def bubble_plot_calcs(
list[str],
list[str],
list[str],
]: # x, y, xlims, ylims, sc, si, ticks, ticklabs, wtg_id, park_wtgids, series_wtgs
# extracting coordinates
]:
x = np.array([])
y = np.array([])
wtg_id = []
Expand All @@ -67,8 +58,8 @@ def bubble_plot_calcs(
x = x - np.median(x)
y = y - np.median(y)

xmar = 500 # 0.15 * (x.max() - x.min())
ymar = 500 # 0.05 * (y.max() - y.min())
xmar = 500
ymar = 500
xlims = (x.min() - xmar, x.max() + xmar)
ylims = (y.min() - ymar, y.max() + ymar)

Expand Down Expand Up @@ -139,12 +130,12 @@ def bubble_plot(
txt: bool = True,
title: str | None = None,
cbarunits: str | None = None,
savefigure: Path | None = None,
save_path: Path | None = None,
display_wtgids: bool = True,
cbar_label: str | None = None,
text_rotation: int = 0,
figuresize: tuple[float, float] | None = None,
showfigure: bool = False,
show_plot: bool = False,
) -> None:
if isinstance(series, type(pd.DataFrame())):
msg = "series should be a pandas series"
Expand Down Expand Up @@ -212,8 +203,8 @@ def bubble_plot(
)

plt.grid()
if showfigure:
if show_plot:
plt.show()
if savefigure is not None:
plt.savefig(savefigure, dpi=120)
if save_path is not None:
plt.savefig(save_path, dpi=120)
plt.close()
4 changes: 2 additions & 2 deletions wind_up/plots/scada_funcs_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def print_and_plot_capacity_factor(scada_df: pd.DataFrame, cfg: WindUpConfig, pl
series=cf_df["CF"] * 100,
title=f"{cfg.asset.name} capacity factor",
cbarunits="%",
savefigure=plots_cfg.plots_dir / f"{title}.png",
showfigure=plots_cfg.show_plots,
save_path=plots_cfg.plots_dir / f"{title}.png",
show_plot=plots_cfg.show_plots,
)

logger.info(f'average capacity factor: {cf_df["CF"].mean() * 100:.1f}%')
Expand Down

0 comments on commit 0783a26

Please sign in to comment.