Implement irradiance.complete_irradiance with component sum equations#1567
Implement irradiance.complete_irradiance with component sum equations#1567kandersolar merged 40 commits intopvlib:masterfrom
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
kandersolar
left a comment
There was a problem hiding this comment.
Getting close! Sorry I'm so nitpicky about everything...
pvlib/tests/test_modelchain.py
Outdated
| 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.
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.
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.
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 <kevin.anderson@nrel.gov>
Co-authored-by: Kevin Anderson <kevin.anderson@nrel.gov>
kandersolar
left a comment
There was a problem hiding this comment.
@pvlib/pvlib-core, any thoughts regarding the apparent zenith question (#1567 (comment) and #1567 (comment))?
A few other minor things below, otherwise LGTM
Co-authored-by: Kevin Anderson <kevin.anderson@nrel.gov>
cwhanse
left a comment
There was a problem hiding this comment.
Pending zenith vs. apparent_zenith, I'm approving.
pvlib/tests/test_modelchain.py
Outdated
| 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.
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
| 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.
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 <cwhanse@sandia.gov>
wholmgren
left a comment
There was a problem hiding this comment.
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 <william.holmgren@gmail.com>
Co-authored-by: Will Holmgren <william.holmgren@gmail.com>
|
@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? |
kandersolar
left a comment
There was a problem hiding this comment.
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/referencefor API changes.docs/sphinx/source/whatsnewfor 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.