Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion docs/sphinx/source/whatsnew/v0.16.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Breaking Changes

Deprecations
~~~~~~~~~~~~

* Deprecate :py:func:`pvlib.irradiance.king`.
Use other diffuse transposition models in :py:mod:`pvlib.irradiance` instead.
(:issue:`2636`, :pull:`2783`)

Bug fixes
~~~~~~~~~
Expand Down
6 changes: 6 additions & 0 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,12 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,
return sky_diffuse


@deprecated(
since="0.16.0",
removal="0.17.0",
name="pvlib.irradiance.king",
alternative="other diffuse transposition models in pvlib.irradiance",
)
def king(surface_tilt, dhi, ghi, solar_zenith):
'''
Determine diffuse irradiance from the sky on a tilted surface using
Expand Down
13 changes: 7 additions & 6 deletions tests/test_irradiance.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some other tests are emitting the deprecation error as well. It would be good to suppress those too:

tests/test_irradiance.py::test_sky_diffuse_zenith_close_to_90[king]
tests/test_irradiance.py::test_get_total_irradiance
tests/test_irradiance.py::test_get_total_irradiance_albedo[king]
tests/test_irradiance.py::test_get_total_irradiance_scalars[king]
  /home/runner/work/pvlib-python/pvlib-python/pvlib/irradiance.py:457: pvlibDeprecationWarning: The pvlib.irradiance.king function was deprecated in pvlib 0.15.3 and will be removed in 0.17.0. Use other diffuse transposition models in pvlib.irradiance instead.
    sky = king(surface_tilt, dhi, ghi, solar_zenith)

https://github.com/pvlib/pvlib-python/actions/runs/28933855087/job/85839249803?pr=2783#step:9:88

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see two ways to prevent this, one is to add if checks inside the tests, another is to remove king from those existing tests entirely and create separate ones for king specifically. I think the latter would make it easier to remove everything king-related when it is eventually removed from pvlib, would you agree?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that new tests just for king are necessary, I would say just drop 'king' from the parameter list.

Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ def test_reindl(irrad_data, ephem_data, dni_et):


def test_king(irrad_data, ephem_data):
result = irradiance.king(40, irrad_data['dhi'], irrad_data['ghi'],
ephem_data['apparent_zenith'])
with pytest.warns(pvlibDeprecationWarning, match='king'):
result = irradiance.king(40, irrad_data['dhi'], irrad_data['ghi'],
ephem_data['apparent_zenith'])
assert_allclose(result, [0, 44.629352, 115.182626, 79.719855], atol=1e-4)


Expand Down Expand Up @@ -439,7 +440,7 @@ def test_perez_driesse_scalar():


@pytest.mark.parametrize('model', ['isotropic', 'klucher', 'haydavies',
'reindl', 'king', 'perez', 'perez-driesse'])
'reindl', 'perez', 'perez-driesse'])
def test_sky_diffuse_zenith_close_to_90(model):
# GH 432
sky_diffuse = irradiance.get_sky_diffuse(
Expand Down Expand Up @@ -491,7 +492,7 @@ def test_campbell_norman():
def test_get_total_irradiance(irrad_data, ephem_data, dni_et,
relative_airmass):
models = ['isotropic', 'klucher',
'haydavies', 'reindl', 'king', 'perez', 'perez-driesse']
'haydavies', 'reindl', 'perez', 'perez-driesse']

for model in models:
total = irradiance.get_total_irradiance(
Expand All @@ -509,7 +510,7 @@ def test_get_total_irradiance(irrad_data, ephem_data, dni_et,


@pytest.mark.parametrize('model', ['isotropic', 'klucher',
'haydavies', 'reindl', 'king',
'haydavies', 'reindl',
'perez', 'perez-driesse'])
def test_get_total_irradiance_albedo(
irrad_data, ephem_data, dni_et, relative_airmass, model):
Expand All @@ -529,7 +530,7 @@ def test_get_total_irradiance_albedo(


@pytest.mark.parametrize('model', ['isotropic', 'klucher',
'haydavies', 'reindl', 'king',
'haydavies', 'reindl',
'perez', 'perez-driesse'])
def test_get_total_irradiance_scalars(model):
total = irradiance.get_total_irradiance(
Expand Down
Loading