Skip to content

Commit d7fce07

Browse files
committed
only include i v keys if needed
1 parent c69164a commit d7fce07

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
@@ -1550,23 +1550,23 @@ def singlediode(photocurrent, saturation_current, resistance_series,
15501550
15511551
Parameters
15521552
----------
1553-
photocurrent : float or Series
1553+
photocurrent : numeric
15541554
Light-generated current (photocurrent) in amperes under desired
15551555
IV curve conditions. Often abbreviated ``I_L``.
15561556
1557-
saturation_current : float or Series
1557+
saturation_current : numeric
15581558
Diode saturation current in amperes under desired IV curve
15591559
conditions. Often abbreviated ``I_0``.
15601560
1561-
resistance_series : float or Series
1561+
resistance_series : numeric
15621562
Series resistance in ohms under desired IV curve conditions.
15631563
Often abbreviated ``Rs``.
15641564
1565-
resistance_shunt : float or Series
1565+
resistance_shunt : numeric
15661566
Shunt resistance in ohms under desired IV curve conditions.
15671567
Often abbreviated ``Rsh``.
15681568
1569-
nNsVth : float or Series
1569+
nNsVth : numeric
15701570
The product of three components. 1) The usual diode ideal factor
15711571
(n), 2) the number of cells in series (Ns), and 3) the cell
15721572
thermal voltage under the desired IV curve conditions (Vth). The
@@ -1581,22 +1581,29 @@ def singlediode(photocurrent, saturation_current, resistance_series,
15811581
15821582
Returns
15831583
-------
1584-
If photocurrent is a Series and ivcurve_pnts is None, a DataFrame
1585-
with the columns described below. All columns have the same number
1586-
of rows as the largest input DataFrame.
1587-
1588-
If photocurrent is a scalar or ivcurve_pnts is not None, an
1589-
OrderedDict with the following keys.
1590-
1591-
* i_sc - short circuit current in amperes.
1592-
* v_oc - open circuit voltage in volts.
1593-
* i_mp - current at maximum power point in amperes.
1594-
* v_mp - voltage at maximum power point in volts.
1595-
* p_mp - power at maximum power point in watts.
1596-
* i_x - current, in amperes, at ``v = 0.5*v_oc``.
1597-
* i_xx - current, in amperes, at ``V = 0.5*(v_oc+v_mp)``.
1598-
* i - None or iv curve current.
1599-
* v - None or iv curve voltage.
1584+
OrderedDict or DataFrame
1585+
1586+
The returned dict-like object always contains the keys/columns:
1587+
1588+
* i_sc - short circuit current in amperes.
1589+
* v_oc - open circuit voltage in volts.
1590+
* i_mp - current at maximum power point in amperes.
1591+
* v_mp - voltage at maximum power point in volts.
1592+
* p_mp - power at maximum power point in watts.
1593+
* i_x - current, in amperes, at ``v = 0.5*v_oc``.
1594+
* i_xx - current, in amperes, at ``V = 0.5*(v_oc+v_mp)``.
1595+
1596+
If ivcurve_pnts is greater than 0, the output dictionary will also
1597+
include the keys:
1598+
1599+
* i - IV curve current in amperes.
1600+
* v - IV curve voltage in volts.
1601+
1602+
The output will be an OrderedDict if photocurrent is a scalar,
1603+
array, or ivcurve_pnts is not None.
1604+
1605+
The output will be a DataFrame if photocurrent is a Series and
1606+
ivcurve_pnts is None.
16001607
16011608
Notes
16021609
-----
@@ -1650,27 +1657,24 @@ def singlediode(photocurrent, saturation_current, resistance_series,
16501657
i_xx = i_from_v(resistance_shunt, resistance_series, nNsVth,
16511658
0.5*(v_oc+v_mp), saturation_current, photocurrent)
16521659

1653-
# create ivcurve
1654-
if ivcurve_pnts:
1655-
ivcurve_v = (np.asarray(v_oc)[..., np.newaxis] *
1656-
np.linspace(0, 1, ivcurve_pnts))
1657-
ivcurve_i = i_from_v(
1658-
resistance_shunt, resistance_series, nNsVth, ivcurve_v.T,
1659-
saturation_current, photocurrent).T
1660-
else:
1661-
ivcurve_v = None
1662-
ivcurve_i = None
1663-
16641660
out = OrderedDict()
16651661
out['i_sc'] = i_sc
1666-
out['i_mp'] = i_mp
16671662
out['v_oc'] = v_oc
1663+
out['i_mp'] = i_mp
16681664
out['v_mp'] = v_mp
16691665
out['p_mp'] = p_mp
16701666
out['i_x'] = i_x
16711667
out['i_xx'] = i_xx
1672-
out['i'] = ivcurve_i
1673-
out['v'] = ivcurve_v
1668+
1669+
# create ivcurve
1670+
if ivcurve_pnts:
1671+
ivcurve_v = (np.asarray(v_oc)[..., np.newaxis] *
1672+
np.linspace(0, 1, ivcurve_pnts))
1673+
ivcurve_i = i_from_v(
1674+
resistance_shunt, resistance_series, nNsVth, ivcurve_v.T,
1675+
saturation_current, photocurrent).T
1676+
out['v'] = ivcurve_v
1677+
out['i'] = ivcurve_i
16741678

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

0 commit comments

Comments
 (0)