-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Muneer transposition model #2184
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
Draft
BernatNicolau
wants to merge
55
commits into
pvlib:main
Choose a base branch
from
BernatNicolau:muneer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 29 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
02ae568
muneer transposition model
bernatnic ea15728
Update pvlib/irradiance.py
BernatNicolau feafcea
Update pvlib/irradiance.py
BernatNicolau e4646d4
Update pvlib/irradiance.py
BernatNicolau 8066458
Update pvlib/irradiance.py
BernatNicolau 1798da8
Update pvlib/irradiance.py
BernatNicolau 4281d61
Update pvlib/irradiance.py
BernatNicolau 8b13595
references modified and doi added
BernatNicolau 6cd63a8
removed unwanted file
BernatNicolau fa4d8e6
formating autopep8
BernatNicolau 8318d5b
formatting
BernatNicolau d5c8bc3
avoid references first paragraph
BernatNicolau 8cbee57
updated wording
BernatNicolau 20c8fae
function finished
BernatNicolau a326e94
Merge branch 'muneer' of https://github.com/BernatNicolau/pvlib-pytho…
BernatNicolau e0d85c0
pvlib.irradiance update (muneer)
BernatNicolau 30fb33a
documentation, tests and flake8
BernatNicolau e1a7f74
flake8 update
BernatNicolau 618ca91
test_added
BernatNicolau 373d3e0
flake8
BernatNicolau e517a84
E501
BernatNicolau 9452248
update whatsnew
BernatNicolau b2d5239
Merge branch 'main' into muneer
BernatNicolau 36f633e
Update docs/sphinx/source/whatsnew/v0.11.1.rst
BernatNicolau 982d2f9
documentation improvement
BernatNicolau eecc05e
documentation improvement
BernatNicolau 83b5036
documentation improvement
BernatNicolau 6bd1d51
Merge branch 'main' into muneer
BernatNicolau 4fb4bae
b added to `get_total_irradiance`
BernatNicolau 4c69d6f
Apply suggestions from code review (documentation)
BernatNicolau b93aa05
flake8-linter
BernatNicolau c2248f1
Update DOI
BernatNicolau 91fd117
create scenario with low solar altitude (<0.1rad)
BernatNicolau b8910de
avoid zero in denominator
BernatNicolau 0591323
division by zero fix
BernatNicolau aed0e6d
solar_azimuth is not optional anymore + test updated
BernatNicolau 2d4b10f
# GH 432
BernatNicolau bec7412
test_update
BernatNicolau a3e3e3c
replace np.where by .where to keep the pd.Series type
BernatNicolau 927c8a8
revert np.where and modify type if needed
BernatNicolau 7cfd605
typo when converting sky_diffuse
BernatNicolau 5298cb2
improvement # GH 432
BernatNicolau ce6f5c0
np.array and float tests added
BernatNicolau ce42241
updated expected to np.array as it should be
BernatNicolau 5632bda
assert_series_equal to assert_almost_equal
BernatNicolau b2128cf
documentation improvement
BernatNicolau f9fb65c
linter
BernatNicolau c0caf04
Apply suggestions from code review
BernatNicolau 2142559
unify irradiation unit format
BernatNicolau 4e58192
Merge branch 'muneer' of https://github.com/BernatNicolau/pvlib-pytho…
BernatNicolau bedd18b
linter
BernatNicolau b5e4aec
muneer2004
BernatNicolau 1bcf20d
overcast condition
BernatNicolau c9b9214
update clearness index
BernatNicolau 519861e
Merge pull request #1 from BernatNicolau/muneer-book
BernatNicolau 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
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 |
---|---|---|
|
@@ -263,7 +263,7 @@ def get_total_irradiance(surface_tilt, surface_azimuth, | |
dni, ghi, dhi, dni_extra=None, airmass=None, | ||
albedo=0.25, surface_type=None, | ||
model='isotropic', | ||
model_perez='allsitescomposite1990'): | ||
model_perez='allsitescomposite1990', b=5.73): | ||
r""" | ||
Determine total in-plane irradiance and its beam, sky diffuse and ground | ||
reflected components, using the specified sky diffuse irradiance model. | ||
|
@@ -280,6 +280,7 @@ def get_total_irradiance(surface_tilt, surface_azimuth, | |
* king | ||
* perez | ||
* perez-driesse | ||
* muneer | ||
|
||
Parameters | ||
---------- | ||
|
@@ -309,9 +310,12 @@ def get_total_irradiance(surface_tilt, surface_azimuth, | |
model : str, default 'isotropic' | ||
Irradiance model. Can be one of ``'isotropic'``, ``'klucher'``, | ||
``'haydavies'``, ``'reindl'``, ``'king'``, ``'perez'``, | ||
``'perez-driesse'``. | ||
``'perez-driesse'`` and ``'muneer | ||
model_perez : str, default 'allsitescomposite1990' | ||
Used only if ``model='perez'``. See :py:func:`~pvlib.irradiance.perez`. | ||
b : numeric, default 5.73 | ||
Used only if ``model='muneer'``. | ||
See :py:func:`~pvlib.irradiance.muneer`. | ||
|
||
Returns | ||
------- | ||
|
@@ -321,9 +325,9 @@ def get_total_irradiance(surface_tilt, surface_azimuth, | |
|
||
Notes | ||
----- | ||
Models ``'haydavies'``, ``'reindl'``, ``'perez'`` and ``'perez-driesse'`` | ||
require ``'dni_extra'``. Values can be calculated using | ||
:py:func:`~pvlib.irradiance.get_extra_radiation`. | ||
Models ``'haydavies'``, ``'reindl'``, ``'perez'``, ``'perez-driesse'``, | ||
and ``'muneer'`` require ``'dni_extra'``. Values can be calculated | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using :py:func:`~pvlib.irradiance.get_extra_radiation`. | ||
|
||
The ``'perez'`` and ``'perez-driesse'`` models require relative airmass | ||
(``airmass``) as input. If ``airmass`` is not provided, it is calculated | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -333,7 +337,7 @@ def get_total_irradiance(surface_tilt, surface_azimuth, | |
poa_sky_diffuse = get_sky_diffuse( | ||
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, | ||
dni, ghi, dhi, dni_extra=dni_extra, airmass=airmass, model=model, | ||
model_perez=model_perez) | ||
model_perez=model_perez, b=b) | ||
|
||
poa_ground_diffuse = get_ground_diffuse(surface_tilt, ghi, albedo, | ||
surface_type) | ||
|
@@ -346,7 +350,7 @@ def get_sky_diffuse(surface_tilt, surface_azimuth, | |
solar_zenith, solar_azimuth, | ||
dni, ghi, dhi, dni_extra=None, airmass=None, | ||
model='isotropic', | ||
model_perez='allsitescomposite1990'): | ||
model_perez='allsitescomposite1990', b=5.73): | ||
r""" | ||
Determine in-plane sky diffuse irradiance component | ||
using the specified sky diffuse irradiance model. | ||
|
@@ -359,6 +363,7 @@ def get_sky_diffuse(surface_tilt, surface_azimuth, | |
* king | ||
* perez | ||
* perez-driesse | ||
* muneer | ||
|
||
Parameters | ||
---------- | ||
|
@@ -383,9 +388,12 @@ def get_sky_diffuse(surface_tilt, surface_azimuth, | |
model : str, default 'isotropic' | ||
Irradiance model. Can be one of ``'isotropic'``, ``'klucher'``, | ||
``'haydavies'``, ``'reindl'``, ``'king'``, ``'perez'``, | ||
``'perez-driesse'``. | ||
``'perez-driesse'``, ``'muneer'``. | ||
model_perez : str, default 'allsitescomposite1990' | ||
Used only if ``model='perez'``. See :py:func:`~pvlib.irradiance.perez`. | ||
b : numeric, default 5.73 | ||
Used only if ``model='muneer'``. | ||
See :py:func:`~pvlib.irradiance.muneer`. | ||
|
||
Returns | ||
------- | ||
|
@@ -395,14 +403,15 @@ def get_sky_diffuse(surface_tilt, surface_azimuth, | |
Raises | ||
------ | ||
ValueError | ||
If model is one of ``'haydavies'``, ``'reindl'``, ``'perez'``, or | ||
``'perez_driesse'`` and ``dni_extra`` is not specified. | ||
If model is one of ``'haydavies'``, ``'reindl'``, ``'perez'``, | ||
``'perez_driesse'``, or ``'muneer'`` and ``dni_extra`` is not | ||
specified. | ||
|
||
Notes | ||
----- | ||
Models ``'haydavies'``, ``'reindl'``, ``'perez'`` and ``'perez-driesse'`` | ||
require ``'dni_extra'``. Values can be calculated using | ||
:py:func:`~pvlib.irradiance.get_extra_radiation`. | ||
Models ``'haydavies'``, ``'reindl'``, ``'perez'``, ``'perez-driesse'`` | ||
and ``'muneer'`` require ``'dni_extra'``. Values can be calculated | ||
using :py:func:`~pvlib.irradiance.get_extra_radiation`. | ||
|
||
The ``'Perez'`` transposition model features discontinuities in the | ||
predicted tilted diffuse irradiance due to relying on discrete input | ||
|
@@ -443,6 +452,9 @@ def get_sky_diffuse(surface_tilt, surface_azimuth, | |
# perez_driesse will calculate its own airmass if needed | ||
sky = perez_driesse(surface_tilt, surface_azimuth, dhi, dni, dni_extra, | ||
solar_zenith, solar_azimuth, airmass) | ||
elif model == 'muneer': | ||
sky = muneer(surface_tilt, surface_azimuth, dhi, ghi, dni_extra, | ||
b, solar_zenith, solar_azimuth) | ||
else: | ||
raise ValueError(f'invalid model selection {model}') | ||
|
||
|
@@ -994,6 +1006,103 @@ def king(surface_tilt, dhi, ghi, solar_zenith): | |
return sky_diffuse | ||
|
||
|
||
def muneer(surface_tilt, surface_azimuth, dhi, ghi, dni_extra, b=5.73, | ||
solar_zenith=None, solar_azimuth=None, projection_ratio=None): | ||
''' | ||
Determine sky diffuse irradiance on a tilted surface using the | ||
Muneer model. | ||
|
||
This Muneer transposition model is described in [1]_. | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Parameters | ||
---------- | ||
surface_tilt : numeric | ||
Surface tilt angles in decimal degrees. surface_tilt must be >=0 | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
and <=180. The tilt angle is defined as degrees from horizontal | ||
(e.g. surface facing up = 0, surface facing horizon = 90) | ||
|
||
surface_azimuth : numeric | ||
Surface azimuth angles in decimal degrees. surface_azimuth must | ||
be >=0 and <=360. The azimuth convention is defined as degrees | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
east of north (e.g. North = 0, South=180 East = 90, West = 270). | ||
|
||
dhi : numeric | ||
Diffuse horizontal irradiance. [W/m^2] | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
ghi : numeric | ||
Global horizontal irradiance in W/m^2. | ||
|
||
dni_extra : numeric | ||
Extraterrestrial normal irradiance in W/m^2. | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
b : numeric, default 5.73 | ||
Radiance distribution index, introduced by Moon and Spencer [2]_ | ||
to model luminance distribution of overcast sky. [unitless] | ||
Recommended values from [1]_: | ||
|
||
- isotropic: b = 0 | ||
- shaded surface: b = 5.73 (default) | ||
- sunlit surface, overcast sky: b = 1.68 | ||
- sunlit surface, non-overcast sky: b = -0.62 | ||
|
||
solar_zenith : numeric | ||
Solar apparent (refraction-corrected) zenith angles in decimal | ||
degrees. Must supply ``solar_zenith`` and ``solar_azimuth`` or | ||
supply ``projection_ratio``. | ||
|
||
solar_azimuth : numeric, optional | ||
Solar azimuth angles in decimal degrees. Must supply | ||
``solar_zenith`` and ``solar_azimuth`` or supply | ||
``projection_ratio``. | ||
|
||
projection_ratio : numeric, optional | ||
Ratio of angle of incidence projection to solar zenith angle | ||
projection. Must supply ``solar_zenith`` and ``solar_azimuth`` | ||
or supply ``projection_ratio``. | ||
|
||
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 suggest leaving this out for simplicity and being consistent with the other transposition models in pvlib. |
||
Returns | ||
------- | ||
poa_sky_diffuse : numeric | ||
In-plane diffuse irradiance from the sky. [W/m^2] | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
References | ||
---------- | ||
.. [1] Muneer, T., 1990. Solar radiation model for Europe. Building | ||
Services Engineering Research and Technology 11, 153-163. | ||
:doi:`10.1177/014362449001100405` | ||
|
||
.. [2] Moon, P., Spencer, D.E., 1942. Illumination from a non-uniform sky. | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Trans. Illum. Eng. Soc. (London) 37, 707-725. | ||
:doi:`10.1177/096032719302500301` | ||
BernatNicolau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
''' | ||
|
||
cos_solar_zenith = tools.cosd(solar_zenith) | ||
# 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_tt = np.maximum(cos_tt, 0) # GH 526 | ||
Rb = cos_tt / np.maximum(cos_solar_zenith, 0.01745) # GH 432 | ||
else: | ||
Rb = projection_ratio | ||
|
||
T_term1 = (1 + tools.cosd(surface_tilt)) * 0.5 | ||
T_term2 = 2 * b / (np.pi * (3 + 2 * b)) | ||
T_term3 = ( | ||
tools.sind(surface_tilt) | ||
- np.radians(surface_tilt) * tools.cosd(surface_tilt) | ||
- np.pi * (1 - tools.cosd(surface_tilt)) * 0.5 | ||
) | ||
T = T_term1 + T_term2 * T_term3 | ||
|
||
horizontal_extra = dni_extra * np.maximum(cos_solar_zenith, 0.01745) | ||
F = (ghi - dhi) / horizontal_extra | ||
|
||
sky_diffuse = dhi*(T*(1-F) + F*Rb) | ||
|
||
return sky_diffuse | ||
|
||
|
||
def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra, | ||
solar_zenith, solar_azimuth, airmass, | ||
model='allsitescomposite1990', return_components=False): | ||
|
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.