8000 polite handling of nan in irradiance.perez by cwhanse · Pull Request #610 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
polite handling of nan in irradiance.perez
  • Loading branch information
cwhanse committed Oct 23, 2018
commit dd300697b6643756af0378eb0facf5839c677764
6 changes: 3 additions & 3 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,17 +1147,17 @@ def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
F2c = np.vstack((F2c, nans))

F1 = (F1c[ebin, 0] + F1c[ebin, 1] * delta + F1c[ebin, 2] * z)
F1 = np.maximum(F1, 0)
F1 = np.where(np.isnan(F1), np.nan, np.maximum(F1, 0))

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))
Copy link
Member
@mikofski mikofski Oct 23, 2018

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))

Copy link
Member

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.


A = aoi_projection(surface_tilt, surface_azimuth,
solar_zenith, solar_azimuth)
A = np.maximum(A, 0)

B = tools.cosd(solar_zenith)
B = np.maximum(B, tools.cosd(85))
B = np.where(np.isnan(B), np.nan, np.maximum(B, tools.cosd(85)))

# Calculate Diffuse POA from sky dome
term1 = 0.5 * (1 - F1) * (1 + tools.cosd(surface_tilt))
Expand Down
0