Skip to content

Commit 680dd73

Browse files
committed
Change parameter names for easier readability
and adapt tests and docstrings to new names
1 parent 2ae8db6 commit 680dd73

File tree

11 files changed

+260
-234
lines changed

11 files changed

+260
-234
lines changed

example/basic_example.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
" 'turbine_name': 'myTurbine',\n",
192192
" 'nominal_power': 3e6, # in W\n",
193193
" 'hub_height': 105, # in m\n",
194-
" 'd_rotor': 90, # in m\n",
194+
" 'rotor_diameter': 90, # in m\n",
195195
" 'p_values': pd.DataFrame(\n",
196196
" data={'p': [p * 1000 for p in\n",
197197
" [0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]]}, # in W\n",
@@ -215,7 +215,7 @@
215215
"enerconE126 = {\n",
216216
" 'turbine_name': 'ENERCON E 126 7500', # turbine name as in register\n",
217217
" 'hub_height': 135, # in m\n",
218-
" 'd_rotor': 127 # in m\n",
218+
" 'rotor_diameter': 127 # in m\n",
219219
" }\n",
220220
"# initialise WindTurbine object\n",
221221
"e126 = wt.WindTurbine(**enerconE126)"
@@ -339,7 +339,7 @@
339339
"language_info": {
340340
"codemirror_mode": {
341341
"name": "ipython",
342-
"version": 3
342+
"version": 3.0
343343
},
344344
"file_extension": ".py",
345345
"mimetype": "text/x-python",
@@ -350,5 +350,5 @@
350350
}
351351
},
352352
"nbformat": 4,
353-
"nbformat_minor": 2
354-
}
353+
"nbformat_minor": 0
354+
}

example/basic_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def initialise_wind_turbines():
129129
'turbine_name': 'myTurbine',
130130
'nominal_power': 3e6, # in W
131131
'hub_height': 105, # in m
132-
'd_rotor': 90, # in m
132+
'rotor_diameter': 90, # in m
133133
'p_values': pd.DataFrame(
134134
data={'p': [p * 1000 for p in
135135
[0.0, 26.0, 180.0, 1500.0, 3000.0, 3000.0]]}, # in W
@@ -144,7 +144,7 @@ def initialise_wind_turbines():
144144
enerconE126 = {
145145
'turbine_name': 'ENERCON E 126 7500', # turbine name as in register
146146
'hub_height': 135, # in m
147-
'd_rotor': 127 # in m
147+
'rotor_diameter': 127 # in m
148148
}
149149
# initialise WindTurbine object
150150
e126 = wt.WindTurbine(**enerconE126)

tests/test_density.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,70 @@
99
class TestDensityTemperature:
1010

1111
def test_temperature_gradient(self):
12-
parameters = {'temp_air': pd.Series(data=[267, 268]),
13-
'temp_height': 2,
12+
parameters = {'temperature': pd.Series(data=[267, 268]),
13+
'temperature_height': 2,
1414
'hub_height': 100}
1515

16-
# Test temp_air as pd.Series
16+
# Test temperature as pd.Series
1717
temp_hub_exp = pd.Series(data=[266.363, 267.36300])
1818
assert_series_equal(temperature_gradient(**parameters), temp_hub_exp)
1919

20-
# Test temp_air as np.array
20+
# Test temperature as np.array
2121
temp_hub_exp = np.array([266.363, 267.36300])
22-
parameters['temp_air'] = np.array(parameters['temp_air'])
22+
parameters['temperature'] = np.array(parameters['temperature'])
2323
assert_array_equal(temperature_gradient(**parameters), temp_hub_exp)
2424
assert isinstance(temperature_gradient(**parameters), np.ndarray)
2525

2626
def test_rho_barometric(self):
2727
parameters = {'pressure': pd.Series(data=[101125, 101000]),
2828
'pressure_height': 0,
2929
'hub_height': 100,
30-
'temp_hub': pd.Series(data=[267, 268])}
30+
'temperature_hub_height': pd.Series(data=[267, 268])}
3131

32-
# Test pressure as pd.Series and temp_hub as pd.Series and np.array
32+
# Test pressure as pd.Series and temperature_hub_height as pd.Series
33+
# and np.array
3334
rho_exp = pd.Series(data=[1.30305336, 1.29656645])
3435
assert_series_equal(rho_barometric(**parameters), rho_exp)
35-
parameters['temp_hub'] = np.array(parameters['temp_hub'])
36+
parameters['temperature_hub_height'] = np.array(
37+
parameters['temperature_hub_height'])
3638
assert_series_equal(rho_barometric(**parameters), rho_exp)
3739

38-
# Test pressure as np.array and temp_hub as pd.Series
40+
# Test pressure as np.array and temperature_hub_height as pd.Series
3941
parameters['pressure'] = np.array(parameters['pressure'])
40-
parameters['temp_hub'] = pd.Series(data=parameters['temp_hub'])
42+
parameters['temperature_hub_height'] = pd.Series(
43+
data=parameters['temperature_hub_height'])
4144
assert_series_equal(rho_barometric(**parameters), rho_exp)
4245

43-
# Test pressure as np.array and temp_hub as np.array
46+
# Test pressure as np.array and temperature_hub_height as np.array
4447
rho_exp = np.array([1.30305336, 1.29656645])
45-
parameters['temp_hub'] = np.array(parameters['temp_hub'])
48+
parameters['temperature_hub_height'] = np.array(
49+
parameters['temperature_hub_height'])
4650
assert_allclose(rho_barometric(**parameters), rho_exp)
4751
assert isinstance(rho_barometric(**parameters), np.ndarray)
4852

4953
def test_rho_ideal_gas(self):
5054
parameters = {'pressure': pd.Series(data=[101125, 101000]),
5155
'pressure_height': 0,
5256
'hub_height': 100,
53-
'temp_hub': pd.Series(data=[267, 268])}
57+
'temperature_hub_height': pd.Series(data=[267, 268])}
5458

