1313import functools
1414from scipy .optimize import minimize
1515from pvlib .tools import cosd , sind , acosd
16+ from scipy .interpolate import make_interp_spline
1617
1718# a dict of required parameter names for each IAM model
1819# keys are the function names for the IAM models
@@ -469,9 +470,6 @@ def interp(aoi, theta_ref, iam_ref, method='linear', normalize=True):
469470 pvlib.iam.sapm
470471 '''
471472 # Contributed by Anton Driesse (@adriesse), PV Performance Labs. July, 2019
472-
473- from scipy .interpolate import make_interp_spline
474-
475473 # Scipy doesn't give the clearest feedback, so check number of points here.
476474 MIN_REF_VALS = {'linear' : 2 , 'quadratic' : 3 , 'cubic' : 4 , 1 : 2 , 2 : 3 , 3 : 4 }
477475
@@ -487,22 +485,13 @@ def interp(aoi, theta_ref, iam_ref, method='linear', normalize=True):
487485 iam_ref = np .asarray (iam_ref )
488486
489487 if method == "linear" :
490- spline = make_interp_spline (theta_ref , iam_ref , k = 1 )
491-
492- def interpolator (x ):
493- return spline (x )
488+ interpolator = make_interp_spline (theta_ref , iam_ref , k = 1 )
494489
495490 elif method == "quadratic" :
496- spline = make_interp_spline (theta_ref , iam_ref , k = 2 )
497-
498- def interpolator (x ):
499- return spline (x )
491+ interpolator = make_interp_spline (theta_ref , iam_ref , k = 2 )
500492
501493 elif method == "cubic" :
502- spline = make_interp_spline (theta_ref , iam_ref , k = 3 )
503-
504- def interpolator (x ):
505- return spline (x )
494+ interpolator = make_interp_spline (theta_ref , iam_ref , k = 3 )
506495
507496 else :
508497 raise ValueError (f"Invalid interpolation method '{ method } '." )
0 commit comments