-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement irradiance.complete_irradiance with component sum equations #1567
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
Conversation
Not a review, rather, thoughts for discussion:
'clearsky_dni' should be described as optional. |
@cwhanse on the second point, modelchains definitely prefers the dataframe with the dni, ghi, and dhi fields, but I worry about the use of a dataframe not in the context of modelchains. I set it up as separate fields for situations where the dataframe has uniquely named ghi, dni, and dhi columns. Open to either way, but that's what motivated the initial choice to make the ghi, dni, and dhi fields as separate parameters. |
Is there an aversion to having e.g. 'ghi' be both an input and output parameter name? |
I don't have an aversion to it if we change the name of the pvlib.irradiance.dni() function. I originally had the fields ghi, dhi, and dni as passed parameters, but it was erroring since we also have a dni() method (got confused between parameter and method). What do you think about renaming the method? |
I think @cwhanse is suggesting keeping the input parameters as separate series but returning the outputs together in a single dataframe, which I agree is more consistent with other functions in Something related to this if you're up for it: with this kind of function, we try to write it such that it will work equally well for scalar, numpy, and pandas inputs, and return outputs of similar type (scalar in -> scalar out, numpy in -> numpy out, pandas in -> pandas out). In this case for scalar inputs we'd return a dictionary instead of a dataframe. Regarding the |
Ok, @kanderso-nrel that makes more sense. Thank you guys both for the suggestions @kanderso-nrel and @cwhanse ! I'll see what I can do to adapt the code to make it fit better with the pvlib framework. |
…um + other suggestions
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.
Here's a partial review
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.
Getting close! Sorry I'm so nitpicky about everything...
pvlib/tests/test_modelchain.py
Outdated
@@ -1904,7 +1904,7 @@ def test_complete_irradiance(sapm_dc_snl_ac_system, location): | |||
|
|||
mc.complete_irradiance(i[['dhi', 'ghi']]) | |||
assert_series_equal(mc.results.weather['dni'], | |||
pd.Series([49.756966, 62.153947], | |||
pd.Series([49.63565561689957, 62.10624908037814], |
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.
Hmm, I guess this is an artifact of switching to apparent_zenith
. Maybe we shouldn't actually make that change, or if we do then it needs to be mentioned in the changelog. Let's keep this as "to discuss" also.
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.
On technical merit, apparent_zenith
would be better. But the practical difference is small and not worth annoying someone trying to reproduce archived results. I could go either way: change to apparent_zenith
, or name the parameter solar_zenith
and give a generic description.
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.
Any other input on this change? We have two votes neither opposed but neither in strong favor. If that's the roll call, I'd say keep it as zenith
.
Co-authored-by: Kevin Anderson <[email protected]>
Co-authored-by: Kevin Anderson <[email protected]>
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.
@pvlib/pvlib-core, any thoughts regarding the apparent zenith question (#1567 (comment) and #1567 (comment))?
A few other minor things below, otherwise LGTM
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.
Pending zenith
vs. apparent_zenith
, I'm approving.
pvlib/tests/test_modelchain.py
Outdated
@@ -1904,7 +1904,7 @@ def test_complete_irradiance(sapm_dc_snl_ac_system, location): | |||
|
|||
mc.complete_irradiance(i[['dhi', 'ghi']]) | |||
assert_series_equal(mc.results.weather['dni'], | |||
pd.Series([49.756966, 62.153947], | |||
pd.Series([49.63565561689957, 62.10624908037814], |
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.
On technical merit, apparent_zenith
would be better. But the practical difference is small and not worth annoying someone trying to reproduce archived results. I could go either way: change to apparent_zenith
, or name the parameter solar_zenith
and give a generic description.
pvlib/tests/test_modelchain.py
Outdated
@@ -1904,7 +1904,7 @@ def test_complete_irradiance(sapm_dc_snl_ac_system, location): | |||
|
|||
mc.complete_irradiance(i[['dhi', 'ghi']]) | |||
assert_series_equal(mc.results.weather['dni'], | |||
pd.Series([49.756966, 62.153947], | |||
pd.Series([49.63565561689957, 62.10624908037814], |
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.
Any other input on this change? We have two votes neither opposed but neither in strong favor. If that's the roll call, I'd say keep it as zenith
.
Co-authored-by: Cliff Hansen <[email protected]>
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.
A few minor comments that I'd prefer to see addressed but won't object to ignoring.
Can we change the PR name (and thus the default commit) to something like "Implement irradiance.complete_irradiance with component sum equations"? The current title makes me think of the pvanalytics QC function.
Co-authored-by: Will Holmgren <[email protected]>
Co-authored-by: Will Holmgren <[email protected]>
@wholmgren thank you for the review! I went ahead and worked on addressing all of your comments, and changed the PR name to the suggested name. Let me know if there's anything else I can do before merging! |
thanks @kperrynrel! @kanderso-nrel can you merge if you're happy with it too? |
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.
Going back to zenith
meant the associated ModelChain test changes needed to be undone as well, but LGTM now. Thanks @kperrynrel!
Added the function component_sum_irradiance() to independently calculate the irradiance ghi, dhi, and dni fields from the modelchains module.
docs/sphinx/source/reference
for API changes.docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).remote-data
) and Milestone are assigned to the Pull Request and linked Issue.