Skip to content

Added irradiance_loss_pvsyst function to pvsystem #1000

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 33 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
693e60d
Added irradiance_loss_pvsyst function to pvsystem module and method t…
btaute Jul 8, 2020
ad09984
Updated formatting
btaute Jul 9, 2020
896e71f
fixing loss equation formatting
btaute Jul 10, 2020
430ab3d
Fix math formatting
btaute Jul 10, 2020
06efce1
Added Tests
btaute Jul 10, 2020
43ac80e
fix formatting in tests
btaute Jul 10, 2020
1bd866b
more test formatting fixes
btaute Jul 10, 2020
7969ce5
Updated v0.8.0 What's New
btaute Jul 10, 2020
8b617b7
Added Issue Number to v0.8.0 What's New
btaute Jul 10, 2020
2361db2
Update pvlib/pvsystem.py
btaute Jul 21, 2020
e0e168c
Update pvlib/pvsystem.py
btaute Jul 21, 2020
b7169bd
Update pvlib/pvsystem.py
btaute Jul 22, 2020
607bdb9
Update pvlib/tests/test_pvsystem.py
btaute Jul 22, 2020
6c408f5
Update pvlib/tests/test_pvsystem.py
btaute Jul 22, 2020
4b33177
Update pvlib/tests/test_pvsystem.py
btaute Jul 22, 2020
29cccdd
Updated params and output to be percents
btaute Jul 22, 2020
25fc424
fix indents
btaute Jul 22, 2020
5d488e7
Changed function to generic combine_loss_factors
btaute Aug 4, 2020
6f2f976
Changed function to generic combine_loss_factors
btaute Aug 4, 2020
3a90af3
Merge branch 'master' of https://github.com/btaute/pvlib-python
btaute Aug 4, 2020
6c5e5a9
fixed test typo
btaute Aug 4, 2020
49a7f04
indentation fix
btaute Aug 4, 2020
50590d3
whitespace fix
btaute Aug 4, 2020
48fd3b4
Moved combine_loss_factors to PV System Effects
btaute Aug 4, 2020
7107119
Apply suggestions from code review
btaute Aug 4, 2020
0b6ae04
fill_method docstring update
btaute Aug 4, 2020
ce50282
Merge branch 'master' of https://github.com/btaute/pvlib-python
btaute Aug 4, 2020
62e9af3
fill_method docstring update
btaute Aug 4, 2020
0d1e95c
Merge branch 'master' into master
btaute Sep 2, 2020
d8abcfe
Update v0.8.0.rst
btaute Sep 2, 2020
4391540
Update pvsystem.py
btaute Sep 2, 2020
1af4854
Update test_pvsystem.py
btaute Sep 2, 2020
70f2fa8
Update v0.8.0.rst
btaute Sep 2, 2020
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/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ Other
Effects on PV System Output
===========================

Loss models
^^^^^^^^^^^
.. autosummary::
:toctree: generated/

pvsystem.combine_loss_factors

.. autosummary::
:toctree: generated/

Expand Down
3 changes: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ Enhancements
PVSystem, LocalizedPVSystem, SingleAxisTracker, and
LocalizedSingleAxisTracker repr methods. (:issue:`1027`)
* Added ability for :py:func:`pvlib.soiling.hsu` to accept arbitrary time intervals. (:pull:`980`)
* Add :py:func:`pvlib.pvsystem.combine_loss_factors` as general purpose
function to combine loss factors with a common index.
Partialy addresses :issue:`988`. Contributed by Brock Taute :ghuser:`btaute`

Bug fixes
~~~~~~~~~
Expand Down
42 changes: 42 additions & 0 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,48 @@ def pvwatts_losses(soiling=2, shading=3, snow=0, mismatch=2, wiring=2,
return losses


def combine_loss_factors(index, *losses, fill_method='ffill'):
r"""
Combines Series loss fractions while setting a common index.

The separate losses are compounded using the following equation:

.. math::

L_{total} = 1 - [ 1 - \Pi_i ( 1 - L_i ) ]

:math:`L_{total}` is the total loss returned
:math:`L_i` is each individual loss factor input

Note the losses must each be a series with a DatetimeIndex.
All losses will be resampled to match the index parameter using
the fill method specified (defaults to "fill forward").

Parameters
----------
index : DatetimeIndex
The index of the returned loss factors

*losses : Series
One or more Series of fractions to be compounded

fill_method : {'ffill', 'bfill', 'nearest'}, default 'ffill'
Method to use for filling holes in reindexed DataFrame

Returns
-------
Series
Fractions resulting from the combination of each loss factor
"""
combined_factor = 1

for loss in losses:
loss = loss.reindex(index, method=fill_method)
combined_factor *= (1 - loss)

return 1 - combined_factor


snlinverter = deprecated('0.8', alternative='inverter.sandia',
name='snlinverter', removal='0.9')(inverter.sandia)

Expand Down
12 changes: 12 additions & 0 deletions pvlib/tests/test_pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,18 @@ def test_PVSystem_pvwatts_ac_kwargs(mocker):
assert out < pdc


def test_combine_loss_factors():
test_index = pd.date_range(start='1990/01/01T12:00', periods=365, freq='D')
loss_1 = pd.Series(.10, index=test_index)
loss_2 = pd.Series(.05, index=pd.date_range(start='1990/01/01T12:00',
periods=365*2, freq='D'))
loss_3 = pd.Series(.02, index=pd.date_range(start='1990/01/01',
periods=12, freq='MS'))
expected = pd.Series(.1621, index=test_index)
out = pvsystem.combine_loss_factors(test_index, loss_1, loss_2, loss_3)
assert_series_equal(expected, out)


@fail_on_pvlib_version('0.9')
def test_deprecated_09(cec_inverter_parameters, adr_inverter_parameters):
# deprecated function pvsystem.snlinverter
Expand Down