Skip to content

Commit

Permalink
Fixing style errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
stickler-ci committed Dec 12, 2019
1 parent dda3b45 commit fb4f10b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
39 changes: 29 additions & 10 deletions windpowerlib/power_output.py
Expand Up @@ -237,18 +237,37 @@ def power_curve_density_correction(
"""
if density is None:
raise TypeError("`density` is None. For the calculation with a " +
"density corrected power curve density at hub " +
"height is needed.")
power_output=[(np.interp(
wind_speed[i], power_curve_wind_speeds * (1.225 / density[i]) ** (
np.interp(power_curve_wind_speeds, [7.5, 12.5], [1/3, 2/3])),
power_curve_values, left=0, right=0)) for i in range(len(wind_speed))]
raise TypeError(
"`density` is None. For the calculation with a "
+ "density corrected power curve density at hub "
+ "height is needed."
)
power_output = [
(
np.interp(
wind_speed[i],
power_curve_wind_speeds
* (1.225 / density[i])
** (
np.interp(
power_curve_wind_speeds, [7.5, 12.5], [1 / 3, 2 / 3]
)
),
power_curve_values,
left=0,
right=0,
)
)
for i in range(len(wind_speed))
]

# Power_output as pd.Series if wind_speed is pd.Series (else: np.array)
if isinstance(wind_speed, pd.Series):
power_output=pd.Series(data=power_output, index=wind_speed.index,
name='feedin_power_plant')
power_output = pd.Series(
data=power_output,
index=wind_speed.index,
name="feedin_power_plant",
)
else:
power_output=np.array(power_output)
power_output = np.array(power_output)
return power_output
11 changes: 6 additions & 5 deletions windpowerlib/wind_speed.py
Expand Up @@ -171,10 +171,11 @@ def hellman(
if hellman_exponent is None:
if roughness_length is not None:
# Return np.array if wind_speed is np.array
if (isinstance(wind_speed, np.ndarray) and
isinstance(roughness_length, pd.Series)):
roughness_length=np.array(roughness_length)
hellman_exponent=1 / np.log(hub_height / roughness_length)
if isinstance(wind_speed, np.ndarray) and isinstance(
roughness_length, pd.Series
):
roughness_length = np.array(roughness_length)
hellman_exponent = 1 / np.log(hub_height / roughness_length)
else:
hellman_exponent=1/7
hellman_exponent = 1 / 7
return wind_speed * (hub_height / wind_speed_height) ** hellman_exponent

0 comments on commit fb4f10b

Please sign in to comment.