1313
1414def linear_interpolation_extrapolation (df , target_height ):
1515 r"""
16- Inter - or extrapolates between the values of a data frame.
16+ Linear inter - or extrapolates between the values of a data frame.
1717
1818 This function can be used for the inter-/extrapolation of a parameter
1919 (e.g wind speed) available at two or more different heights, to approximate
@@ -73,6 +73,60 @@ def linear_interpolation_extrapolation(df, target_height):
7373 (target_height - heights_sorted [0 ]) + df [heights_sorted [0 ]])
7474
7575
76+ def logarithmic_interpolation_extrapolation (df , target_height ):
77+ r"""
78+ Logarithmic inter- or extrapolates between the values of a data frame.
79+
80+ This function can be used for the inter-/extrapolation of the wind speed if
81+ it is available at two or more different heights, to approximate
82+ the value at hub height. The function is carried out when the parameter
83+ `wind_speed_model` :class:`~.modelchain.ModelChain` class is
84+ 'log_interpolation_extrapolation'.
85+
86+ Parameters
87+ ----------
88+ df : pandas.DataFrame
89+ DataFrame with time series for parameter that is to be interpolated or
90+ extrapolated. The columns of the DataFrame are the different heights
91+ for which the parameter is available. If more than two heights are
92+ given, the two closest heights are used. See example in
93+ :py:func:`~.linear_interpolation_extrapolation` on how the
94+ DataFrame should look like and how the function can be used.
95+ target_height : float
96+ Height for which the parameter is approximated (e.g. hub height).
97+
98+ Returns
99+ -------
100+ pandas.Series
101+ Result of the inter-/extrapolation (e.g. wind speed at hub height).
102+
103+ Notes
104+ -----
105+
106+ For the logarithmic inter- and extrapolation the following equation is
107+ used [1]_:
108+
109+ .. math:: f(x) = \frac{\ln(x) \cdot (f(x_2) - f(x_1)) - f(x_2) \cdot \ln(x_1) + f(x_1) \cdot \ln(x_2)}{\ln(x_2) - \ln(x_1)}
110+
111+ References
112+ ----------
113+ .. [1] Knorr, K.: "Modellierung von raum-zeitlichen Eigenschaften der
114+ Windenergieeinspeisung für wetterdatenbasierte
115+ Windleistungssimulationen". Universität Kassel, Diss., 2016,
116+ p. 83
117+
118+ """
119+ # find closest heights
120+ heights_sorted = df .columns [
121+ sorted (range (len (df .columns )),
122+ key = lambda i : abs (df .columns [i ] - target_height ))]
123+ return ((np .log (target_height ) *
124+ (df [heights_sorted [1 ]] - df [heights_sorted [0 ]]) -
125+ df [heights_sorted [1 ]] * np .log (heights_sorted [0 ]) +
126+ df [heights_sorted [0 ]] * np .log (heights_sorted [1 ])) /
127+ (np .log (heights_sorted [1 ]) - np .log (heights_sorted [0 ])))
128+
129+
76130def gaussian_distribution (function_variable , standard_deviation , mean = 0 ):
77131 r"""
78132 Normal distribution or gaussian distribution.
@@ -105,7 +159,7 @@ def gaussian_distribution(function_variable, standard_deviation, mean=0):
105159 ----------
106160 .. [1] Berendsen, H.: "A Student's Guide to Data and Error Analysis".
107161 New York, Cambridge University Press, 2011, p. 37
108-
162+
109163 # TODO: add references
110164
111165 """
@@ -118,6 +172,29 @@ def estimate_turbulence_intensity(height, roughness_length):
118172 """
119173 Calculate turbulence intensity.
120174
175+ Parameters
176+ ----------
177+ height : Float
178+ Height above ground in m at which the turbulence intensity is
179+ calculated.
180+ roughness_length : pandas.Series or numpy.array or float
181+ Roughness length.
182+
183+ Notes
184+ -----
185+ The following equation is used [1]_:
186+
187+ .. math:: TI = \f rac{1}{ln \left(\f rac{h}{z_\t ext{0}} \r ight)}
188+
189+ with:
190+ TI: turbulence intensity, h: height, :math:`z_{0}`: roughness length
191+
192+ References
193+ ----------
194+ .. [1] Knorr, K.: "Modellierung von raum-zeitlichen Eigenschaften der
195+ Windenergieeinspeisung für wetterdatenbasierte
196+ Windleistungssimulationen". Universität Kassel, Diss., 2016,
197+ p. 88
198+
121199 """
122- # TODO: Search other possibilities for TI.
123200 return 1 / (np .log (height / roughness_length ))
0 commit comments