Skip to content

Commit 7195548

Browse files
mikofskiwholmgren
authored andcommitted
STY: BUG: fix pvsystem imports pvlib twice (#562)
* from pvlib import singlediode as _singlediode # to differentiate from local function pvsystem.singlediode * replace pvlib.singlediode with _singlediode everywhere * remove extra line and whitespace around FC_MODEL_PARAMS
1 parent 05b0674 commit 7195548

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

pvlib/pvsystem.py

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,29 @@
1919
from pvlib import tools
2020
from pvlib.tools import _build_kwargs
2121
from pvlib.location import Location
22-
from pvlib import irradiance, atmosphere
23-
import pvlib # use pvlib.singlediode to avoid clash with local method
22+
from pvlib import irradiance, atmosphere, singlediode as _singlediode
2423

2524

2625
# a dict of required parameter names for each DC power model
27-
28-
DC_MODEL_PARAMS = {'sapm' :
29-
set(['A0', 'A1', 'A2', 'A3', 'A4', 'B0', 'B1', 'B2', 'B3',
30-
'B4', 'B5', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6',
31-
'C7', 'Isco', 'Impo', 'Aisc', 'Aimp', 'Bvoco',
32-
'Mbvoc', 'Bvmpo', 'Mbvmp', 'N', 'Cells_in_Series',
33-
'IXO', 'IXXO', 'FD']),
34-
'desoto' :
35-
set(['alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref',
36-
'R_sh_ref', 'R_s']),
37-
'pvsyst' :
38-
set(['gamma_ref', 'mu_gamma', 'I_L_ref', 'I_o_ref',
39-
'R_sh_ref', 'R_sh_0', 'R_s', 'alpha_sc', 'EgRef',
40-
'cells_in_series']),
41-
'singlediode' :
42-
set(['alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref',
43-
'R_sh_ref', 'R_s']),
44-
'pvwatts' :
45-
set(['pdc0', 'gamma_pdc'])
46-
}
26+
DC_MODEL_PARAMS = {
27+
'sapm' : set([
28+
'A0', 'A1', 'A2', 'A3', 'A4', 'B0', 'B1', 'B2', 'B3',
29+
'B4', 'B5', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6',
30+
'C7', 'Isco', 'Impo', 'Aisc', 'Aimp', 'Bvoco',
31+
'Mbvoc', 'Bvmpo', 'Mbvmp', 'N', 'Cells_in_Series',
32+
'IXO', 'IXXO', 'FD']),
33+
'desoto' : set([
34+
'alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref',
35+
'R_sh_ref', 'R_s']),
36+
'pvsyst' : set([
37+
'gamma_ref', 'mu_gamma', 'I_L_ref', 'I_o_ref',
38+
'R_sh_ref', 'R_sh_0', 'R_s', 'alpha_sc', 'EgRef',
39+
'cells_in_series']),
40+
'singlediode' : set([
41+
'alpha_sc', 'a_ref', 'I_L_ref', 'I_o_ref',
42+
'R_sh_ref', 'R_s']),
43+
'pvwatts' : set(['pdc0', 'gamma_pdc'])
44+
}
4745

4846

4947
# not sure if this belongs in the pvsystem module.
@@ -2019,7 +2017,7 @@ def singlediode(photocurrent, saturation_current, resistance_series,
20192017
# Calculate points on the IV curve using the LambertW solution to the
20202018
# single diode equation
20212019
if method.lower() == 'lambertw':
2022-
out = pvlib.singlediode._lambertw(
2020+
out = _singlediode._lambertw(
20232021
photocurrent, saturation_current, resistance_series,
20242022
resistance_shunt, nNsVth, ivcurve_pnts
20252023
)
@@ -2032,19 +2030,19 @@ def singlediode(photocurrent, saturation_current, resistance_series,
20322030
# equation for the diode voltage V_d then backing out voltage
20332031
args = (photocurrent, saturation_current, resistance_series,
20342032
resistance_shunt, nNsVth) # collect args
2035-
v_oc = pvlib.singlediode.bishop88_v_from_i(
2033+
v_oc = _singlediode.bishop88_v_from_i(
20362034
0.0, *args, method=method.lower()
20372035
)
2038-
i_mp, v_mp, p_mp = pvlib.singlediode.bishop88_mpp(
2036+
i_mp, v_mp, p_mp = _singlediode.bishop88_mpp(
20392037
*args, method=method.lower()
20402038
)
2041-
i_sc = pvlib.singlediode.bishop88_i_from_v(
2039+
i_sc = _singlediode.bishop88_i_from_v(
20422040
0.0, *args, method=method.lower()
20432041
)
2044-
i_x = pvlib.singlediode.bishop88_i_from_v(
2042+
i_x = _singlediode.bishop88_i_from_v(
20452043
v_oc / 2.0, *args, method=method.lower()
20462044
)
2047-
i_xx = pvlib.singlediode.bishop88_i_from_v(
2045+
i_xx = _singlediode.bishop88_i_from_v(
20482046
(v_oc + v_mp) / 2.0, *args, method=method.lower()
20492047
)
20502048

@@ -2054,7 +2052,7 @@ def singlediode(photocurrent, saturation_current, resistance_series,
20542052
(11.0 - np.logspace(np.log10(11.0), 0.0,
20552053
ivcurve_pnts)) / 10.0
20562054
)
2057-
ivcurve_i, ivcurve_v, _ = pvlib.singlediode.bishop88(vd, *args)
2055+
ivcurve_i, ivcurve_v, _ = _singlediode.bishop88(vd, *args)
20582056

20592057
out = OrderedDict()
20602058
out['i_sc'] = i_sc
@@ -2110,7 +2108,7 @@ def max_power_point(photocurrent, saturation_current, resistance_series,
21102108
curve. This function uses Brent's method by default because it is
21112109
guaranteed to converge.
21122110
"""
2113-
i_mp, v_mp, p_mp = pvlib.singlediode.bishop88_mpp(
2111+
i_mp, v_mp, p_mp = _singlediode.bishop88_mpp(
21142112
photocurrent, saturation_current, resistance_series,
21152113
resistance_shunt, nNsVth, method=method.lower()
21162114
)
@@ -2190,7 +2188,7 @@ def v_from_i(resistance_shunt, resistance_series, nNsVth, current,
21902188
Energy Materials and Solar Cells, 81 (2004) 269-277.
21912189
'''
21922190
if method.lower() == 'lambertw':
2193-
return pvlib.singlediode._lambertw_v_from_i(
2191+
return _singlediode._lambertw_v_from_i(
21942192
resistance_shunt, resistance_series, nNsVth, current,
21952193
saturation_current, photocurrent
21962194
)
@@ -2200,9 +2198,9 @@ def v_from_i(resistance_shunt, resistance_series, nNsVth, current,
22002198
# equation for the diode voltage V_d then backing out voltage
22012199
args = (current, photocurrent, saturation_current,
22022200
resistance_series, resistance_shunt, nNsVth)
2203-
V = pvlib.singlediode.bishop88_v_from_i(*args, method=method.lower())
2201+
V = _singlediode.bishop88_v_from_i(*args, method=method.lower())
22042202
# find the right size and shape for returns
2205-
size, shape = pvlib.singlediode._get_size_and_shape(args)
2203+
size, shape = _singlediode._get_size_and_shape(args)
22062204
if size <= 1:
22072205
if shape is not None:
22082206
V = np.tile(V, shape)
@@ -2278,7 +2276,7 @@ def i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
22782276
Energy Materials and Solar Cells, 81 (2004) 269-277.
22792277
'''
22802278
if method.lower() == 'lambertw':
2281-
return pvlib.singlediode._lambertw_i_from_v(
2279+
return _singlediode._lambertw_i_from_v(
22822280
resistance_shunt, resistance_series, nNsVth, voltage,
22832281
saturation_current, photocurrent
22842282
)
@@ -2288,9 +2286,9 @@ def i_from_v(resistance_shunt, resistance_series, nNsVth, voltage,
22882286
# equation for the diode voltage V_d then backing out voltage
22892287
args = (voltage, photocurrent, saturation_current, resistance_series,
22902288
resistance_shunt, nNsVth)
2291-
I = pvlib.singlediode.bishop88_i_from_v(*args, method=method.lower())
2289+
I = _singlediode.bishop88_i_from_v(*args, method=method.lower())
22922290
# find the right size and shape for returns
2293-
size, shape = pvlib.singlediode._get_size_and_shape(args)
2291+
size, shape = _singlediode._get_size_and_shape(args)
22942292
if size <= 1:
22952293
if shape is not None:
22962294
I = np.tile(I, shape)

0 commit comments

Comments
 (0)