55-
# Test pressure as pd.Series and temp_hub as pd.Series and np.array
59+
# Test pressure as pd.Series and temperature_hub_height as pd.Series
60+
# and np.array
5661
rho_exp = pd.Series(data=[1.30309439, 1.29660728])
5762
assert_series_equal(rho_ideal_gas(**parameters), rho_exp)
58-
parameters['temp_hub'] = np.array(parameters['temp_hub'])
63+
parameters['temperature_hub_height'] = np.array(
64+
parameters['temperature_hub_height'])
5965
assert_series_equal(rho_ideal_gas(**parameters), rho_exp)
6066

61-
# Test pressure as np.array and temp_hub as pd.Series
67+
# Test pressure as np.array and temperature_hub_height as pd.Series
6268
parameters['pressure'] = np.array(parameters['pressure'])
63-
parameters['temp_hub'] = pd.Series(data=parameters['temp_hub'])
69+
parameters['temperature_hub_height'] = pd.Series(
70+
data=parameters['temperature_hub_height'])
6471
assert_allclose(rho_ideal_gas(**parameters), rho_exp)
6572

66-
# Test pressure as np.array and temp_hub as np.array
73+
# Test pressure as np.array and temperature_hub_height as np.array
6774
rho_exp = np.array([1.30309439, 1.29660728])
68-
parameters['temp_hub'] = np.array(parameters['temp_hub'])
75+
parameters['temperature_hub_height'] = np.array(
76+
parameters['temperature_hub_height'])
6977
assert_allclose(rho_ideal_gas(**parameters), rho_exp)
7078
assert isinstance(rho_ideal_gas(**parameters), np.ndarray)

tests/test_modelchain.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TestModelChain:
1212
@classmethod
1313
def setup_class(self):
1414
self.test_turbine = {'hub_height': 100,
15-
'd_rotor': 80,
15+
'rotor_diameter': 80,
1616
'turbine_name': 'ENERCON E 126 7500'}
1717

