Skip to content

Commit

Permalink
Tune Weibull priors
Browse files Browse the repository at this point in the history
  • Loading branch information
camirmas committed Apr 14, 2023
1 parent 5114602 commit aa95ee8
Show file tree
Hide file tree
Showing 6 changed files with 594 additions and 550 deletions.
2 changes: 1 addition & 1 deletion REStats/models/iec_power_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def calc_iec_power_curve(data: pd.DataFrame, bin_size: float = 0.5) -> pd.DataFr
raise ValueError("Input DataFrame must contain 'wind_speed' and 'power' columns.")

min_ws = np.floor(np.min(data.wind_speed))
max_ws = np.ceil(np.max(data.wind_speed) + bin_size)
max_ws = np.ceil(np.max(data.wind_speed)) + bin_size
wt_bins = np.arange(min_ws, max_ws, bin_size)
wt_groups = data.groupby(pd.cut(data.wind_speed, wt_bins))
wt_iec = wt_groups.mean()
Expand Down
8 changes: 5 additions & 3 deletions REStats/models/weibull.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def weibull_model(data):
Returns:
None
"""
shape = pyro.sample("shape", dist.Gamma(2, 0.5))
scale = pyro.sample("scale", dist.Gamma(1, 0.5))
mu = np.log(data.mean())

shape = pyro.sample("shape", dist.Gamma(2, 1))
scale = pyro.sample("scale", dist.LogNormal(mu, 0.5))

with pyro.plate("data", len(data)):
pyro.sample("obs", dist.Weibull(scale, shape), obs=data)
Expand Down Expand Up @@ -94,7 +96,7 @@ def plot_prior_samples(idata_wb):
shapes = idata_wb.prior.shape[0, :10]
scales = idata_wb.prior.scale[0, :10]

x = np.linspace(0, 5, 500)
x = np.linspace(0, 12, 500)

def weib(x, scale, shape):
return (shape / scale) * (x / scale)**(shape - 1) * np.exp(-(x / scale)**shape)
Expand Down
936 changes: 489 additions & 447 deletions REStats/notebooks/forecast.ipynb

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions REStats/notebooks/power_curve.ipynb

Large diffs are not rendered by default.

130 changes: 65 additions & 65 deletions REStats/notebooks/sim.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/models/test_iec_power_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_calc_iec_power_curve():
output.reset_index(drop=True, inplace=True)

# Prepare the expected output
wt_bins = np.arange(np.min(wind_speed), np.max(wind_speed), bin_size)
wt_bins = np.arange(np.min(wind_speed), np.ceil(np.max(wind_speed)) + bin_size, bin_size)
wt_groups = data.groupby(pd.cut(data.wind_speed, wt_bins))
expected_output = wt_groups.mean().reset_index(drop=True)

Expand Down

0 comments on commit aa95ee8

Please sign in to comment.