Add support for return_components to irradiance.isotropic#2787
Add support for return_components to irradiance.isotropic#2787cbcrespo wants to merge 5 commits into
Conversation
|
Misssing a whatsnew entry fyi |
echedey-ls
left a comment
There was a problem hiding this comment.
Nice PR! I want to open a discussion on the formatting of the conditional return style.
Scipy does this: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.brentq.html#scipy.optimize.brentq
I personally would prefer the two return items, separately, with the annotation present if ... is True/False or something like that. E.g.:
sky_diffuse : numeric (if ``return_components`` is ``False``)
The sky diffuse component of the solar radiation. [Wm⁻²]
diffuse_components : Dict (array input) or DataFrame (Series input) (if ``return_components`` is ``True``)
Keys/columns are:
* poa_sky_diffuse: Total sky diffuse
* poa_isotropic
| return_components : bool, default `False` | ||
| If `False`, ``sky_diffuse`` is returned. | ||
| If `True`, ``diffuse_components`` is returned. | ||
| For this model, return_components does not add more information, | ||
| but it is included for consistency with the other sky diffuse models. |
There was a problem hiding this comment.
One quick note, while there is a number of single-backtick-formatting ocurrences, it formats text into italic. It's usually a typo and double-backticks enclosing is preferred, which formats as code in the HTML build. In this case, I think it was intended (or at least I personally prefer) to code-format `False`, `True` and return_components
Btw, have you been able to navigate to the docs preview on PRs?
| diffuse_components : Dict (array input) or DataFrame (Series input) | ||
| Keys/columns are: | ||
| * poa_sky_diffuse: Total sky diffuse | ||
| * poa_isotropic |
There was a problem hiding this comment.
sphinx interprets this weirdly - I speculate it's the colon after Keys/columns are.
See https://pvlib-python--2787.org.readthedocs.build/en/2787/reference/generated/pvlib.irradiance.isotropic.html
| assert_frame_equal(result, expected, check_less_precise=4) | ||
| # numpy | ||
| result = irradiance.isotropic( | ||
| 40, irrad_data['dhi'].values, return_components=True) |
There was a problem hiding this comment.
Pandas docs recommend substituting .values to to_numpy(), https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.values.html
I don't know the rationale, but it may be a good idea to incorporate their suggestion.
Closes #xxxxdocs/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.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 (default), or are interested in the split between different diffuse components (sky diffuse, circumsolar, horizon brightening).This has been implemented for irradiance.reindl in #2775.
For
irradiance.isotropicspecifically,return_components=Truedoes not return additional information, but has been added in order to be consistent with other diffuse transposition models.The docstrings have been changed accordingly, and a new test was added.