11import windpowerlib .modelchain as mc
22import windpowerlib .wind_turbine as wt
33from pandas .util .testing import assert_series_equal
4+ from numpy .testing import assert_array_equal , assert_allclose
45import pandas as pd
56import pytest
7+ import numpy as np
68
79
810class TestModelChain :
@@ -29,9 +31,13 @@ def test_v_wind_hub(self):
2931 'v_wind_2' : [4.0 , 5.0 ],
3032 'z0' : 0.15 },
3133 index = [0 , 1 ])
34+ weather_arr = {'v_wind' : np .array (weather ['v_wind' ]),
35+ 'v_wind_2' : np .array (weather ['v_wind_2' ]),
36+ 'z0' : 0.15 }
3237 data_height = {'v_wind' : 10 ,
3338 'v_wind_2' : 8 }
3439
40+ # Test weather dictionary with pandas.Series
3541 # v_wind is closer to hub height than v_wind_2
3642 v_wind_exp = pd .Series (data = [7.12462 , 9.26201 ])
3743 assert_series_equal (self .test_mc .v_wind_hub (weather , data_height ),
@@ -49,10 +55,13 @@ def test_v_wind_hub(self):
4955 assert_series_equal (
5056 self .test_mc .v_wind_hub (weather , data_height ),
5157 v_wind_exp )
52- # Test DataFrame
53- assert_series_equal (self .test_mc .v_wind_hub (weather_df ,
54- data_height ),
58+ # Test weather DataFrame
59+ assert_series_equal (self .test_mc .v_wind_hub (weather_df , data_height ),
5560 v_wind_exp )
61+ # Test weather dictionary with numpy.arrays
62+ v_wind_exp = np .array ([4.0 , 5.0 ])
63+ assert_array_equal (self .test_mc .v_wind_hub (weather_arr , data_height ),
64+ v_wind_exp )
5665
5766 def test_rho_hub (self ):
5867 weather = {'temp_air' : pd .Series (data = [267 , 268 ]),
@@ -62,6 +71,9 @@ def test_rho_hub(self):
6271 'temp_air_2' : [267 , 266 ],
6372 'pressure' : [101125 , 101000 ]},
6473 index = [0 , 1 ])
74+ weather_arr = {'temp_air' : np .array (weather ['temp_air' ]),
75+ 'temp_air_2' : np .array (weather ['temp_air_2' ]),
76+ 'pressure' : np .array (weather ['pressure' ])}
6577 data_height = {'temp_air' : 2 ,
6678 'temp_air_2' : 10 ,
6779 'pressure' : 0 }
@@ -84,6 +96,10 @@ def test_rho_hub(self):
8496 assert_series_equal (self .test_mc .rho_hub (weather_df ,
8597 data_height ),
8698 rho_exp )
99+ # Test weather dictionary with numpy.arrays
100+ rho_exp = np .array ([1.30305336 , 1.30631507 ])
101+ assert_allclose (self .test_mc .rho_hub (weather_arr , data_height ),
102+ rho_exp )
87103
88104 def test_run_model (self ):
89105 weather = {'temp_air' : pd .Series (data = [267 , 268 ]),
0 commit comments