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 2 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
7 changes: 7 additions & 0 deletions docs/sphinx/source/whatsnew/v0.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ API Changes
enhancement factor can yield unphysical results, especially for latitudes
closer to the poles and especially in the winter months. It may yield
improved results under other conditions. (:issue:`435`)
* Add projection_minimum keyword argument to irradiance.aoi_projection.
Default behavior remains the same. (:issue:`526`)


Enhancements
Expand Down Expand Up @@ -109,6 +111,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
39 changes: 31 additions & 8 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def _handle_extra_radiation_types(datetime_or_doy, epoch_year):
return to_doy, to_datetimeindex, to_output


def aoi_projection(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth):
def aoi_projection(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth,
projection_minimum=-1):
"""
Calculates the dot product of the solar vector and the surface
normal.
Expand All @@ -169,6 +170,11 @@ def aoi_projection(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth):
Solar zenith angle.
solar_azimuth : numeric
Solar azimuth angle.
projection_minimum : numeric, default -1
Minimum allowable value for the projection for the solar angle
into the plane of the array. For example, 0 is equivalent to a
90 degree limit, 0.01745 is equivalent to a 89 degree limit, and
-1 allows for any angle.

Copy link
Member

Choose a reason for hiding this comment

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

Your explanation makes me wonder whether the minimum would be better expressed in degrees.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I also wondered this. I only went with the projection because it's the quantity that is hardcoded in the matlab library.

Copy link
Member Author

Choose a reason for hiding this comment

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

After thinking through the response to your comment below, I am leaning towards keeping it as the dot product to avoid the complexity of handling angles > 90 degrees or less than 0.

Copy link
Member

Choose a reason for hiding this comment

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

I'm having trouble seeing a use case which requires projection_minimum. The function's description says it calculates a dot product so that's what I'd expect it to do, and to not do more.

Copy link
Member

Choose a reason for hiding this comment

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

Actually it does less than a dot product since it assumes/requires the vectors are unit vectors. It's really just calculating the cosine of the angle of incidence. I think the name "projection" seems to suggest more, and may even be confusing to some.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will remove the projection_minimum kwargs and put the limits in the diffuse models where necessary. We can address the function name in a separate issue.

Returns
-------
Expand All @@ -181,6 +187,8 @@ def aoi_projection(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth):
tools.sind(surface_tilt) * tools.sind(solar_zenith) *
tools.cosd(solar_azimuth - surface_azimuth))

projection = np.maximum(projection, projection_minimum)

try:
projection.name = 'aoi_projection'
except AttributeError:
Expand Down Expand Up @@ -226,7 +234,9 @@ def aoi(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth):


def poa_horizontal_ratio(surface_tilt, surface_azimuth,
solar_zenith, solar_azimuth):
solar_zenith, solar_azimuth,
poa_projection_minimum=None,
solar_zenith_projection_minimum=None):
"""
Calculates the ratio of the beam components of the plane of array
irradiance and the horizontal irradiance.
Expand All @@ -243,6 +253,12 @@ def poa_horizontal_ratio(surface_tilt, surface_azimuth,
Solar zenith angle.
solar_azimuth : numeric
Solar azimuth angle.
poa_projection_minimum : numeric, default -1
Minimum allowable value for the projection for the solar angle
into the plane of the array.
solar_zenith_projection_minimum : numeric, default -1
Minimum allowable value for the projection of the solar angle
on to a horizontal surface.

Returns
-------
Expand All @@ -252,10 +268,14 @@ def poa_horizontal_ratio(surface_tilt, surface_azimuth,
"""

cos_poa_zen = aoi_projection(surface_tilt, surface_azimuth,
solar_zenith, solar_azimuth)
solar_zenith, solar_azimuth,
projection_minimum=poa_projection_minimum)

cos_solar_zenith = tools.cosd(solar_zenith)

cos_solar_zenith = np.maximum(cos_solar_zenith,
solar_zenith_projection_minimum)

# ratio of titled and horizontal beam irradiance
Copy link
Member

Choose a reason for hiding this comment

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

Nit: tilted not titled

ratio = cos_poa_zen / cos_solar_zenith

Expand Down Expand Up @@ -745,7 +765,8 @@ 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)
solar_zenith, solar_azimuth,
projection_minimum=0)

F = 1 - ((dhi / ghi) ** 2)
try:
Expand Down Expand Up @@ -835,8 +856,9 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
# if necessary, calculate ratio of titled and horizontal beam irradiance
if projection_ratio is None:
cos_tt = aoi_projection(surface_tilt, surface_azimuth,
solar_zenith, solar_azimuth)
cos_solar_zenith = tools.cosd(solar_zenith)
solar_zenith, solar_azimuth,
projection_minimum=0)
cos_solar_zenith = np.maximum(tools.cosd(solar_zenith), 0.01745)
Rb = cos_tt / cos_solar_zenith
else:
Rb = projection_ratio
Expand Down Expand Up @@ -931,12 +953,13 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,
'''

cos_tt = aoi_projection(surface_tilt, surface_azimuth,
solar_zenith, solar_azimuth)
solar_zenith, solar_azimuth,
projection_minimum=0)

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)

# Anisotropy Index
AI = dni / dni_extra
Expand Down