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

implemented Weibull_IEC

parent 4d8959bd
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,36 @@ def Weibull2(u, k, wsp_lst):
edges = np.r_[wsp_lst[0] - (wsp_lst[1] - wsp_lst[0]) / 2, (wsp_lst[1:] + wsp_lst[:-1]) / 2, wsp_lst[-1] + (wsp_lst[-1] - wsp_lst[-2]) / 2]
return [-cdf(e1) + cdf(e2) for wsp, e1, e2 in zip(wsp_lst, edges[:-1], edges[1:])]
def Weibull_IEC(Vref, Vhub_lst):
"""Weibull distribution according to IEC 61400-1:2005, page 24
Parameters
----------
Vref : int or float
Vref of wind turbine class
Vhub_lst : array_like
Wind speed at hub height. Must be equally spaced.
Returns
-------
nd_array : list of probabilities
Examples
--------
>>> Weibull_IEC(50, [4,6,8])
[ 0.11002961 0.14116891 0.15124155]
"""
Vhub_lst = np.array(Vhub_lst)
#Average wind speed
Vave=.2*Vref
#Rayleigh distribution
Pr = lambda x : 1 - np.exp(-np.pi*(x/(2*Vave))**2)
#Wsp bin edges: [4,6,8] -> [3,5,7,9]
wsp_bin_edges = np.r_[Vhub_lst[0] - (Vhub_lst[1] - Vhub_lst[0]) / 2, (Vhub_lst[1:] + Vhub_lst[:-1]) / 2, Vhub_lst[-1] + (Vhub_lst[-1] - Vhub_lst[-2]) / 2]
#probabilities of 3-5, 5-7, 7-9
return np.array([-Pr(e1) + Pr(e2) for e1, e2 in zip(wsp_bin_edges[:-1], wsp_bin_edges[1:])])
class DLCHighLevel(object):
......@@ -159,7 +189,7 @@ class DLCHighLevel(object):
dist = self.dlc_df[dist_key][row]
if str(dist).lower() == "weibull" or str(dist).lower() == "rayleigh":
dist = Weibull2(self.vref * .2, self.shape_k, values)
dist = Weibull_IEC(self.vref, values)
else:
def fmt(v):
if "#" in str(v):
......
......@@ -10,7 +10,7 @@ from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
import unittest
from wetb.dlc.high_level import DLCHighLevel, Weibull
from wetb.dlc.high_level import DLCHighLevel, Weibull, Weibull_IEC
import os
import numpy as np
......@@ -109,7 +109,10 @@ class TestDLCHighLevel(unittest.TestCase):
p_tot = np.array([value for key, value in weibull.items()]).sum()
self.assertTrue(np.allclose(p_tot, 1.0))
def test_weibull_IEC(self):
Vref = 50
np.testing.assert_array_almost_equal(Weibull_IEC(Vref, [4,6,8]), [ 0.11002961, 0.14116891, 0.15124155])
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
......
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