2
2
from datetime import datetime
3
3
from pvlib .bifacial import pvfactors_timeseries
4
4
from conftest import requires_pvfactors
5
+ import pytest
5
6
6
7
7
8
@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 ):
9
12
""" Test that pvfactors is functional, using the TLDR section inputs of the
10
13
package github repo README.md file:
11
14
https://github.com/SunPower/pvfactors/blob/master/README.md#tldr---quick-start"""
@@ -18,6 +21,7 @@ def test_pvfactors_timeseries():
18
21
solar_azimuth = [110. , 140. ]
19
22
surface_tilt = [10. , 0. ]
20
23
surface_azimuth = [90. , 90. ]
24
+ axis_azimuth = 0.
21
25
dni = [1000. , 300. ]
22
26
dhi = [50. , 500. ]
23
27
gcr = 0.4
@@ -31,42 +35,32 @@ def test_pvfactors_timeseries():
31
35
horizon_band_angle = 15.
32
36
33
37
# Expected values
34
- expected_ipoa_front = pd .Series ([1034.96216923 , 795.4423259 ],
38
+ expected_ipoa_front = pd .Series ([1034.95474708997 , 795.4423259036623 ],
35
39
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 ],
38
42
index = timestamps ,
39
- name = (1 , 'back' , 'qinc ' ))
43
+ name = ('total_inc_back ' ))
40
44
41
- # Test serial calculations
42
- ipoa_front , ipoa_back , df_registries = pvfactors_timeseries (
45
+ # Run calculation
46
+ ipoa_front , ipoa_back = pvfactors_timeseries (
43
47
solar_azimuth , solar_zenith , surface_azimuth , surface_tilt ,
48
+ axis_azimuth ,
44
49
timestamps , dni , dhi , gcr , pvrow_height , pvrow_width , albedo ,
45
50
n_pvrows = n_pvrows , index_observed_pvrow = index_observed_pvrow ,
46
51
rho_front_pvrow = rho_front_pvrow , rho_back_pvrow = rho_back_pvrow ,
47
52
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 )
49
55
50
56
pd .testing .assert_series_equal (ipoa_front , expected_ipoa_front )
51
57
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 ())
66
58
67
59
68
60
@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 ):
70
64
""" Test that pvfactors is functional, using the TLDR section inputs of the
71
65
package github repo README.md file, but converted to pandas Series:
72
66
https://github.com/SunPower/pvfactors/blob/master/README.md#tldr---quick-start"""
@@ -79,6 +73,7 @@ def test_pvfactors_timeseries_pandas_inputs():
79
73
solar_azimuth = pd .Series ([110. , 140. ])
80
74
surface_tilt = pd .Series ([10. , 0. ])
81
75
surface_azimuth = pd .Series ([90. , 90. ])
76
+ axis_azimuth = 0.
82
77
dni = pd .Series ([1000. , 300. ])
83
78
dhi = pd .Series ([50. , 500. ])
84
79
gcr = 0.4
@@ -92,35 +87,23 @@ def test_pvfactors_timeseries_pandas_inputs():
92
87
horizon_band_angle = 15.
93
88
94
89
# Expected values
95
- expected_ipoa_front = pd .Series ([1034.96216923 , 795.4423259 ],
90
+ expected_ipoa_front = pd .Series ([1034.95474708997 , 795.4423259036623 ],
96
91
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 ],
99
94
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' ))
114
96
115
- # Run calculations in parallel
116
- ipoa_front , ipoa_back , df_registries = pvfactors_timeseries (
97
+ # Run calculation
98
+ ipoa_front , ipoa_back = pvfactors_timeseries (
117
99
solar_azimuth , solar_zenith , surface_azimuth , surface_tilt ,
100
+ axis_azimuth ,
118
101
timestamps , dni , dhi , gcr , pvrow_height , pvrow_width , albedo ,
119
102
n_pvrows = n_pvrows , index_observed_pvrow = index_observed_pvrow ,
120
103
rho_front_pvrow = rho_front_pvrow , rho_back_pvrow = rho_back_pvrow ,
121
104
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 )
123
107
124
108
pd .testing .assert_series_equal (ipoa_front , expected_ipoa_front )
125
109
pd .testing .assert_series_equal (ipoa_back , expected_ipoa_back )
126
- pd .testing .assert_index_equal (timestamps , df_registries .index .unique ())
0 commit comments