Skip to content

Commit 4b1ba1d

Browse files
authored
pvlib.pvsystem.singlediode: remove deprecated ivcurve_pnts parameter (#2101)
* remove deprecated singlediode ivcurve_pnts parameter * whatsnew
1 parent c6547b5 commit 4b1ba1d

File tree

4 files changed

+17
-103
lines changed

4 files changed

+17
-103
lines changed

docs/sphinx/source/whatsnew/v0.11.0.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Breaking changes
1919
* :py:func:`~pvlib.iotools.get_psm3`, :py:func:`~pvlib.iotools.read_psm3`, and
2020
:py:func:`~pvlib.iotools.parse_psm3` all now have ``map_variables=True`` by
2121
default. (:issue:`1425`, :pull:`2094`)
22+
* The deprecated ``ivcurve_pnts`` parameter of :py:func:`pvlib.pvsystem.singlediode`
23+
is removed. Use :py:func:`pvlib.pvsystem.v_from_i` and
24+
:py:func:`pvlib.pvsystem.i_from_v` instead. (:pull:`2101`)
2225

2326

2427
Deprecations

pvlib/pvsystem.py

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -722,15 +722,13 @@ def _spectral_correction(array, pw):
722722
)
723723

724724
def singlediode(self, photocurrent, saturation_current,
725-
resistance_series, resistance_shunt, nNsVth,
726-
ivcurve_pnts=None):
725+
resistance_series, resistance_shunt, nNsVth):
727726
"""Wrapper around the :py:func:`pvlib.pvsystem.singlediode` function.
728727
729728
See :py:func:`pvsystem.singlediode` for details
730729
"""
731730
return singlediode(photocurrent, saturation_current,
732-
resistance_series, resistance_shunt, nNsVth,
733-
ivcurve_pnts=ivcurve_pnts)
731+
resistance_series, resistance_shunt, nNsVth)
734732

735733
def i_from_v(self, voltage, photocurrent, saturation_current,
736734
resistance_series, resistance_shunt, nNsVth):
@@ -2352,8 +2350,7 @@ def sapm_effective_irradiance(poa_direct, poa_diffuse, airmass_absolute, aoi,
23522350

23532351

23542352
def singlediode(photocurrent, saturation_current, resistance_series,
2355-
resistance_shunt, nNsVth, ivcurve_pnts=None,
2356-
method='lambertw'):
2353+
resistance_shunt, nNsVth, method='lambertw'):
23572354
r"""
23582355
Solve the single diode equation to obtain a photovoltaic IV curve.
23592356
@@ -2405,14 +2402,6 @@ def singlediode(photocurrent, saturation_current, resistance_series,
24052402
junction in Kelvin, and :math:`q` is the charge of an electron
24062403
(coulombs). ``0 < nNsVth``. [V]
24072404
2408-
ivcurve_pnts : int, optional
2409-
Number of points in the desired IV curve. If not specified or 0, no
2410-
points on the IV curves will be produced.
2411-
2412-
.. deprecated:: 0.10.0
2413-
Use :py:func:`pvlib.pvsystem.v_from_i` and
2414-
:py:func:`pvlib.pvsystem.i_from_v` instead.
2415-
24162405
method : str, default 'lambertw'
24172406
Determines the method used to calculate points on the IV curve. The
24182407
options are ``'lambertw'``, ``'newton'``, or ``'brentq'``.
@@ -2430,12 +2419,7 @@ def singlediode(photocurrent, saturation_current, resistance_series,
24302419
* i_x - current, in amperes, at ``v = 0.5*v_oc``.
24312420
* i_xx - current, in amperes, at ``v = 0.5*(v_oc+v_mp)``.
24322421
2433-
A dict is returned when the input parameters are scalars or
2434-
``ivcurve_pnts > 0``. If ``ivcurve_pnts > 0``, the output dictionary
2435-
will also include the keys:
2436-
2437-
* i - IV curve current in amperes.
2438-
* v - IV curve voltage in volts.
2422+
A dict is returned when the input parameters are scalars.
24392423
24402424
See also
24412425
--------
@@ -2459,13 +2443,6 @@ def singlediode(photocurrent, saturation_current, resistance_series,
24592443
that guarantees convergence by bounding the voltage between zero and
24602444
open-circuit.
24612445
2462-
If the method is either ``'newton'`` or ``'brentq'`` and ``ivcurve_pnts``
2463-
are indicated, then :func:`pvlib.singlediode.bishop88` [4]_ is used to
2464-
calculate the points on the IV curve points at diode voltages from zero to
2465-
open-circuit voltage with a log spacing that gets closer as voltage
2466-
increases. If the method is ``'lambertw'`` then the calculated points on
2467-
the IV curve are linearly spaced.
2468-
24692446
References
24702447
----------
24712448
.. [1] S.R. Wenham, M.A. Green, M.E. Watt, "Applied Photovoltaics" ISBN
@@ -2482,21 +2459,13 @@ def singlediode(photocurrent, saturation_current, resistance_series,
24822459
photovoltaic cell interconnection circuits" JW Bishop, Solar Cell (1988)
24832460
https://doi.org/10.1016/0379-6787(88)90059-2
24842461
"""
2485-
if ivcurve_pnts:
2486-
warn_deprecated('0.10.0', name='pvlib.pvsystem.singlediode',
2487-
alternative=('pvlib.pvsystem.v_from_i and '
2488-
'pvlib.pvsystem.i_from_v'),
2489-
obj_type='parameter ivcurve_pnts',
2490-
removal='0.11.0')
24912462
args = (photocurrent, saturation_current, resistance_series,
24922463
resistance_shunt, nNsVth) # collect args
24932464
# Calculate points on the IV curve using the LambertW solution to the
24942465
# single diode equation
24952466
if method.lower() == 'lambertw':
2496-
out = _singlediode._lambertw(*args, ivcurve_pnts)
2467+
out = _singlediode._lambertw(*args)
24972468
points = out[:7]
2498-
if ivcurve_pnts:
2499-
ivcurve_i, ivcurve_v = out[7:]
25002469
else:
25012470
# Calculate points on the IV curve using either 'newton' or 'brentq'
25022471
# methods. Voltages are determined by first solving the single diode
@@ -2518,21 +2487,10 @@ def singlediode(photocurrent, saturation_current, resistance_series,
25182487
)
25192488
points = i_sc, v_oc, i_mp, v_mp, p_mp, i_x, i_xx
25202489

