From 7a247f4c46c06f92dbdb52db7af4ad39450e6da1 Mon Sep 17 00:00:00 2001 From: mmpe <mmpe@dtu.dk> Date: Thu, 19 Apr 2018 05:59:51 +0200 Subject: [PATCH] added wind_resource.py --- topfarm/cost_models/utils/wind_resource.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 topfarm/cost_models/utils/wind_resource.py diff --git a/topfarm/cost_models/utils/wind_resource.py b/topfarm/cost_models/utils/wind_resource.py new file mode 100644 index 00000000..d41a14e7 --- /dev/null +++ b/topfarm/cost_models/utils/wind_resource.py @@ -0,0 +1,25 @@ +''' +Created on 19/04/2018 + +@author: Mads +''' +import numpy as np +class WindResource(object): + def __init__(self,f,a,k,ti): + self.f = f + self.a = a + self.k = k + self.ti = ti + + def weibull_weight(self, ws): + cdf = lambda ws, A=self.A,k=self.k : 1 - np.exp(-(ws / A) ** k) + dws = np.diff(ws,0) + return cdf(ws+dws) - cdf(ws-dws) + + def __call__(self, turbine_positions, wdir, wsp): + + WS = np.broadcast_to(wsp, (len(turbine_positions), len(wdir),len(wsp))) + weight = self.weibull_weight(self.a, self.k, WS) + #TODO: add weight from wdir dist + return WS, np.zeros_like(WS)+self.ti, weight + -- GitLab