8000 Change Variables and Symbols page into a Glossary of terms by RDaxini · Pull Request #2234 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Change Variables and Symbols page into a Glossary of terms #2234

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 30 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3ccef46
initial test
RDaxini Sep 29, 2024
a7ba8ea
Update irradiance.py
RDaxini Sep 29, 2024
678d7e4
update list of terms
RDaxini Oct 9, 2024
ef311d0
update dni description in irradiance.py
RDaxini Oct 9, 2024
2360025
minor edits, aoi definition
RDaxini Oct 9, 2024
a68d27e
Update glossary.rst
RDaxini Oct 9, 2024
9b6f7b0
Update glossary.rst
RDaxini Oct 9, 2024
4b90bd4
remove in-text dni term glossary link
RDaxini Oct 9, 2024
80175c3
delete one surface_tilt definition
RDaxini Oct 9, 2024
34d87c4
review: dni definition
RDaxini Oct 9, 2024
ffa60c6
remove old files, add general text to glossary
RDaxini Oct 10, 2024
5297a08
remove first bullet, add colon, on SoDa line
RDaxini Oct 10, 2024
8e578e5
Update glossary.rst
RDaxini Oct 10, 2024
fc4d2e7
conciseness (suggestion)
RDaxini Oct 10, 2024
816f43d
updated aoi definition #2247
RDaxini Oct 19, 2024
7d6a0ac
update references old variables style rules page
RDaxini Oct 19, 2024
3c6ef52
Merge remote-tracking branch 'upstream/main' into glossary
RDaxini Oct 19, 2024
7329393
remove old page link from v0.3.0 whatsnew
RDaxini Oct 19, 2024
70957f0
Update index.rst
RDaxini Oct 19, 2024
65de172
Update v0.11.2.rst
RDaxini Oct 19, 2024
21d6115
Update docs/sphinx/source/user_guide/glossary.rst
RDaxini Oct 19, 2024
34c155a
Merge remote-tracking branch 'upstream/main' into glossary
RDaxini Oct 20, 2024
ff9383a
Update docs/sphinx/source/contributing/style_guide.rst
RDaxini Oct 21, 2024
d5dca77
add underscore
RDaxini Oct 30, 2024
eae6e48
changed reference label
RDaxini Oct 30, 2024
3491f26
update labels
RDaxini Oct 30, 2024
637d250
name: nomenclature, update labels
RDaxini Oct 30, 2024
dc001fa
update whatsnew wording
RDaxini Oct 30, 2024
72f2f96
update file name
RDaxini Oct 30, 2024
3ec3cb3
Merge branch 'main' into glossary
RDaxini Oct 31, 2024
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into glossary
  • Loading branch information
RDaxini committed Oct 19, 2024
commit 3c6ef528b089292c6a715ab73c3cb62f2d9b44ae
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Contributing
============

