Skip to content

Commit 611f409

Browse files
committed
MAINT: rename singlediode_methods.py to just singlediode.py
* closes pvlib#515 * import pvlib in pvsystem and use pvlib.singlediode to differentiate from existing pvsystem.singldiode() method already there! * rename test_singlediode_methods.py to test_singlediode.py * update documentation and comments
1 parent 2a436c6 commit 611f409

File tree

8 files changed

+38
-38
lines changed

8 files changed

+38
-38
lines changed

docs/sphinx/source/api.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ Low-level functions for solving the single diode equation.
213213
.. autosummary::
214214
:toctree: generated/
215215

216-
singlediode_methods.estimate_voc
217-
singlediode_methods.bishop88
218-
singlediode_methods.bishop88_i_from_v
219-
singlediode_methods.bishop88_v_from_i
220-
singlediode_methods.bishop88_mpp
216+
singlediode.estimate_voc
217+
singlediode.bishop88
218+
singlediode.bishop88_i_from_v
219+
singlediode.bishop88_v_from_i
220+
singlediode.bishop88_mpp
221221

222222
SAPM model
223223
----------

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,32 @@ Enhancements
3232
``method`` in ``('lambertw', 'newton', 'brentq')``, default is ``'lambertw'``,
3333
to select a method to solve the single diode equation for points on the IV
3434
curve. Selecting either ``'brentq'`` or ``'newton'`` as the method uses
35-
:func:`~pvlib.singlediode_methods.bishop88` with the corresponding method.
35+
:func:`~pvlib.singlediode.bishop88` with the corresponding method.
3636
(:issue:`410`)
3737
* Implement new methods ``'brentq'`` and ``'newton'`` for solving the single
3838
diode equation for points on the IV curve. ``'brentq'`` uses a bisection
3939
method (Brent, 1973) that may be slow but guarantees a solution. ``'newton'``
4040
uses the Newton-Raphson method and may be faster but is not guaranteed to
4141
converge. However, ``'newton'`` should be safe for well-behaved IV curves.
4242
(:issue:`408`)
43-
* Implement :func:`~pvlib.singlediode_methods.bishop88` for explicit calculation
43+
* Implement :func:`~pvlib.singlediode.bishop88` for explicit calculation
4444
of arbitrary IV curve points using diode voltage instead of cell voltage. If
4545
``method`` is either ``'newton'`` or ``'brentq'`` and ``ivcurve_pnts`` in
4646
:func:`~pvlib.pvsystem.singlediode` is provided, the IV curve points will be
4747
log spaced instead of linear.
48-
* Implement :func:`~pvlib.singlediode_methods.estimate_voc` to estimate open
48+
* Implement :func:`~pvlib.singlediode.estimate_voc` to estimate open
4949
circuit voltage by assuming :math:`R_{sh} \to \infty` and :math:`R_s=0` as an
5050
upper bound in bisection method for :func:`~pvlib.pvsystem.singlediode` when
5151
method is either ``'newton'`` or ``'brentq'``.
5252
* Add :func:`~pvlib.pvsystem.max_power_point` method to compute the max power
5353
point using the new ``'brentq'`` method.
54-
* Add new module ``pvlib.singlediode_methods`` with low-level functions for
54+
* Add new module ``pvlib.singlediode`` with low-level functions for
5555
solving the single diode equation such as:
56-
:func:`~pvlib.singlediode_methods.bishop88`,
57-
:func:`~pvlib.singlediode_methods.estimate_voc`,
58-
:func:`~pvlib.singlediode_methods.bishop88_i_from_v`,
59-
:func:`~pvlib.singlediode_methods.bishop88_v_from_i`, and
60-
:func:`~pvlib.singlediode_methods.bishop88_mpp`.
56+
:func:`~pvlib.singlediode.bishop88`,
57+
:func:`~pvlib.singlediode.estimate_voc`,
58+
:func:`~pvlib.singlediode.bishop88_i_from_v`,
59+
:func:`~pvlib.singlediode.bishop88_v_from_i`, and
60+
:func:`~pvlib.singlediode.bishop88_mpp`.
6161
* Add PVSyst thin-film recombination losses for CdTe and a:Si (:issue:`163`)
6262
* Python 3.7 officially supported. (:issue:`496`)
6363

pvlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
from pvlib import pvsystem
1212
from pvlib import spa
1313
from pvlib import modelchain
14-
from pvlib import singlediode_methods
14+
from pvlib import singlediode

