8
8
9
9
import numpy as np
10
10
11
+ import scipy .constants
12
+ from scipy import optimize
13
+ from scipy .special import lambertw
14
+
11
15
from pvlib .pvsystem import singlediode , v_from_i
12
16
13
17
from pvlib .ivtools .utility import constants , rectify_iv_curve , _numdiff
@@ -197,12 +201,6 @@ def fit_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc, cells_in_series,
197
201
2006.
198
202
"""
199
203
200
- try :
201
- from scipy .optimize import root
202
- import scipy .constants
203
- except ImportError :
204
- raise ImportError ("The fit_desoto function requires scipy." )
205
-
206
204
# Constants
207
205
k = scipy .constants .value ('Boltzmann constant in eV/K' )
208
206
Tref = temp_ref + 273.15 # [K]
@@ -222,8 +220,8 @@ def fit_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc, cells_in_series,
222
220
Tref , k )
223
221
224
222
# computing with system of equations described in [1]
225
- optimize_result = root (_system_of_equations_desoto , x0 = params_i ,
226
- args = (specs ,), ** root_kwargs )
223
+ optimize_result = optimize . root (_system_of_equations_desoto , x0 = params_i ,
224
+ args = (specs ,), ** root_kwargs )
227
225
228
226
if optimize_result .success :
229
227
sdm_params = optimize_result .x
@@ -657,8 +655,8 @@ def _fit_desoto_sandia_diode(ee, voc, vth, tc, specs, const):
657
655
try :
658
656
import statsmodels .api as sm
659
657
except ImportError :
660
- raise ImportError ('Parameter extraction using Sandia method requires' ,
661
- ' statsmodels' )
658
+ raise ImportError (
659
+ 'Parameter extraction using Sandia method requires statsmodels' )
662
660
663
661
x = specs ['cells_in_series' ] * vth * np .log (ee / const ['E0' ])
664
662
y = voc - specs ['beta_voc' ] * (tc - const ['T0' ])
@@ -791,11 +789,10 @@ def _extract_sdm_params(ee, tc, iph, io, rs, rsh, n, u, specs, const,
791
789
# Get single diode model parameters from five parameters iph, io, rs, rsh
792
790
# and n vs. effective irradiance and temperature
793
791
try :
794
- from scipy import optimize
795
792
import statsmodels .api as sm
796
793
except ImportError :
797
- raise ImportError ('Parameter extraction using Sandia method requires' ,
798
- ' scipy and statsmodels' )
794
+ raise ImportError (
795
+ 'Parameter extraction using Sandia method requires statsmodels' )
799
796
800
797
tck = tc + 273.15
801
798
tok = const ['T0' ] + 273.15 # convert to to K
@@ -1183,12 +1180,6 @@ def _calc_theta_phi_exact(vmp, imp, iph, io, rs, rsh, nnsvth):
1183
1180
real solar cells using Lambert W-function", Solar Energy Materials and
1184
1181
Solar Cells, 81 (2004) 269-277.
1185
1182
"""
1186
-
1187
- try :
1188
- from scipy .special import lambertw
1189
- except ImportError :
1190
- raise ImportError ('calc_theta_phi_exact requires scipy' )
1191
-
1192
1183
# handle singleton inputs
1193
1184
vmp = np .asarray (vmp )
1194
1185
imp = np .asarray (imp )
0 commit comments