-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adapts irradiance.isotropic to return_components framework. #2527
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -587,7 +587,7 @@ def get_ground_diffuse(surface_tilt, ghi, albedo=.25, surface_type=None): | |
return diffuse_irrad | ||
|
||
|
||
def isotropic(surface_tilt, dhi): | ||
def isotropic(surface_tilt, dhi, return_components=False): | ||
r''' | ||
Determine diffuse irradiance from the sky on a tilted surface using | ||
the isotropic sky model. | ||
|
@@ -613,10 +613,23 @@ def isotropic(surface_tilt, dhi): | |
dhi : numeric | ||
Diffuse horizontal irradiance. [Wm⁻²] DHI must be >=0. | ||
|
||
return_components : bool, default False | ||
Flag used to decide whether to return the calculated diffuse components | ||
or not. If `False`, ``sky_diffuse`` is returned. If `True`, | ||
``diffuse_components`` is returned. | ||
|
||
Returns | ||
------- | ||
diffuse : numeric | ||
The sky diffuse component of the solar radiation. | ||
poa_sky_diffuse : numeric | ||
The sky diffuse component of the solar radiation on a tilted | ||
surface. | ||
|
||
diffuse_components : OrderedDict (array input) or DataFrame (Series input) | ||
Keys/columns are: | ||
* sky_diffuse: Total sky diffuse | ||
* isotropic | ||
* circumsolar | ||
* horizon | ||
|
||
|
||
References | ||
---------- | ||
|
@@ -630,9 +643,20 @@ def isotropic(surface_tilt, dhi): | |
Energy vol. 201. pp. 8-12 | ||
:doi:`10.1016/j.solener.2020.02.067` | ||
''' | ||
sky_diffuse = dhi * (1 + tools.cosd(surface_tilt)) * 0.5 | ||
poa_sky_diffuse = dhi * (1 + tools.cosd(surface_tilt)) * 0.5 | ||
|
||
return sky_diffuse | ||
if return_components: | ||
diffuse_components = OrderedDict() | ||
|
||
diffuse_components['poa_sky_diffuse'] = poa_sky_diffuse | ||
|
||
# Calculate the different components | ||
diffuse_components['poa_isotropic'] = poa_sky_diffuse | ||
diffuse_components['poa_circumsolar'] = 0 | ||
diffuse_components['poa_horizon'] = 0 | ||
|
||
return diffuse_components | ||
else: | ||
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. I would prefer to return both 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. Sounds good to me. This "one or the other" is what is implemented in For clarity, do you mean returning two dictionaries, which makes the number of outputs depend on 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. I'm thinking a tuple with two dicts, when 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. @cwhanse I just noticed that in my latest commit I included in the If instead we have two dictionaries as originally proposed, the one having the 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. Apologies, I misspoke. Return a tuple 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. Edited: returning a tuple requires the user to change from
to
I was (wrongly) thinking that only the first element of the tuple would be assigned to So now I'm not so sure that returning a tuple is a good idea. Still, it seems better than requiring the user to change to
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. Thanks for clarifying and thinking things through. Going back to the start:
I just remembered that in my latest commit the While what you propose is v0.13.1-friendly for the models not yet returning What do you think? If agreed, can you can raise a new issue like @kandersolar did in #2529? 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.
All the irradiance component sets I looked at include both components and sums of components. I think the cleanest way would be (would have been) to include only the lowest level and leave the summation up to the user. |
||
return poa_sky_diffuse | ||
|
||
|
||
def klucher(surface_tilt, surface_azimuth, dhi, ghi, solar_zenith, | ||
|
@@ -782,8 +806,9 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra, | |
or supply ``projection_ratio``. | ||
|
||
return_components : bool, default `False` | ||
If `False`, ``sky_diffuse`` is returned. | ||
If `True`, ``diffuse_components`` is returned. | ||
Flag used to decide whether to return the calculated diffuse components | ||
or not. If `False`, ``sky_diffuse`` is returned. If `True`, | ||
``diffuse_components`` is returned. | ||
|
||
Returns | ||
-------- | ||
|
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.
Assuming this is in reference to the names in the
Returns
section