-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9a74404
limit cos(aoi) in diffuse sky functions
wholmgren c8530a2
no limit on cos_solar_zenith in hb calculation. change proj limit to -1
wholmgren c0943a8
reimplement without projection_minimum kwarg
wholmgren 205cc16
fix np.minimum vs. np.maximum
wholmgren 1122055
update tutorial
wholmgren 0e3fb1a
add sky diffuse test for zenith close to 90
wholmgren e23d9d3
Merge remote-tracking branch 'pvlib/master' into aoidiff
wholmgren eead186
fix botched whatsnew merge [skip ci]
wholmgren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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. | ||
|
||
Returns | ||
------- | ||
|
@@ -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: | ||
|
@@ -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. | ||
|
@@ -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 | ||
------- | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
ratio = cos_poa_zen / cos_solar_zenith | ||
|
||
|
@@ -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: | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Your explanation makes me wonder whether the minimum would be better expressed in degrees.
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.
Yes, I also wondered this. I only went with the projection because it's the quantity that is hardcoded in the matlab library.
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.
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.
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'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.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.
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.
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 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.