From 5cd6c2ae7c8137e3ccc82ff20a2cb51e8e192089 Mon Sep 17 00:00:00 2001 From: "Mads M. Pedersen" <mmpe@dtu.dk> Date: Tue, 24 Apr 2018 11:32:57 +0200 Subject: [PATCH] fixed asymmetry issue in wind_resource.py --- topfarm/cost_models/utils/wind_resource.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/topfarm/cost_models/utils/wind_resource.py b/topfarm/cost_models/utils/wind_resource.py index 2c93b646..705f7fa0 100644 --- a/topfarm/cost_models/utils/wind_resource.py +++ b/topfarm/cost_models/utils/wind_resource.py @@ -9,11 +9,11 @@ import numpy as np class WindResource(object): def __init__(self, f, a, k, ti): wdir = np.linspace(0, 360, len(f), endpoint=False) - indexes = np.argmin((np.broadcast_to(np.arange(360), (len(f), 360)).T - wdir) % 360, 1) - self.f = f[indexes] / (360 / len(f)) - self.a = a[indexes] - self.k = k[indexes] - self.ti = ti[indexes] + indexes = np.argmin((np.tile(np.arange(360),(len(f),1)).T - wdir + (360/len(f)/2)) % 360, 1) + self.f = np.array(f)[indexes] / (360 / len(f)) + self.a = np.array(a)[indexes] + self.k = np.array(k)[indexes] + self.ti = np.array(ti)[indexes] def weibull_weight(self, WS, A, k): cdf = lambda ws, A=A, k=k: 1 - np.exp(-(ws / A) ** k) @@ -24,6 +24,7 @@ class WindResource(object): # f(turbine_positions, wdir, wsp) -> WS[nWT,nWdir,nWsp], TI[nWT,nWdir,nWsp), Weight[nWdir,nWsp] WD, WS = np.meshgrid(wdir, wsp) weight = self.weibull_weight(WS, self.a[WD], self.k[WD]) * self.f[wdir] + WD,WS = np.tile(WD,(len(turbine_positions),1,1)), np.tile(WS,(len(turbine_positions),1,1)) return WD, WS, self.ti[WD], weight -- GitLab