Skip to content

limit cos(aoi) in diffuse sky functions #535

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

Merged
merged 8 commits into from
Aug 19, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
5 changes: 5 additions & 0 deletions docs/sphinx/source/whatsnew/v0.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ Bug fixes
* Make GitHub recognize the license, add AUTHORS.md, clarify shared copyright.
(:issue:`503`)
* Fix argument order of longitude and latitude when querying weather forecasts by lonlat bounding box (:issue:`521`)
* Fix issue with non-zero direct irradiance contribution to Reindl, Klucher,
and Hay-Davies diffuse sky algorithms when the sun is behind the array.
(:issue:`526`)
* Fix issue with dividing by near-0 cos(solar_zenith) values in Reindl and
Hay-Davies diffuse sky algorithms. (:issue:`432`)


Documentation
Expand Down
10 changes: 7 additions & 3 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def poa_horizontal_ratio(surface_tilt, surface_azimuth,

cos_solar_zenith = tools.cosd(solar_zenith)

# ratio of titled and horizontal beam irradiance
# ratio of tilted and horizontal beam irradiance
ratio = cos_poa_zen / cos_solar_zenith

try:
Expand Down Expand Up @@ -746,6 +746,7 @@ def klucher(surface_tilt, surface_azimuth, dhi, ghi, solar_zenith,
# zenith angle with respect to panel normal.
cos_tt = aoi_projection(surface_tilt, surface_azimuth,
solar_zenith, solar_azimuth)
cos_tt = np.minimum(cos_tt, 0) # GH 526

F = 1 - ((dhi / ghi) ** 2)
try:
Expand Down Expand Up @@ -836,8 +837,9 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
if projection_ratio is None:
cos_tt = aoi_projection(surface_tilt, surface_azimuth,
solar_zenith, solar_azimuth)
cos_tt = np.minimum(cos_tt, 0) # GH 526
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be np.maximum

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hay and Davies:

test_haydavies fails because of this error np.minimum. Otherwise I believe it should pass.

cos_solar_zenith = tools.cosd(solar_zenith)
Rb = cos_tt / cos_solar_zenith
Rb = cos_tt / np.maximum(cos_solar_zenith, 0.01745) # GH 432
else:
Rb = projection_ratio

Expand Down Expand Up @@ -932,11 +934,13 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,

cos_tt = aoi_projection(surface_tilt, surface_azimuth,
solar_zenith, solar_azimuth)
cos_tt = np.minimum(cos_tt, 0) # GH 526
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np.maximum here


# do not apply cos(zen) limit here (needed for HB below)
cos_solar_zenith = tools.cosd(solar_zenith)

# ratio of titled and horizontal beam irradiance
Rb = cos_tt / cos_solar_zenith
Rb = cos_tt / np.maximum(cos_solar_zenith, 0.01745) # GH 432

# Anisotropy Index
AI = dni / dni_extra
Expand Down