Skip to content

Commit b55f74d

Browse files
committed
deprecate npoints and vectorize parameters
1 parent f20d78e commit b55f74d

File tree

3 files changed

+49
-23
lines changed

3 files changed

+49
-23
lines changed

pvlib/bifacial/infinite_sheds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _shaded_fraction(solar_zenith, solar_azimuth, surface_tilt,
182182
def get_irradiance_poa(surface_tilt, surface_azimuth, solar_zenith,
183183
solar_azimuth, gcr, height, pitch, ghi, dhi, dni,
184184
albedo, model='isotropic', dni_extra=None, iam=1.0,
185-
npoints=100, vectorize=False):
185+
npoints=None, vectorize=None):
186186
r"""
187187
Calculate plane-of-array (POA) irradiance on one side of a row of modules.
188188
@@ -379,7 +379,7 @@ def get_irradiance(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
379379
gcr, height, pitch, ghi, dhi, dni,
380380
albedo, model='isotropic', dni_extra=None, iam_front=1.0,
381381
iam_back=1.0, bifaciality=0.8, shade_factor=-0.02,
382-
transmission_factor=0, npoints=100, vectorize=False):
382+
transmission_factor=0, npoints=None, vectorize=None):
383383
"""
384384
Get front and rear irradiance using the infinite sheds model.
385385

pvlib/tests/bifacial/test_infinite_sheds.py

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from pvlib.bifacial import infinite_sheds
88
from ..conftest import assert_series_equal
99

10+
from pvlib._deprecation import pvlibDeprecationWarning
11+
1012
import pytest
1113

1214

@@ -92,11 +94,10 @@ def test_get_irradiance_poa():
9294
dni = 700
9395
albedo = 0
9496
iam = 1.0
95-
npoints = 100
9697
res = infinite_sheds.get_irradiance_poa(
9798
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
9899
gcr, height, pitch, ghi, dhi, dni,
99-
albedo, iam=iam, npoints=npoints)
100+
albedo, iam=iam)
100101
expected_diffuse = np.array([300.])
101102
expected_direct = np.array([700.])
102103
expected_global = expected_diffuse + expected_direct
@@ -118,7 +119,7 @@ def test_get_irradiance_poa():
118119
res = infinite_sheds.get_irradiance_poa(
119120
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
120121
gcr, height, pitch, ghi, dhi, dni,
121-
albedo, iam=iam, npoints=npoints)
122+
albedo, iam=iam)
122123
assert np.allclose(res['poa_global'], expected_global)
123124
assert np.allclose(res['poa_diffuse'], expected_diffuse)
124125
assert np.allclose(res['poa_direct'], expected_direct)
@@ -136,7 +137,7 @@ def test_get_irradiance_poa():
136137
res = infinite_sheds.get_irradiance_poa(
137138
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
138139
gcr, height, pitch, ghi, dhi, dni,
139-
albedo, iam=iam, npoints=npoints)
140+
albedo, iam=iam)
140141
assert isinstance(res, pd.DataFrame)
141142
assert_series_equal(res['poa_global'], expected_global)
142143
assert all(k in res.columns for k in [
@@ -152,8 +153,7 @@ def test__backside_tilt():
152153
assert np.allclose(back_az, np.array([0., 330., 90., 180.]))
153154

154155

155-
@pytest.mark.parametrize("vectorize", [True, False])
156-
def test_get_irradiance(vectorize):
156+
def test_get_irradiance():
157157
# singleton inputs
158158
solar_zenith = 0.
159159
solar_azimuth = 180.
@@ -168,12 +168,10 @@ def test_get_irradiance(vectorize):
168168
albedo = 0.
169169
iam_front = 1.0
170170
iam_back = 1.0
171-
npoints = 100
172171
result = infinite_sheds.get_irradiance(
173172
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
174173
gcr, height, pitch, ghi, dhi, dni, albedo, iam_front, iam_back,
175-
bifaciality=0.8, shade_factor=-0.02, transmission_factor=0,
176-
npoints=npoints, vectorize=vectorize)
174+
bifaciality=0.8, shade_factor=-0.02, transmission_factor=0)
177175
expected_front_diffuse = np.array([300.])
178176
expected_front_direct = np.array([700.])
179177
expected_front_global = expected_front_diffuse + expected_front_direct
@@ -190,19 +188,42 @@ def test_get_irradiance(vectorize):
190188
result = infinite_sheds.get_irradiance(
191189
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
192190
gcr, height, pitch, ghi, dhi, dni, albedo, iam_front, iam_back,
193-
bifaciality=0.8, shade_factor=-0.02, transmission_factor=0,
194-
npoints=npoints, vectorize=vectorize)
191+
bifaciality=0.8, shade_factor=-0.02, transmission_factor=0)
195192
result_front = infinite_sheds.get_irradiance_poa(
196193
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
197194
gcr, height, pitch, ghi, dhi, dni,
198-
albedo, iam=iam_front, vectorize=vectorize)
195+
albedo, iam=iam_front)
199196
assert isinstance(result, pd.DataFrame)
200197
expected_poa_global = pd.Series(
201198
[1000., 500., result_front['poa_global'][2] * (1 + 0.8 * 0.98),
202199
np.nan], index=ghi.index, name='poa_global')
203200
assert_series_equal(result['poa_global'], expected_poa_global)
204201

205202