1818
def test_rho_hub(self):
@@ -236,7 +236,7 @@ def test_run_model(self):
236236
'temp_air_2': 10,
237237
'pressure': 0}
238238
test_turbine = {'hub_height': 100,
239-
'd_rotor': 80,
239+
'rotor_diameter': 80,
240240
'turbine_name': 'ENERCON E 126 7500',
241241
'fetch_curve': 'p'}
242242
test_modelchain = {'wind_model': 'hellman',
@@ -326,7 +326,7 @@ def test_run_model(self):
326326
# Raise TypeErrors due to missing cp- or p-values
327327
with pytest.raises(TypeError):
328328
turbine1 = {'hub_height': 100,
329-
'd_rotor': 80,
329+
'rotor_diameter': 80,
330330
'turbine_name': 'ENERCON E 126 7500',
331331
'fetch_curve': 'p'}
332332
modelchain1 = {'wind_model': 'hellman',
@@ -338,7 +338,7 @@ def test_run_model(self):
338338
test_mc.run_model(weather, data_height)
339339
with pytest.raises(TypeError):
340340
turbine2 = {'hub_height': 100,
341-
'd_rotor': 80,
341+
'rotor_diameter': 80,
342342
'turbine_name': 'ENERCON E 126 7500',
343343
'fetch_curve': 'cp'}
344344
modelchain2 = {'wind_model': 'hellman',

tests/test_power_output.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,93 +9,93 @@
99
class TestPowerOutput:
1010

1111
def test_cp_curve(self):
12-
parameters = {'v_wind': pd.Series(data=[2.0, 5.5, 7.0]),
13-
'rho_hub': pd.Series(data=[1.3, 1.3, 1.3]),
14-
'd_rotor': 80,
12+
parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]),
13+
'density': pd.Series(data=[1.3, 1.3, 1.3]),
14+
'rotor_diameter': 80,
1515
'cp_values': pd.DataFrame(data={'cp': [0.3, 0.4, 0.5]},
1616
index=[4.0, 5.0, 6.0])}
1717

18-
# Test v_wind as pd.Series with rho_hub as pd.Series and np.array
18+
# Test wind_speed as pd.Series with density as pd.Series and np.array
1919
power_output_exp = pd.Series(data=[0.0, 244615.399, 0.0],
2020
name='feedin_wind_turbine')
2121
assert_series_equal(cp_curve(**parameters), power_output_exp)
22-
parameters['rho_hub'] = np.array(parameters['rho_hub'])
22+
parameters['density'] = np.array(parameters['density'])
2323
assert_series_equal(cp_curve(**parameters), power_output_exp)
2424

25-
# Test v_wind as np.array with rho_hub as np.array and pd.Series
25+
# Test wind_speed as np.array with density as np.array and pd.Series
2626
power_output_exp = np.array([0.0, 244615.399, 0.0])
27-
parameters['v_wind'] = np.array(parameters['v_wind'])
27+
parameters['wind_speed'] = np.array(parameters['wind_speed'])
2828
assert_allclose(cp_curve(**parameters), power_output_exp)
2929
assert isinstance(cp_curve(**parameters), np.ndarray)
30-
parameters['rho_hub'] = pd.Series(data=parameters['rho_hub'])
30+
parameters['density'] = pd.Series(data=parameters['density'])
3131
assert_allclose(cp_curve(**parameters), power_output_exp)
3232
assert isinstance(cp_curve(**parameters), np.ndarray)
3333

3434
def test_cp_curve_density_corrected(self):
35-
parameters = {'v_wind': pd.Series(data=[2.0, 5.5, 7.0]),
36-
'rho_hub': pd.Series(data=[1.3, 1.3, 1.3]),
37-
'd_rotor': 80,
35+
parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]),
36+
'density': pd.Series(data=[1.3, 1.3, 1.3]),
37+
'rotor_diameter': 80,
3838
'cp_values': pd.DataFrame(data={'cp': [0.3, 0.4, 0.5]},
3939
index=[4.0, 5.0, 6.0])}
4040

41-
# Test v_wind as pd.Series with rho_hub as pd.Series and np.array
41+
# Test wind_speed as pd.Series with density as pd.Series and np.array
4242
power_output_exp = pd.Series(data=[0.0, 262869.785, 0.0],
4343
name='feedin_wind_turbine')
4444
assert_series_equal(cp_curve_density_corr(**parameters),
4545
power_output_exp)
46-
parameters['rho_hub'] = np.array(parameters['rho_hub'])
46+
parameters['density'] = np.array(parameters['density'])
4747
assert_series_equal(cp_curve_density_corr(**parameters),
4848
power_output_exp)
4949

