-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Replace interp1d #2394 #2741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jason-rpkt
wants to merge
6
commits into
pvlib:main
Choose a base branch
from
jason-rpkt:replace_interp1d
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+65
−27
Open
Replace interp1d #2394 #2741
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8773810
Replace interp1d #2394
jason-rpkt ab6c74f
Replace CubicSpline by make_interp_spline k=3
jason-rpkt c658199
clean up/ simplify/move import to top
jason-rpkt 486cf38
remove list input
jason-rpkt e1ccae7
Remove ifinstance check/Use np.interp
jason-rpkt 2797f37
linting
jason-rpkt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| import functools | ||
| from scipy.optimize import minimize | ||
| from pvlib.tools import cosd, sind, acosd | ||
| from scipy.interpolate import make_interp_spline | ||
|
|
||
| # a dict of required parameter names for each IAM model | ||
| # keys are the function names for the IAM models | ||
|
|
@@ -440,7 +441,7 @@ def interp(aoi, theta_ref, iam_ref, method='linear', normalize=True): | |
| method : str, default 'linear' | ||
| Specifies the interpolation method. | ||
| Useful options are: 'linear', 'quadratic', 'cubic'. | ||
| See scipy.interpolate.interp1d for more options. | ||
| See scipy.interpolate for more options. | ||
|
|
||
| normalize : boolean, default True | ||
| When true, the interpolated values are divided by the interpolated | ||
|
|
@@ -469,9 +470,6 @@ def interp(aoi, theta_ref, iam_ref, method='linear', normalize=True): | |
| pvlib.iam.sapm | ||
| ''' | ||
| # Contributed by Anton Driesse (@adriesse), PV Performance Labs. July, 2019 | ||
|
|
||
| from scipy.interpolate import interp1d | ||
|
|
||
| # Scipy doesn't give the clearest feedback, so check number of points here. | ||
| MIN_REF_VALS = {'linear': 2, 'quadratic': 3, 'cubic': 4, 1: 2, 2: 3, 3: 4} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could add a dictionary with names and k values, or something like that, to use below. |
||
|
|
||
|
|
@@ -483,10 +481,21 @@ def interp(aoi, theta_ref, iam_ref, method='linear', normalize=True): | |
| raise ValueError("Negative value(s) found in 'iam_ref'. " | ||
| "This is not physically possible.") | ||
|
|
||
| interpolator = interp1d(theta_ref, iam_ref, kind=method, | ||
| fill_value='extrapolate') | ||
| aoi_input = aoi | ||
| if method == "linear": | ||
| interpolator = make_interp_spline(theta_ref, iam_ref, k=1) | ||
|
|
||
| elif method == "quadratic": | ||
| interpolator = make_interp_spline(theta_ref, iam_ref, k=2) | ||
|
|
||
| elif method == "cubic": | ||
| interpolator = make_interp_spline(theta_ref, iam_ref, k=3) | ||
|
|
||
| else: | ||
| raise ValueError( | ||
| f"Interpolation method '{method}' is not supported" | ||
| " in pvlib-python.") | ||
|
|
||
| aoi_input = aoi | ||
| aoi = np.asanyarray(aoi) | ||
| aoi = np.abs(aoi) | ||
| iam = interpolator(aoi) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line may need to be edited, depending on https://github.com/pvlib/pvlib-python/pull/2741/changes#r3137773820