22from datetime import datetime
33from pvlib .bifacial import pvfactors_timeseries
44from conftest import requires_pvfactors
5+ import pytest
56
67
78@requires_pvfactors
8- def test_pvfactors_timeseries ():
9+ @pytest .mark .parametrize ('run_parallel_calculations' ,
10+ [False , True ])
11+ def test_pvfactors_timeseries (run_parallel_calculations ):
912 """ Test that pvfactors is functional, using the TLDR section inputs of the
1013 package github repo README.md file:
1114 https://github.com/SunPower/pvfactors/blob/master/README.md#tldr---quick-start"""
@@ -18,6 +21,7 @@ def test_pvfactors_timeseries():
1821 solar_azimuth = [110. , 140. ]
1922 surface_tilt = [10. , 0. ]
2023 surface_azimuth = [90. , 90. ]
24+ axis_azimuth = 0.
2125 dni = [1000. , 300. ]
2226 dhi = [50. , 500. ]
2327 gcr = 0.4
@@ -31,42 +35,32 @@ def test_pvfactors_timeseries():
3135 horizon_band_angle = 15.
3236
3337 # Expected values
34- expected_ipoa_front = pd .Series ([1034.96216923 , 795.4423259 ],
38+ expected_ipoa_front = pd .Series ([1034.95474708997 , 795.4423259036623 ],
3539 index = timestamps ,
36- name = (1 , 'front' , 'qinc ' ))
37- expected_ipoa_back = pd .Series ([92.11871485 , 70.39404124 ],
40+ name = ('total_inc_front ' ))
41+ expected_ipoa_back = pd .Series ([91.88707460262768 , 78.05831585685215 ],
3842 index = timestamps ,
39- name = (1 , 'back' , 'qinc ' ))
43+ name = ('total_inc_back ' ))
4044
41- # Test serial calculations
42- ipoa_front , ipoa_back , df_registries = pvfactors_timeseries (
45+ # Run calculation
46+ ipoa_front , ipoa_back = pvfactors_timeseries (
4347 solar_azimuth , solar_zenith , surface_azimuth , surface_tilt ,
48+ axis_azimuth ,
4449 timestamps , dni , dhi , gcr , pvrow_height , pvrow_width , albedo ,
4550 n_pvrows = n_pvrows , index_observed_pvrow = index_observed_pvrow ,
4651 rho_front_pvrow = rho_front_pvrow , rho_back_pvrow = rho_back_pvrow ,
4752 horizon_band_angle = horizon_band_angle ,
48- run_parallel_calculations = False , n_workers_for_parallel_calcs = None )
53+ run_parallel_calculations = run_parallel_calculations ,
54+ n_workers_for_parallel_calcs = - 1 )
4955
5056 pd .testing .assert_series_equal (ipoa_front , expected_ipoa_front )
5157 pd .testing .assert_series_equal (ipoa_back , expected_ipoa_back )
52- pd .testing .assert_index_equal (timestamps , df_registries .index .unique ())
53-
54- # Run calculations in parallel
55- ipoa_front , ipoa_back , df_registries = pvfactors_timeseries (
56- solar_azimuth , solar_zenith , surface_azimuth , surface_tilt ,
57- timestamps , dni , dhi , gcr , pvrow_height , pvrow_width , albedo ,
58- n_pvrows = n_pvrows , index_observed_pvrow = index_observed_pvrow ,
59- rho_front_pvrow = rho_front_pvrow , rho_back_pvrow = rho_back_pvrow ,
60- horizon_band_angle = horizon_band_angle ,
61- run_parallel_calculations = True , n_workers_for_parallel_calcs = None )
62-
63- pd .testing .assert_series_equal (ipoa_front , expected_ipoa_front )
64- pd .testing .assert_series_equal (ipoa_back , expected_ipoa_back )
65- pd .testing .assert_index_equal (timestamps , df_registries .index .unique ())
6658
6759
6860@requires_pvfactors
69- def test_pvfactors_timeseries_pandas_inputs ():
61+ @pytest .mark .parametrize ('run_parallel_calculations' ,
62+ [False , True ])
63+ def test_pvfactors_timeseries_pandas_inputs (run_parallel_calculations ):
7064 """ Test that pvfactors is functional, using the TLDR section inputs of the
7165 package github repo README.md file, but converted to pandas Series:
7266 https://github.com/SunPower/pvfactors/blob/master/README.md#tldr---quick-start"""
@@ -79,6 +73,7 @@ def test_pvfactors_timeseries_pandas_inputs():
7973 solar_azimuth = pd .Series ([110. , 140. ])
8074 surface_tilt = pd .Series ([10. , 0. ])
8175 surface_azimuth = pd .Series ([90. , 90. ])
76+ axis_azimuth = 0.
8277 dni = pd .Series ([1000. , 300. ])
8378 dhi = pd .Series ([50. , 500. ])
8479 gcr = 0.4
@@ -92,35 +87,23 @@ def test_pvfactors_timeseries_pandas_inputs():
9287 horizon_band_angle = 15.
9388
9489 # Expected values
95- expected_ipoa_front = pd .Series ([1034.96216923 , 795.4423259 ],
90+ expected_ipoa_front = pd .Series ([1034.95474708997 , 795.4423259036623 ],
9691 index = timestamps ,
97- name = (1 , 'front' , 'qinc ' ))
98- expected_ipoa_back = pd .Series ([92.11871485 , 70.39404124 ],
92+ name = ('total_inc_front ' ))
93+ expected_ipoa_back = pd .Series ([91.88707460262768 , 78.05831585685215 ],
9994 index = timestamps ,
100- name = (1 , 'back' , 'qinc' ))
101-
102- # Test serial calculations
103- ipoa_front , ipoa_back , df_registries = pvfactors_timeseries (
104- solar_azimuth , solar_zenith , surface_azimuth , surface_tilt ,
105- timestamps , dni , dhi , gcr , pvrow_height , pvrow_width , albedo ,
106- n_pvrows = n_pvrows , index_observed_pvrow = index_observed_pvrow ,
107- rho_front_pvrow = rho_front_pvrow , rho_back_pvrow = rho_back_pvrow ,
108- horizon_band_angle = horizon_band_angle ,
109- run_parallel_calculations = False , n_workers_for_parallel_calcs = None )
110-
111- pd .testing .assert_series_equal (ipoa_front , expected_ipoa_front )
112- pd .testing .assert_series_equal (ipoa_back , expected_ipoa_back )
113- pd .testing .assert_index_equal (timestamps , df_registries .index .unique ())
95+ name = ('total_inc_back' ))
11496
115- # Run calculations in parallel
116- ipoa_front , ipoa_back , df_registries = pvfactors_timeseries (
97+ # Run calculation
98+ ipoa_front , ipoa_back = pvfactors_timeseries (
11799 solar_azimuth , solar_zenith , surface_azimuth , surface_tilt ,
100+ axis_azimuth ,
118101 timestamps , dni , dhi , gcr , pvrow_height , pvrow_width , albedo ,
119102 n_pvrows = n_pvrows , index_observed_pvrow = index_observed_pvrow ,
120103 rho_front_pvrow = rho_front_pvrow , rho_back_pvrow = rho_back_pvrow ,
121104 horizon_band_angle = horizon_band_angle ,
122- run_parallel_calculations = True , n_workers_for_parallel_calcs = None )
105+ run_parallel_calculations = run_parallel_calculations ,
106+ n_workers_for_parallel_calcs = - 1 )
123107
124108 pd .testing .assert_series_equal (ipoa_front , expected_ipoa_front )
125109 pd .testing .assert_series_equal (ipoa_back , expected_ipoa_back )
126- pd .testing .assert_index_equal (timestamps , df_registries .index .unique ())
0 commit comments