50-
# Test v_wind as np.array with rho_hub as np.array and pd.Series
50+
# Test wind_speed as np.array with density as np.array and pd.Series
5151
power_output_exp = np.array([0.0, 262869.785, 0.0])
52-
parameters['v_wind'] = np.array(parameters['v_wind'])
52+
parameters['wind_speed'] = np.array(parameters['wind_speed'])
5353
assert_allclose(cp_curve_density_corr(**parameters),
5454
power_output_exp)
5555
assert isinstance(cp_curve_density_corr(**parameters), np.ndarray)
56-
parameters['rho_hub'] = pd.Series(data=parameters['rho_hub'])
56+
parameters['density'] = pd.Series(data=parameters['density'])
5757
assert_allclose(cp_curve_density_corr(**parameters),
5858
power_output_exp)
5959
assert isinstance(cp_curve_density_corr(**parameters), np.ndarray)
6060

6161
def test_p_curve(self):
62-
parameters = {'v_wind': pd.Series(data=[2.0, 5.5, 7.0]),
62+
parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]),
6363
'p_values': pd.DataFrame(data={'p': [300, 400, 500]},
6464
index=[4.0, 5.0, 6.0])}
6565

66-
# Test v_wind as pd.Series
66+
# Test wind_speed as pd.Series
6767
power_output_exp = pd.Series(data=[0.0, 450.0, 0.0],
6868
name='feedin_wind_turbine')
6969
assert_series_equal(p_curve(**parameters), power_output_exp)
7070

71-
# Test v_wind as np.array
71+
# Test wind_speed as np.array
7272
power_output_exp = np.array([0.0, 450.0, 0.0])
73-
parameters['v_wind'] = np.array(parameters['v_wind'])
73+
parameters['wind_speed'] = np.array(parameters['wind_speed'])
7474
assert_allclose(p_curve(**parameters), power_output_exp)
7575
assert isinstance(p_curve(**parameters), np.ndarray)
7676

7777
def test_p_curve_density_corrected(self):
78-
parameters = {'v_wind': pd.Series(data=[2.0, 5.5, 7.0]),
79-
'rho_hub': pd.Series(data=[1.3, 1.3, 1.3]),
78+
parameters = {'wind_speed': pd.Series(data=[2.0, 5.5, 7.0]),
79+
'density': pd.Series(data=[1.3, 1.3, 1.3]),
8080
'p_values': pd.DataFrame(data={'p': [300, 400, 500]},
8181
index=[4.0, 5.0, 6.0])}
8282

83-
# Test v_wind as pd.Series with rho_hub as pd.Series and np.array
83+
# Test wind_speed as pd.Series with density as pd.Series and np.array
8484
power_output_exp = pd.Series(data=[0.0, 461.00290572, 0.0],
8585
name='feedin_wind_turbine')
8686
assert_series_equal(p_curve_density_corr(**parameters),
8787
power_output_exp)
88-
parameters['rho_hub'] = np.array(parameters['rho_hub'])
88+
parameters['density'] = np.array(parameters['density'])
8989
assert_series_equal(p_curve_density_corr(**parameters),
9090
power_output_exp)
9191

92-
# Test v_wind as np.array with rho_hub as np.array and pd.Series
92+
# Test wind_speed as np.array with density as np.array and pd.Series
9393
power_output_exp = np.array([0.0, 461.00290572, 0.0])
94-
parameters['v_wind'] = np.array(parameters['v_wind'])
94+
parameters['wind_speed'] = np.array(parameters['wind_speed'])
9595
assert_allclose(p_curve_density_corr(**parameters),
9696
power_output_exp)
9797
assert isinstance(p_curve_density_corr(**parameters), np.ndarray)
98-
parameters['rho_hub'] = pd.Series(data=parameters['rho_hub'])
98+
parameters['density'] = pd.Series(data=parameters['density'])
9999
assert_allclose(p_curve_density_corr(**parameters),
100100
power_output_exp)
101101
assert isinstance(p_curve_density_corr(**parameters), np.ndarray)

0 commit comments

Comments
 (0)