pvlib/pvsystem.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from pvlib.tools import _build_kwargs
2121
from pvlib.location import Location
2222
from pvlib import irradiance, atmosphere
23-
from pvlib import singlediode_methods
23+
import pvlib # FIXME: import singlediode module from pvlib
2424

2525

2626
# not sure if this belongs in the pvsystem module.
@@ -1963,7 +1963,7 @@ def singlediode(photocurrent, saturation_current, resistance_series,
19631963
open-circuit.
19641964
19651965
If the method is either ``'newton'`` or ``'brentq'`` and ``ivcurve_pnts``
1966-
are indicated, then :func:`pvlib.singlediode_methods.bishop88` is used to
1966+
are indicated, then :func:`pvlib.singlediode.bishop88` is used to
19671967
calculate the points on the IV curve points at diode voltages from zero to
19681968
open-circuit voltage with a log spacing that gets closer as voltage
19691969
increases. If the method is ``'lambertw'`` then the calculated points on
@@ -2029,12 +2029,12 @@ def singlediode(photocurrent, saturation_current, resistance_series,
20292029
--------
20302030
sapm
20312031
calcparams_desoto
2032-
pvlib.singlediode_methods.bishop88
2032+
pvlib.singlediode.bishop88
20332033
"""
20342034
# Calculate points on the IV curve using the LambertW solution to the
20352035
# single diode equation
20362036
if method.lower() == 'lambertw':
2037-
out = singlediode_methods._lambertw(
2037+
out = pvlib.singlediode._lambertw(
20382038
photocurrent, saturation_current, resistance_series,
20392039
resistance_shunt, nNsVth, ivcurve_pnts
20402040
)
@@ -2047,19 +2047,19 @@ def singlediode(photocurrent, saturation_current, resistance_series,
20472047
# equation for the diode voltage V_d then backing out voltage
20482048
args = (photocurrent, saturation_current, resistance_series,
20492049
resistance_shunt, nNsVth) # collect args
2050-
v_oc = singlediode_methods.bishop88_v_from_i(
2050+
v_oc = pvlib.singlediode.bishop88_v_from_i(
20512051
0.0, *args, method=method.lower()
20522052
)
2053-
i_mp, v_mp, p_mp = singlediode_methods.bishop88_mpp(
2053+
i_mp, v_mp, p_mp = pvlib.singlediode.bishop88_mpp(
20542054
*args, method=method.lower()
20552055
)
2056-
i_sc = singlediode_methods.bishop88_i_from_v(
2056+
i_sc = pvlib.singlediode.bishop88_i_from_v(
20572057
0.0, *args, method=method.lower()
20582058
)
2059-
i_x = singlediode_methods.bishop88_i_from_v(
2059+
i_x = pvlib.singlediode.bishop88_i_from_v(
20602060
v_oc / 2.0, *args, method=method.lower()
20612061
)
2062-
i_xx = singlediode_methods.bishop88_i_from_v(
2062+
i_xx = pvlib.singlediode.bishop88_i_from_v(
20632063
(v_oc + v_mp) / 2.0, *args, method=method.lower()
20642064
)
20652065

@@ -2069,7 +2069,7 @@ def singlediode(photocurrent, saturation_current, resistance_series,
20692069
(11.0 - np.logspace(np.log10(11.0), 0.0,
20702070
ivcurve_pnts)) / 10.0
20712071
)
2072-
ivcurve_i, ivcurve_v, _ = singlediode_methods.bishop88(vd, *args)
2072+
ivcurve_i, ivcurve_v, _ = pvlib.singlediode.bishop88(vd, *args)
20732073

20742074
out = OrderedDict()
20752075
out['i_sc'] = i_sc
@@ -2125,7 +2125,7 @@ def max_power_point(photocurrent, saturation_current, resistance_series,
21252125
curve. This function uses Brent's method by default because it is
21262126
guaranteed to converge.
21272127
"""
2128-
i_mp, v_mp, p_mp = singlediode_methods.bishop88_mpp(
2128+
i_mp, v_mp, p_mp = pvlib.singlediode.bishop88_mpp(
21292129
photocurrent, saturation_current, resistance_series,
21302130
resistance_shunt, nNsVth, method=method.lower()
21312131
)
@@ -2205,7 +2205,7 @@ def v_from_i(resistance_shunt, resistance_series, nNsVth, current,
22052205
Energy Materials and Solar Cells, 81 (2004) 269-277.
22062206
'''
22072207
if method.lower() == 'lambertw':
2208-
return singlediode_methods._lambertw_v_from_i(
2208+
return pvlib.singlediode._lambertw_v_from_i(
22092209
resistance_shunt, resistance_series, nNsVth, current,
22102210
saturation_current, photocurrent
22112211
)
@@ -2215,9 +2215,9 @@ def v_from_i(resistance_shunt, resistance_series, nNsVth, current,
22152215
# equation for the diode voltage V_d then backing out voltage
22162216
args = (current, photocurrent, saturation_current,
22172217
resistance_series, resistance_shunt, nNsVth)
2218-
V = singlediode_methods.bishop88_v_from_i(*args, method=method.lower())
2218+
V = pvlib.singlediode.bishop88_v_from_i(*args, method=method.lower())
22192219
# find the right size and shape for returns
2220-
size, shape = singlediode_methods._get_size_and_shape(args)
2220+
size, shape = pvlib.singlediode._get_size_and_shape(args)
22212221
if size <= 1:
22222222
if shape is not None:
22232223
V = np.tile(V, shape)
@@ -2293,7 +2293,7 @@ def i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
22932293
Energy Materials and Solar Cells, 81 (2004) 269-277.
22942294
'''
22952295
if method.lower() == 'lambertw':
2296-
return singlediode_methods._lambertw_i_from_v(
2296+
return pvlib.singlediode._lambertw_i_from_v(
22972297
resistance_shunt, resistance_series, nNsVth, voltage,
22982298
saturation_current, photocurrent
22992299
)
@@ -2303,9 +2303,9 @@ def i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
23032303
# equation for the diode voltage V_d then backing out voltage
23042304
args = (voltage, photocurrent, saturation_current, resistance_series,
23052305
resistance_shunt, nNsVth)
2306-
I = singlediode_methods.bishop88_i_from_v(*args, method=method.lower())
2306+
I = pvlib.singlediode.bishop88_i_from_v(*args, method=method.lower())
23072307
# find the right size and shape for returns
2308-
size, shape = singlediode_methods._get_size_and_shape(args)
2308+
size, shape = pvlib.singlediode._get_size_and_shape(args)
23092309
if size <= 1:
23102310
if shape is not None:
23112311
I = np.tile(I, shape)
File renamed without changes.

pvlib/test/test_numerical_precision.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
77
This module can be executed from the command line to generate a high precision
88
dataset of I-V curve points to test the explicit single diode calculations
9-
:func:`pvlib.singlediode_methods.bishop88`::
9+
:func:`pvlib.singlediode.bishop88`::
1010
1111
$ python test_numeric_precision.py
1212
1313
This generates a file in the pvlib data folder, which is specified by the
1414
constant ``DATA_PATH``. When the test is run using ``pytest`` it will compare
15-
the values calculated by :func:`pvlib.singlediode_methods.bishop88` with the
15+
the values calculated by :func:`pvlib.singlediode.bishop88` with the
1616
high-precision values generated with SymPy.
1717
"""
1818

@@ -21,7 +21,7 @@
2121
import numpy as np
2222
import pandas as pd
2323
from pvlib import pvsystem
24-
from pvlib.singlediode_methods import bishop88, estimate_voc
24+
from pvlib.singlediode import bishop88, estimate_voc
2525

2626
logging.basicConfig()
2727
LOGGER = logging.getLogger(__name__)

pvlib/test/test_singlediode_methods.py renamed to pvlib/test/test_singlediode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import numpy as np
66
from pvlib import pvsystem
7-
from pvlib.singlediode_methods import bishop88, estimate_voc, VOLTAGE_BUILTIN
7+
from pvlib.singlediode import bishop88, estimate_voc, VOLTAGE_BUILTIN
88
import pytest
99
from conftest import requires_scipy
1010

pvlib/tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ def _build_kwargs(keys, input_dict):
255255

256256

257257
# FIXME: remove _array_newton when SciPy-1.2.0 is released
258-
# pvlib.singlediode_methods.bishop88_i_from_v(..., method='newton') and other
259-
# functions in singlediode_methods call scipy.optimize.newton with a vector
258+
# pvlib.singlediode.bishop88_i_from_v(..., method='newton') and other
259+
# functions in singlediode call scipy.optimize.newton with a vector
260260
# unfortunately wrapping the functions with np.vectorize() was too slow
261261
# a vectorized newton method was merged into SciPy but isn't released yet, so
262262
# in the meantime, we just copied the relevant code: "_array_newton" for more

0 commit comments

Comments
 (0)