-
Notifications
You must be signed in to change notification settings - Fork 1.1k
polite handling of nan in irradiance.perez #610
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
pvlib/irradiance.py
Outdated
|
||
F2 = (F2c[ebin, 0] + F2c[ebin, 1] * delta + F2c[ebin, 2] * z) | ||
F2 = np.maximum(F2, 0) | ||
F2 = np.where(np.isnan(F2), np.nan, np.maximum(F2, 0)) |
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.
if this polite handling is going to become a pattern, it might be worth putting it into tools
as a dedicated set of functions like
def polite_handling_of_nan(x, f):
"""return nan where x is nan otherwise return f(x)"""
return np.where(np.isnan(x), np.nan, f(x))
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.
Also isn't another option to turn off NumPy warnings? If that's an alternate, I'm curious if there is any penalty for calling np.where()
all the time, instead of just ignoring the warnings.
Actually that earlier commit did nothing, since np.where evaluates both cases before constructing its output. See the latest commit, adding Having |
np.fmax documentation says "See Also... maximum Element-wise maximum of two arrays, propagates NaNs." It is ridiculous that a function specifically advertised to propagate NaNs would also complain that it was provided a NaN! There's got to be a better way than trying to maintain our own nan-friendly maximum function. |
I agree. We could open an issue for |
I'm working on a comment here.... numpy/numpy#12038 |
OK, let's sit on this until numpy makes up its mind. The custom function is messing with the output typing in |
Also I'm still concerned about penalty from all these extra |
Looks like numpy will stop emitting the warnings. I suggest we live with them for now and close this PR. |
pvlib python pull request guidelines
Thank you for your contribution to pvlib python! You may delete all of these instructions except for the list below.
You may submit a pull request with your code at any stage of completion.
The following items must be addressed before the code can be merged. Please don't hesitate to ask for help if you're unsure of how to accomplish any of the items below:
docs/sphinx/source/whatsnew
file for all changes.Brief description of the problem and proposed solution (if not already fully described in the issue linked to above):