Add support for return_components to Reindl#2775
Conversation
Hey @cbcrespo! 🎉Thanks for opening your first pull request! We appreciate your If AI is used for any portion of this PR, you must vet the content |
kandersolar
left a comment
There was a problem hiding this comment.
Nice PR @cbcrespo! I think your interpretation of the horizon component is reasonable, although since it is not stated in the reference, I think we need to document it ourselves. A sentence in the Notes section of the docstring would be appropriate, I think.
I haven't yet added a test. I saw that e.g. haydavies has two separate tests, for return_components=False and return_components=True. However, from what I gathered, the test values came from the matlab implementation of pvlib, and therefore it seems kind of silly to create a test using values derived from the python implementation to test the python implementation. Curious as to what are the community's thoughts on this.
Yes, ideally the test values would come from an independent implementation. If you wanted, you could reimplement the model in Excel (or whatever you like) and calculate test values that way. In this case, I personally would just use the python implementation to compute the test values, for two reasons:
- the math is not very complicated, so we can be fairly confident that there is no bug in the code
- the test's intent is only partially to check that the correct numeric values are returned; equally important is that the test verifies that
return_components=Trueproduces a dict with the correct structure.
Also, a few comments below regarding whether the returned object should be OrderedDict or dict.
| sky_diffuse = dhi * (term1 + term2 + term3) | ||
|
|
||
| if return_components: | ||
| diffuse_components = OrderedDict() |
There was a problem hiding this comment.
I know this would be consistent with existing functions, but at some point we will switch those to normal dictionaries (see #1684). I suggest getting ahead of that change here and using a normal dictionary.
| The sky diffuse component of the solar radiation on a tilted | ||
| surface. | ||
|
|
||
| diffuse_components : OrderedDict (array input) or DataFrame (Series input) |
There was a problem hiding this comment.
If switching the return from OrderedDict to dict, change here as well
| ------- | ||
| poa_sky_diffuse : numeric | ||
| The sky diffuse component of the solar radiation. [Wm⁻²] | ||
| numeric, OrderedDict, or DataFrame |
@kandersolar just for clarification, this interpretation can be seen as factual rather than reasonable since, while it is not explicit in the paper, it is remaining term after subtracting the hay-davies models which predeces it (and to which reindl only adds an horizon term). @cbcrespo explanation of the interpretation is a bit convoluted because in the beginning we we're trying too much to make a physical interpretation of the term and we wanted to open up a bite the discussion. but then, when talking to Adam, we noticed that indeed this is simply the extra term when we multiply the multiplicative terms. Anyway, something can be added to the Notes if that is deemed relevant, but it should be really short imo. |
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`).This PR is part of my GSoC 2026 project. One of the goals is to add support for
return_componentsto all diffuse transposition models inpvlib, which currently is supported by some models (e.g.perez) but not others. This parameter allows the user to choose whether they want only the total diffuse irradiance, or are interested in the split between different diffuse components (sky diffuse, circumsolar, horizon brightening).This first PR starts by implementing
return_componentsinreindl.Reindl expands the Hay and Davies model, which considers only the isotropic and circumsolar components, and is defined as:

with A Rb being the circumsolar component and the rest being the isotropic component.
Reindl expands this by adding a horizon brightening component, but this new component is not additive but rather multiplied by the existing isotropic component:

In my implementation, I essentially considered that the isotropic term was:


while the horizon brightening term was:
I updated the function docstrings accordingly. I haven't yet added a test. I saw that e.g.
haydavieshas two separate tests, forreturn_components=Falseandreturn_components=True. However, from what I gathered, the test values came from the matlab implementation ofpvlib, and therefore it seems kind of silly to create a test using values derived from the python implementation to test the python implementation. Curious as to what are the community's thoughts on this.