Skip to content

Commit c8f7920

Browse files
committed
only include i v keys if needed
1 parent 2c0cb3c commit c8f7920

File tree

1 file changed

+39
-35
lines changed

1 file changed

+39
-35
lines changed

pvlib/pvsystem.py

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,23 +1541,23 @@ def singlediode(photocurrent, saturation_current, resistance_series,
15411541
15421542
Parameters
15431543
----------
1544-
photocurrent : float or Series
1544+
photocurrent : numeric
15451545
Light-generated current (photocurrent) in amperes under desired
15461546
IV curve conditions. Often abbreviated ``I_L``.
15471547
1548-
saturation_current : float or Series
1548+
saturation_current : numeric
15491549
Diode saturation current in amperes under desired IV curve
15501550
conditions. Often abbreviated ``I_0``.
15511551
1552-
resistance_series : float or Series
1552+
resistance_series : numeric
15531553
Series resistance in ohms under desired IV curve conditions.
15541554
Often abbreviated ``Rs``.
15551555
1556-
resistance_shunt : float or Series
1556+
resistance_shunt : numeric
15571557
Shunt resistance in ohms under desired IV curve conditions.
15581558
Often abbreviated ``Rsh``.
15591559
1560-
nNsVth : float or Series
1560+
nNsVth : numeric
15611561
The product of three components. 1) The usual diode ideal factor
15621562
(n), 2) the number of cells in series (Ns), and 3) the cell
15631563
thermal voltage under the desired IV curve conditions (Vth). The
@@ -1572,22 +1572,29 @@ def singlediode(photocurrent, saturation_current, resistance_series,
15721572
15731573
Returns
15741574
-------
1575-
If photocurrent is a Series and ivcurve_pnts is None, a DataFrame
1576-
with the columns described below. All columns have the same number
1577-
of rows as the largest input DataFrame.
1578-
1579-
If photocurrent is a scalar or ivcurve_pnts is not None, an
1580-
OrderedDict with the following keys.
1581-
1582-
* i_sc - short circuit current in amperes.
1583-
* v_oc - open circuit voltage in volts.
1584-
* i_mp - current at maximum power point in amperes.
1585-
* v_mp - voltage at maximum power point in volts.
1586-
* p_mp - power at maximum power point in watts.
1587-
* i_x - current, in amperes, at ``v = 0.5*v_oc``.
1588-
* i_xx - current, in amperes, at ``V = 0.5*(v_oc+v_mp)``.
1589-
* i - None or iv curve current.
1590-
* v - None or iv curve voltage.
1575+
OrderedDict or DataFrame
1576+
1577+
The returned dict-like object always contains the keys/columns:
1578+
1579+
* i_sc - short circuit current in amperes.
1580+
* v_oc - open circuit voltage in volts.
1581+
* i_mp - current at maximum power point in amperes.
1582+
* v_mp - voltage at maximum power point in volts.
1583+
* p_mp - power at maximum power point in watts.
1584+
* i_x - current, in amperes, at ``v = 0.5*v_oc``.
1585+
* i_xx - current, in amperes, at ``V = 0.5*(v_oc+v_mp)``.
1586+
1587+
If ivcurve_pnts is greater than 0, the output dictionary will also
1588+
include the keys:
1589+
1590+
* i - IV curve current in amperes.
1591+
* v - IV curve voltage in volts.
1592+
1593+
The output will be an OrderedDict if photocurrent is a scalar,
1594+
array, or ivcurve_pnts is not None.
1595+
1596+
The output will be a DataFrame if photocurrent is a Series and
1597+
ivcurve_pnts is None.
15911598
15921599
Notes
15931600
-----
@@ -1641,27 +1648,24 @@ def singlediode(photocurrent, saturation_current, resistance_series,
16411648
i_xx = i_from_v(resistance_shunt, resistance_series, nNsVth,
16421649
0.5*(v_oc+v_mp), saturation_current, photocurrent)
16431650

1644-
# create ivcurve
1645-
if ivcurve_pnts:
1646-
ivcurve_v = (np.asarray(v_oc)[..., np.newaxis] *
1647-
np.linspace(0, 1, ivcurve_pnts))
1648-
ivcurve_i = i_from_v(
1649-
resistance_shunt, resistance_series, nNsVth, ivcurve_v.T,
1650-
saturation_current, photocurrent).T
1651-
else:
1652-
ivcurve_v = None
1653-
ivcurve_i = None
1654-
16551651
out = OrderedDict()
16561652
out['i_sc'] = i_sc
1657-
out['i_mp'] = i_mp
16581653
out['v_oc'] = v_oc
1654+
out['i_mp'] = i_mp
16591655
out['v_mp'] = v_mp
16601656
out['p_mp'] = p_mp
16611657
out['i_x'] = i_x
16621658
out['i_xx'] = i_xx
1663-
out['i'] = ivcurve_i
1664-
out['v'] = ivcurve_v
1659+
1660+
# create ivcurve
1661+
if ivcurve_pnts:
1662+
ivcurve_v = (np.asarray(v_oc)[..., np.newaxis] *
1663+
np.linspace(0, 1, ivcurve_pnts))
1664+
ivcurve_i = i_from_v(
1665+
resistance_shunt, resistance_series, nNsVth, ivcurve_v.T,
1666+
saturation_current, photocurrent).T
1667+
out['v'] = ivcurve_v
1668+
out['i'] = ivcurve_i
16651669

16661670
if isinstance(photocurrent, pd.Series) and not ivcurve_pnts:
16671671
out = pd.DataFrame(out, index=photocurrent.index)

0 commit comments

Comments
 (0)