2521-
# calculate the IV curve if requested using bishop88
2522-
if ivcurve_pnts:
2523-
vd = v_oc * (
2524-
(11.0 - np.logspace(np.log10(11.0), 0.0, ivcurve_pnts)) / 10.0
2525-
)
2526-
ivcurve_i, ivcurve_v, _ = _singlediode.bishop88(vd, *args)
2527-
25282490
columns = ('i_sc', 'v_oc', 'i_mp', 'v_mp', 'p_mp', 'i_x', 'i_xx')
25292491

2530-
if all(map(np.isscalar, args)) or ivcurve_pnts:
2492+
if all(map(np.isscalar, args)):
25312493
out = {c: p for c, p in zip(columns, points)}
2532-
2533-
if ivcurve_pnts:
2534-
out.update(i=ivcurve_i, v=ivcurve_v)
2535-
25362494
return out
25372495

25382496
points = np.atleast_1d(*points) # convert scalars to 1d-arrays

pvlib/tests/test_pvsystem.py

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import pandas as pd
77

88
import pytest
9-
from .conftest import (
10-
assert_series_equal, assert_frame_equal, fail_on_pvlib_version)
9+
from .conftest import assert_series_equal, assert_frame_equal
1110
from numpy.testing import assert_allclose
1211
import unittest.mock as mock
1312

@@ -1568,27 +1567,21 @@ def test_singlediode_floats():
15681567
assert_allclose(v, expected[k], atol=1e-6)
15691568

15701569

1571-
def test_singlediode_floats_ivcurve():
1572-
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
1573-
out = pvsystem.singlediode(7., 6e-7, .1, 20., .5, ivcurve_pnts=3,
1574-
method='lambertw')
1570+
def test_singlediode_floats_expected():
1571+
out = pvsystem.singlediode(7., 6e-7, .1, 20., .5, method='lambertw')
15751572
expected = {'i_xx': 4.264060478,
15761573
'i_mp': 6.136267360,
15771574
'v_oc': 8.106300147,
15781575
'p_mp': 38.19421055,
15791576
'i_x': 6.7558815684,
15801577
'i_sc': 6.965172322,
1581-
'v_mp': 6.224339375,
1582-
'i': np.array([
1583-
6.965172322, 6.755881568, 2.664535259e-14]),
1584-
'v': np.array([
1585-
0., 4.053150073, 8.106300147])}
1578+
'v_mp': 6.224339375}
15861579
assert isinstance(out, dict)
15871580
for k, v in out.items():
15881581
assert_allclose(v, expected[k], atol=1e-6)
15891582

15901583

1591-
def test_singlediode_series_ivcurve(cec_module_params):
1584+
def test_singlediode_series_expected(cec_module_params):
15921585
times = pd.date_range(start='2015-06-01', periods=3, freq='6h')
15931586
effective_irradiance = pd.Series([0.0, 400.0, 800.0], index=times)
15941587
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto(
@@ -1603,51 +1596,30 @@ def test_singlediode_series_ivcurve(cec_module_params):
16031596
EgRef=1.121,
16041597
dEgdT=-0.0002677)
16051598

