-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Implemented closed-form solution in detect_clearsky
#2217
Conversation
…learsky. Updates test." This reverts commit 94259c5.
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.
Nice PR @agodbehere 💯 !!
Leaving early review comments:
- You can safely address flake8 warnings in
test_clearsky.py
- Docs will need to be updated to reflect what new algorithm is being used, which I identify are:
- The docstring of the modified function (
pvilb.clearsky.detect_clearsky
) - The user guide section at
clearsky.rst
- As you update these sections, you will be able to see how they will look when published at the following link (you can access it at the bottom of this PR in "Checks", through the "ReadTheDocs" action): https://pvlib-python--2217.org.readthedocs.build/en/2217/
- The docstring of the modified function (
- I haven't checked the code much more deeply, but there may be parts relating to the old algorithm at other places too
Feel free to ask about whatever you need help with, we all know it's not that easy to contribute to open-source 🚀
@@ -30,6 +30,10 @@ Enhancements | |||
* Added function for calculating wind speed at different heights, | |||
:py:func:`pvlib.atmosphere.windspeed_powerlaw`. | |||
(:issue:`2118`, :pull:`2124`) | |||
* Implemented closed-form solution for alpha in detect_clearsky, obviating | |||
the call to scipy.optimize that was prone to runtime errors and minimizing | |||
computation, :py:func:`pvlib.clearsky.detect_clearsky`. Resolves :issue:`2712`. |
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.
computation, :py:func:`pvlib.clearsky.detect_clearsky`. Resolves :issue:`2712`. | |
computation, :py:func:`pvlib.clearsky.detect_clearsky`. (:discuss:`2171`, :issue:`2216`, :pull:`2217`) |
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.
Should be :issue:2171
, :issue:2216
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.
Updated, thanks ❣️
|
||
# Compute arg min of MSE between model and observations | ||
C = (clear_clear**2).sum() | ||
if not (pd.isna(C) or C == 0): # safety check |
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.
What would physically mean that this value is zero or NaN? Maybe we can skip this safety check, I wonder what could happen if this code isn't executed
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.
Without the check the next line divides by C
. The exit criteria need alpha
to be a float. I think the check and if...break
are fine.
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.
Nice job 👍🏾
Minor suggestion for the whatsnew file (someone will correct me if I'm mistaken)
* Implemented closed-form solution for alpha in detect_clearsky, obviating | ||
the call to scipy.optimize that was prone to runtime errors and minimizing | ||
computation, :py:func:`pvlib.clearsky.detect_clearsky`. Resolves :issue:`2712`. |
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.
Link the function in the first line and then no need to repeat it here at the end as (I think?) we only do that if it is a new function being added
* Implemented closed-form solution for alpha in detect_clearsky, obviating | |
the call to scipy.optimize that was prone to runtime errors and minimizing | |
computation, :py:func:`pvlib.clearsky.detect_clearsky`. Resolves :issue:`2712`. | |
* Implemented closed-form solution for alpha in | |
:py:func:`pvlib.clearsky.detect_clearsky`, obviating | |
the call to scipy.optimize that was prone to runtime errors and minimizing | |
computation. (:issue:`2171`, :issue:`2216`, :pull:`2217`). |
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.
I approve providing the comments on the whatsnew file are resolved.
detect_clearsky
Thanks for this nice improvement @agodbehere! |
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.