We need your help to make pvlib-python a great tool!
Please see the [Contributing page](http://pvlib-python.readthedocs.io/en/stable/contributing.html) for more on how you can contribute.
Please see the [Contributing page](https://pvlib-python.readthedocs.io/en/stable/contributing/index.html) for more on how you can contribute.
The long-term success of pvlib-python requires substantial community support.


Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx/source/contributing/testing.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _testing:

Testing
=======
Testing and benchmarking
========================

.. _overview:

Expand Down
6 changes: 4 additions & 2 deletions docs/sphinx/source/whatsnew/v0.11.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Enhancements
Documentation
~~~~~~~~~~~~~
* Edited docstrings for :py:func:`~pvlib.pvsystem.dc_ohms_from_percent` and
:py:func:`~pvlib.pvsystem.dc_ohmic_loss` for clarity. (:issue:`1601`, :pull:`2229`)

:py:func:`~pvlib.pvsystem.dc_ohmic_losses` for clarity. (:issue:`1601`, :pull:`2229`)
* Updated :py:func:`~pvlib.irradiance.reindl` to include definitions of terms
and a new "notes" section (:issue:`2183`, :pull:`2193`)

Testing
~~~~~~~
Expand All @@ -29,4 +30,5 @@ Requirements
Contributors
~~~~~~~~~~~~
* Cliff Hansen (:ghuser:`cwhanse`)
* Rajiv Daxini (:ghuser:`RDaxini`)

73 changes: 73 additions & 0 deletions pvlib/_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,76 @@ def wrapper(*args, **kwargs):
return finalize(wrapper, new_doc)

return deprecate


def renamed_kwarg_warning(since, old_param_name, new_param_name, removal=""):
"""
Decorator to mark a possible keyword argument as deprecated and replaced
with other name.

Raises a warning when the deprecated argument is used, and replaces the
call with the new argument name. Does not modify the function signature.

.. warning::
Ensure ``removal`` date with a ``fail_on_pvlib_version`` decorator in
the test suite.

.. note::
Not compatible with positional-only arguments.

.. note::
Documentation for the function may updated to reflect the new parameter
name; it is suggested to add a |.. versionchanged::| directive.

Parameters
----------
since : str
The release at which this API became deprecated.
old_param_name : str
The name of the deprecated parameter.
new_param_name : str
The name of the new parameter.
removal : str, optional
The expected removal version, in order to compose the Warning message.

Examples
--------
>>> @renamed_kwarg_warning("1.4.0", "old_name", "new_name", "1.6.0")
>>> def some_function(new_name=None):
>>> pass
>>> some_function(old_name=1)
Parameter 'old_name' has been renamed since 1.4.0. and
will be removed in 1.6.0. Please use 'new_name' instead.

>>> @renamed_kwarg_warning("1.4.0", "old_name", "new_name")
>>> def some_function(new_name=None):
>>> pass
>>> some_function(old_name=1)
Parameter 'old_name' has been renamed since 1.4.0. and
will be removed soon. Please use 'new_name' instead.
"""

def deprecate(func, old=old_param_name, new=new_param_name, since=since):
def wrapper(*args, **kwargs):
if old in kwargs:
if new in kwargs:
raise ValueError(
f"{func.__name__} received both '{old}' and '{new}', "
"which are mutually exclusive since they refer to the "
f"same parameter. Please remove deprecated '{old}'."
)
warnings.warn(
f"Parameter '{old}' has been renamed since {since}. "
f"and will be removed "
+ (f"in {removal}" if removal else "soon")
+ f". Please use '{new}' instead.",
_projectWarning,
stacklevel=2,
)
kwargs[new] = kwargs.pop(old)
return func(*args, **kwargs)

wrapper = functools.wraps(func)(wrapper)
return wrapper

return deprecate
8 changes: 4 additions & 4 deletions pvlib/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ def martin_ruiz(aoi, a_r=0.16):

which is presented as :math:`AL(\alpha) = 1 - IAM` in equation 4 of [1]_,
with :math:`\alpha` representing the angle of incidence AOI. Thus IAM = 1
at AOI = 0, and IAM = 0 at AOI = 90. This equation is only valid for
-90 <= aoi <= 90, therefore `iam` is constrained to 0.0 outside this
at AOI = 0°, and IAM = 0 at AOI = 90°. This equation is only valid for
<= aoi <= 90°, therefore `iam` is constrained to 0.0 outside this
interval.

References
Expand Down Expand Up @@ -891,8 +891,8 @@ def schlick_diffuse(surface_tilt):
implements only the integrated Schlick approximation.

Note also that the output of this function (which is an exact integration)
can be compared with the output of :py:func:`marion_diffuse` which numerically
integrates the Schlick approximation:
can be compared with the output of :py:func:`marion_diffuse` which
numerically integrates the Schlick approximation:

.. code::

Expand Down
61 changes: 37 add 1E0A itions & 24 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,19 +869,14 @@ def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,
solar_zenith, solar_azimuth):
r'''
Determine diffuse irradiance from the sky on a tilted surface using
Reindl's 1990 model

.. math::
Determine the diffuse irradiance from the sky on a tilted surface using
the Reindl (1990) model.

I_{d} = DHI \left(A R_b + (1 - A) \left(\frac{1 + \cos\beta}{2}\right)
\left(1 + \sqrt{\frac{I_{hb}}{I_h}} \sin^3(\beta/2)\right) \right)

Reindl's 1990 model determines the diffuse irradiance from the sky
(ground reflected irradiance is not included in this algorithm) on a
tilted surface using the surface tilt angle, surface azimuth angle,
The Reindl (1990) model [1]_ [2]_ determines the diffuse irradiance from
the sky on
a tilted surface using the surface tilt angle, surface azimuth angle,
diffuse horizontal irradiance, direct normal irradiance, global
horizontal irradiance, extraterrestrial irradiance, sun zenith
horizontal irradiance, extraterrestrial normal irradiance, sun zenith
angle, and sun azimuth angle.

Parameters
Expand All @@ -903,7 +898,7 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,
direct normal irradiance. [Wm⁻²]

ghi: numeric
Global irradiance. [Wm⁻²]
Global horizontal irradiance. [Wm⁻²]

dni_extra : numeric
Extraterrestrial normal irradiance. [Wm⁻²]
Expand All @@ -923,23 +918,41 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,

Notes
-----
The poa_sky_diffuse calculation is generated from the Loutzenhiser et al.
(2007) paper, equation 8. Note that I have removed the beam and ground
reflectance portion of the equation and this generates ONLY the diffuse
radiation from the sky and circumsolar, so the form of the equation
varies slightly from equation 8.
The Reindl (1990) model for the sky diffuse irradiance,
:math:`I_d`, is as follows:

.. math::

I_{d} = DHI \left(A \cdot R_b + (1 - A)
\left(\frac{1 + \cos\beta}{2}\right)
\left(1 + \sqrt{\frac{BHI}{GHI}} \sin^3(\beta/2)\right) \right).

:math:`DHI`, :math:`BHI`, and :math:`GHI` are the diffuse horizontal, beam
(direct) horizontal and global horizontal irradiances, respectively.
:math:`A` is the anisotropy index, which is the ratio of the direct normal
irradiance to the direct extraterrestrial irradiation, :math:`R_b` is the
projection ratio, which is defined as the ratio of the cosine of the angle
of incidence (AOI) to the cosine of the zenith angle, and :math:`\beta`
is the tilt angle of the array.

Implementation is based on Loutzenhiser et al.
(2007) [3]_, Equation 8. The beam and ground reflectance portion of the
equation have been removed, therefore the model described here generates
ONLY the diffuse radiation from the sky and circumsolar, so the form of the
equation varies slightly from Equation 8 in [3]_.

References
----------
.. [1] Loutzenhiser P.G. et. al. "Empirical validation of models to
compute solar irradiance on inclined surfaces for building energy
simulation" 2007, Solar Energy vol. 81. pp. 254-267

.. [2] Reindl, D.T., Beckmann, W.A., Duffie, J.A., 1990a. Diffuse
.. [1] Reindl, D. T., Beckmann, W. A., Duffie, J. A., 1990a. Diffuse
fraction correlations. Solar Energy 45(1), 1-7.

.. [3] Reindl, D.T., Beckmann, W.A., Duffie, J.A., 1990b. Evaluation of
:doi:`10.1016/0038-092X(90)90060-P`
.. [2] Reindl, D. T., Beckmann, W. A., Duffie, J. A., 1990b. Evaluation of
hourly tilted surface radiation models. Solar Energy 45(1), 9-17.
:doi:`10.1016/0038-092X(90)90061-G`
.. [3] Loutzenhiser P. G. et. al., 2007. Empirical validation of models to
compute solar irradiance on inclined surfaces for building energy
simulation. Solar Energy 81(2), 254-267
:doi:`10.1016/j.solener.2006.03.009`
'''

cos_tt = aoi_projection(surface_tilt, surface_azimuth,
Expand Down
2 changes: 1 addition & 1 deletion pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2952,7 +2952,7 @@ def dc_ohmic_losses(resistance, current):

.. math::

L = I \times R^2
L = I^2 \times R

where :math:`I` is the current (A) and :math:`R` is the resistance of the
conductor (ohms).
Expand Down
51 changes: 51 additions & 0 deletions pvlib/tests/test__deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
Test the _deprecation module.
"""

import pytest

from pvlib import _deprecation

import warnings


@pytest.fixture
def renamed_kwarg_func():
"""Returns a function decorated by renamed_kwarg_warning.
This function is called 'func' and has a docstring equal to 'docstring'.
"""

@_deprecation.renamed_kwarg_warning(
"0.1.0", "old_kwarg", "new_kwarg", "0.2.0"
)
def func(new_kwarg):
"""docstring"""
return new_kwarg

return func


def test_renamed_kwarg_warning(renamed_kwarg_func):
# assert decorated function name and docstring are unchanged
assert renamed_kwarg_func.__name__ == "func"
assert renamed_kwarg_func.__doc__ == "docstring"

# assert no warning is raised when using the new kwarg
with warnings.catch_warnings():
warnings.simplefilter("error")
assert renamed_kwarg_func(new_kwarg=1) == 1 # as keyword argument
assert renamed_kwarg_func(1) == 1 # as positional argument

# assert a warning is raised when using the old kwarg
with pytest.warns(Warning, match="Parameter 'old_kwarg' has been renamed"):
assert renamed_kwarg_func(old_kwarg=1) == 1

# assert an error is raised when using both the old and new kwarg
with pytest.raises(ValueError, match="they refer to the same parameter."):
renamed_kwarg_func(old_kwarg=1, new_kwarg=2)

# assert when not providing any of them
with pytest.raises(
TypeError, match="missing 1 required positional argument"
):
renamed_kwarg_func()
You are viewing a condensed version of this merge commit. You can view the full changes here.
0