Skip to content

Commit 53c7a99

Browse files
committed
Adjust function for displaying wind efficiency curves to changes
1 parent e2f7bb9 commit 53c7a99

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

windpowerlib/wake_losses.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,32 +128,28 @@ def display_wind_efficiency_curves():
128128
p. 124
129129
130130
"""
131-
path = os.path.join(os.path.dirname(__file__), 'data',
132-
'wind_efficiency_curves.csv')
133-
# Read all curves from file
134-
wind_efficiency_curves = pd.read_csv(path)
135-
# Initialize data frame for plot
136-
curves_df = pd.DataFrame()
137-
for curve_name in [col for col in list(wind_efficiency_curves) if
138-
'x_' not in col]:
139-
# Get wind efficiency curve for standard wind speeds from
140-
# read_wind_efficiency_curve() and add to data frame
141-
efficiency_curve = get_wind_efficiency_curve(
142-
curve_name).rename(
143-
columns={'efficiency': curve_name.replace('_', ' '),
144-
'wind_speed': 'wind speed m/s'}).set_index(
145-
'wind speed m/s')
146-
curves_df = pd.concat([curves_df, efficiency_curve], axis=1)
131+
origins = ['dena', 'knorr']
132+
paths = [os.path.join(os.path.dirname(__file__), 'data',
133+
'wind_efficiency_curves_{}.csv'.format(origin)) for
134+
origin in origins]
135+
# Read wind efficiency curves from files
147136
# Create separate data frames for origin of curve
148-
knorr_df = curves_df[[column_name for column_name in curves_df if
149-
'knorr' in column_name]]
150-
dena_df = curves_df[[column_name for column_name in curves_df if
151-
'dena' in column_name]]
137+
dena_df = pd.read_csv(paths[0])
138+
knorr_df = pd.read_csv(paths[1])
139+
# Print names of all available curves
140+
curves_list = [col for col in dena_df if 'wind_speed' not in col]
141+
curves_list.extend([col for col in knorr_df if 'wind_speed' not in col])
142+
print("Names of the provided wind efficiency curves are the " +
143+
"following: {}".format(curves_list))
152144
if plt:
145+
# Create data frames for plot
146+
dena_df.set_index('wind_speed', inplace=True)
147+
knorr_df.set_index('wind_speed', inplace=True)
153148
fig, ax = plt.subplots()
154-
dena_df.plot(ax=ax, legend=True, marker='x', markersize=3)
155-
knorr_df.plot(ax=ax, legend=True, marker='o', markersize=3)
149+
dena_df.plot(ax=ax, legend=True)
150+
knorr_df.plot(ax=ax, legend=True)
156151
plt.ylabel('Wind farm efficiency')
152+
plt.xlabel('Wind speed m/s')
157153
plt.show()
158154
else:
159155
print(dena_df)

0 commit comments

Comments
 (0)