203+
def test_get_irradiance_deprecated():
204+
kwargs = {"surface_tilt": 0, "surface_azimuth": 0, "solar_zenith": 0,
205+
"solar_azimuth": 0, "gcr": 0.5, "height": 1, "pitch": 1,
206+
"ghi": 1000, "dhi": 200, "dni": 800, "albedo": 0.2}
207+
208+
with pytest.warns(pvlibDeprecationWarning, match="have no effect"):
209+
_ = infinite_sheds.get_irradiance(**kwargs, npoints=10)
210+
211+
with pytest.warns(pvlibDeprecationWarning, match="have no effect"):
212+
_ = infinite_sheds.get_irradiance(**kwargs, vectorize=True)
213+
214+
215+
def test_get_irradiance_poa_deprecated():
216+
kwargs = {"surface_tilt": 0, "surface_azimuth": 0, "solar_zenith": 0,
217+
"solar_azimuth": 0, "gcr": 0.5, "height": 1, "pitch": 1,
218+
"ghi": 1000, "dhi": 200, "dni": 800, "albedo": 0.2}
219+
220+
with pytest.warns(pvlibDeprecationWarning, match="have no effect"):
221+
_ = infinite_sheds.get_irradiance_poa(**kwargs, npoints=10)
222+
223+
with pytest.warns(pvlibDeprecationWarning, match="have no effect"):
224+
_ = infinite_sheds.get_irradiance_poa(**kwargs, vectorize=True)
225+
226+
206227
def test_get_irradiance_limiting_gcr():
207228
# test confirms that irradiance on widely spaced rows is approximately
208229
# the same as for a single row array
@@ -219,12 +240,10 @@ def test_get_irradiance_limiting_gcr():
219240
albedo = 1.
220241
iam_front = 1.0
221242
iam_back = 1.0
222-
npoints = 100
223243
result = infinite_sheds.get_irradiance(
224244
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
225245
gcr, height, pitch, ghi, dhi, dni, albedo, iam_front, iam_back,
226-
bifaciality=1., shade_factor=-0.00, transmission_factor=0.,
227-
npoints=npoints)
246+
bifaciality=1., shade_factor=-0.00, transmission_factor=0.)
228247
expected_ground_diffuse = np.array([500.])
229248
expected_sky_diffuse = np.array([150.])
230249
expected_direct = np.array([0.])
@@ -263,12 +282,11 @@ def test_get_irradiance_with_haydavies():
263282
model = 'haydavies'
264283
iam_front = 1.0
265284
iam_back = 1.0
266-
npoints = 100
267285
result = infinite_sheds.get_irradiance(
268286
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
269287
gcr, height, pitch, ghi, dhi, dni, albedo, model, dni_extra,
270288
iam_front, iam_back, bifaciality=0.8, shade_factor=-0.02,
271-
transmission_factor=0, npoints=npoints)
289+
transmission_factor=0)
272290
expected_front_diffuse = np.array([151.38])
273291
expected_front_direct = np.array([848.62])
274292
expected_front_global = expected_front_diffuse + expected_front_direct
@@ -282,4 +300,4 @@ def test_get_irradiance_with_haydavies():
282300
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
283301
gcr, height, pitch, ghi, dhi, dni, albedo, model, None,
284302
iam_front, iam_back, bifaciality=0.8, shade_factor=-0.02,
285-
transmission_factor=0, npoints=npoints)
303+
transmission_factor=0)

pvlib/tests/bifacial/test_utils.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pvlib.shading import masking_angle, ground_angle
88
from pvlib.tools import cosd
99

10+
from pvlib._deprecation import pvlibDeprecationWarning
1011

1112
@pytest.fixture
1213
def test_system_fixed_tilt():
@@ -90,19 +91,26 @@ def test__vf_ground_sky_2d(test_system_fixed_tilt):
9091
assert np.isclose(vf, vfs_gnd_sky[0])
9192

9293

93-
@pytest.mark.parametrize("vectorize", [True, False])
94-
def test_vf_ground_sky_2d_integ(test_system_fixed_tilt, vectorize):
94+
def test_vf_ground_sky_2d_integ(test_system_fixed_tilt):
9595
ts, pts, vfs_gnd_sky = test_system_fixed_tilt
9696
# pass rotation here since max_rows=1 for the hand-solved case in
9797
# the fixture test_system, which means the ground-to-sky view factor
9898
# isn't summed over enough rows for symmetry to hold.
9999
vf_integ = utils.vf_ground_sky_2d_integ(
100100
ts['rotation'], ts['gcr'], ts['height'], ts['pitch'],
101-
max_rows=1, npoints=3, vectorize=vectorize)
101+
max_rows=1, npoints=3)
102102
expected_vf_integ = np.trapz(vfs_gnd_sky, pts, axis=0)
103103
assert np.isclose(vf_integ, expected_vf_integ, rtol=0.1)
104104

105105

106+
def test_vf_ground_sky_2d_integ_deprecated():
107+
with pytest.warns(pvlibDeprecationWarning, match="have no effect"):
108+
_ = utils.vf_ground_sky_2d_integ(0, 0.5, 1, 1, npoints=10)
109+
110+
with pytest.warns(pvlibDeprecationWarning, match="have no effect"):
111+
_ = utils.vf_ground_sky_2d_integ(0, 0.5, 1, 1, vectorize=True)
112+
113+
106114
def test_vf_row_sky_2d(test_system_fixed_tilt):
107115
ts, _, _ = test_system_fixed_tilt
108116
# with float input, fx at top of row

0 commit comments

Comments
 (0)