1606-
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
1607-
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=3,
1608-
method='lambertw')
1599+
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, method='lambertw')
16091600

16101601
expected = OrderedDict([('i_sc', array([0., 3.01079860, 6.00726296])),
16111602
('v_oc', array([0., 9.96959733, 10.29603253])),
16121603
('i_mp', array([0., 2.656285960, 5.290525645])),
16131604
('v_mp', array([0., 8.321092255, 8.409413795])),
16141605
('p_mp', array([0., 22.10320053, 44.49021934])),
16151606
('i_x', array([0., 2.884132006, 5.746202281])),
1616-
('i_xx', array([0., 2.052691562, 3.909673879])),
1617-
('v', array([[0., 0., 0.],
1618-
[0., 4.984798663, 9.969597327],
1619-
[0., 5.148016266, 10.29603253]])),
1620-
('i', array([[0., 0., 0.],
1621-
[3.0107985972, 2.8841320056, 0.],
1622-
[6.0072629615, 5.7462022810, 0.]]))])
1607+
('i_xx', array([0., 2.052691562, 3.909673879]))])
16231608

16241609
for k, v in out.items():
16251610
assert_allclose(v, expected[k], atol=1e-2)
16261611

1627-
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
1628-
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=3)
1612+
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth)
16291613

16301614
expected['i_mp'] = pvsystem.i_from_v(out['v_mp'], IL, I0, Rs, Rsh, nNsVth,
16311615
method='lambertw')
16321616
expected['v_mp'] = pvsystem.v_from_i(out['i_mp'], IL, I0, Rs, Rsh, nNsVth,
16331617
method='lambertw')
1634-
expected['i'] = pvsystem.i_from_v(out['v'].T, IL, I0, Rs, Rsh, nNsVth,
1635-
method='lambertw').T
1636-
expected['v'] = pvsystem.v_from_i(out['i'].T, IL, I0, Rs, Rsh, nNsVth,
1637-
method='lambertw').T
16381618

16391619
for k, v in out.items():
16401620
assert_allclose(v, expected[k], atol=1e-6)
16411621

16421622

1643-
@fail_on_pvlib_version('0.11')
1644-
@pytest.mark.parametrize('method', ['lambertw', 'brentq', 'newton'])
1645-
def test_singlediode_ivcurvepnts_deprecation_warning(method):
1646-
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
1647-
pvsystem.singlediode(7., 6e-7, .1, 20., .5, ivcurve_pnts=3,
1648-
method=method)
1649-
1650-
16511623
def test_scale_voltage_current_power():
16521624
data = pd.DataFrame(
16531625
np.array([[2, 1.5, 10, 8, 12, 0.5, 1.5]]),

pvlib/tests/test_singlediode.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from pvlib import pvsystem
99
from pvlib.singlediode import (bishop88_mpp, estimate_voc, VOLTAGE_BUILTIN,
1010
bishop88, bishop88_i_from_v, bishop88_v_from_i)
11-
from pvlib._deprecation import pvlibDeprecationWarning
1211
import pytest
1312
from numpy.testing import assert_array_equal
1413
from .conftest import DATA_DIR
@@ -188,24 +187,6 @@ def test_singlediode_lambert_negative_voc(mocker):
188187
assert_array_equal(outs["v_oc"], [0, 0])
189188

190189

191-
@pytest.mark.parametrize('method', ['lambertw'])
192-
def test_ivcurve_pnts_precision(method, precise_iv_curves):
193-
"""
194-
Tests the accuracy of the IV curve points calcuated by singlediode. Only
195-
methods of singlediode that linearly spaced points are tested.
196-
"""
197-
x, pc = precise_iv_curves
198-
pc_i, pc_v = np.stack(pc['Currents']), np.stack(pc['Voltages'])
199-
ivcurve_pnts = len(pc['Currents'][0])
200-
201-
with pytest.warns(pvlibDeprecationWarning, match='ivcurve_pnts'):
202-
outs = pvsystem.singlediode(method=method, ivcurve_pnts=ivcurve_pnts,
203-
**x)
204-
205-
assert np.allclose(pc_i, outs['i'], atol=1e-10, rtol=0)
206-
assert np.allclose(pc_v, outs['v'], atol=1e-10, rtol=0)
207-
208-
209190
@pytest.mark.parametrize('method', ['lambertw', 'brentq', 'newton'])
210191
def test_v_from_i_i_from_v_precision(method, precise_iv_curves):
211192
"""

0 commit comments

Comments
 (0)