Skip to content
Snippets Groups Projects
Commit 3e1beea4 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

fix AEP of time series

parent 44a311c3
No related branches found
No related tags found
No related merge requests found
...@@ -233,7 +233,9 @@ class XRSite(Site): ...@@ -233,7 +233,9 @@ class XRSite(Site):
lw.set_W(WS, WD, TI, ws_bins, self.use_WS_bins) lw.set_W(WS, WD, TI, ws_bins, self.use_WS_bins)
lw.set_data_array(TI_std, 'TI_std', 'Standard deviation of turbulence intensity') lw.set_data_array(TI_std, 'TI_std', 'Standard deviation of turbulence intensity')
if 'time' not in lw: if 'time' in lw:
lw['P'] = 1 / len(lw.time)
else:
if 'P' in self.ds: if 'P' in self.ds:
if ('ws' in self.ds.P.dims and 'ws' in lw.coords): if ('ws' in self.ds.P.dims and 'ws' in lw.coords):
d_ws = self.ds.P.ws.values d_ws = self.ds.P.ws.values
......
...@@ -409,6 +409,18 @@ def test_time_series_override_ti(): ...@@ -409,6 +409,18 @@ def test_time_series_override_ti():
npt.assert_array_equal(sim_res.TI, ti) npt.assert_array_equal(sim_res.TI, ti)
def test_time_series_aep():
d = np.load(os.path.dirname(examples.__file__) + "/data/time_series.npz")
wd, ws = [d[k][::100] for k in ['wd', 'ws']]
wt = V80()
site = Hornsrev1Site()
x, y = site.initial_position.T
wfm = NOJ(site, wt)
sim_res = wfm(x, y, ws=ws, wd=wd, time=True, verbose=False)
npt.assert_allclose(sim_res.aep().sum(), 545, atol=1)
def test_time_series_operating(): def test_time_series_operating():
from py_wake.wind_turbines.power_ct_functions import PowerCtFunctionList, PowerCtTabular from py_wake.wind_turbines.power_ct_functions import PowerCtFunctionList, PowerCtTabular
d = np.load(os.path.dirname(examples.__file__) + "/data/time_series.npz") d = np.load(os.path.dirname(examples.__file__) + "/data/time_series.npz")
......
...@@ -237,6 +237,8 @@ class SimulationResult(xr.Dataset): ...@@ -237,6 +237,8 @@ class SimulationResult(xr.Dataset):
return xr.DataArray(aep, [('wt', self.wt), ('wd', self.wd), ('ws', ws)]) return xr.DataArray(aep, [('wt', self.wt), ('wd', self.wd), ('ws', ws)])
else: else:
weighted_power = power_ilk * self.P.ilk() / norm weighted_power = power_ilk * self.P.ilk() / norm
if 'time' in self and weighted_power.shape[2] == 1:
weighted_power = weighted_power[:, :, 0]
return xr.DataArray(weighted_power * hours_pr_year * 1e-9, return xr.DataArray(weighted_power * hours_pr_year * 1e-9,
self.Power.coords, self.Power.coords,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment