diff --git a/docs/sphinx/source/whatsnew/v0.15.2.rst b/docs/sphinx/source/whatsnew/v0.15.2.rst index 1f4524d893..dcff85d744 100644 --- a/docs/sphinx/source/whatsnew/v0.15.2.rst +++ b/docs/sphinx/source/whatsnew/v0.15.2.rst @@ -10,6 +10,15 @@ Breaking Changes Deprecations ~~~~~~~~~~~~ +* The function :py:func:`pvlib.clearsky._is_leap_year` is deprecated and will be + removed in v0.17.0. Use :py:func:`pandas.Timestamp.is_leap_year` instead. + (:issue: `2764`, :pull:`2766`) +* The function :py:func:`pvlib.irradiance._liujordan` is deprecated and will be + removed in v0.17.0. (:issue: `2764`, :pull:`2766`) +* The function :py:func:`pvlib.modelchain.get_orientation` is deprecated and will + be removed in v0.17.0. (:issue: `2764`, :pull:`2766`) +* The method :py:meth:`pvlib.modelchain.ModelChain._prep_inputs_tracking` is + deprecated and will be removed in v0.17.0. (:issue: `2764`, :pull:`2766`) Bug fixes @@ -62,3 +71,4 @@ Contributors * Cliff Hansen (:ghuser:`cwhanse`) * Arthur Onno (:ghuser:`ArthurOnnoTerabase`) * Adam R. Jensen (:ghuser:`AdamRJensen`) +* :ghuser:`JoLo90` diff --git a/pvlib/clearsky.py b/pvlib/clearsky.py index 0f5ab63392..fd11a0d4cc 100644 --- a/pvlib/clearsky.py +++ b/pvlib/clearsky.py @@ -14,6 +14,7 @@ from pvlib import atmosphere, tools from pvlib.tools import _degrees_to_index +from pvlib._deprecation import deprecated def ineichen(apparent_zenith, airmass_absolute, linke_turbidity, @@ -220,6 +221,13 @@ def lookup_linke_turbidity(time, latitude, longitude, filepath=None, return linke_turbidity +@deprecated( + since="0.15.2", + removal="0.17.0", + name="_is_leap_year", + alternative=None, + addendum=None, +) def _is_leap_year(year): """Determine if a year is leap year. diff --git a/pvlib/iotools/bsrn.py b/pvlib/iotools/bsrn.py index 3cb77b239e..21e497f38a 100644 --- a/pvlib/iotools/bsrn.py +++ b/pvlib/iotools/bsrn.py @@ -465,5 +465,5 @@ def read_bsrn(filename, logical_records=('0100',)): return content -parse_bsrn = deprecated(since="0.13.0", name="parse_bsrn", +parse_bsrn = deprecated(since="0.13.0", removal="0.17.0", name="parse_bsrn", alternative="read_bsrn")(read_bsrn) diff --git a/pvlib/iotools/epw.py b/pvlib/iotools/epw.py index dd46c50999..897337187b 100644 --- a/pvlib/iotools/epw.py +++ b/pvlib/iotools/epw.py @@ -311,5 +311,5 @@ def _parse_epw(csvdata, coerce_year=None): return data, meta -parse_epw = deprecated(since="0.13.0", name="parse_epw", +parse_epw = deprecated(since="0.13.0", removal="0.17.0", name="parse_epw", alternative="read_epw")(read_epw) diff --git a/pvlib/iotools/sodapro.py b/pvlib/iotools/sodapro.py index be11dbf260..81212d8112 100644 --- a/pvlib/iotools/sodapro.py +++ b/pvlib/iotools/sodapro.py @@ -359,5 +359,5 @@ def read_cams(filename, integrated=False, label=None, map_variables=True): return data, metadata -parse_cams = deprecated(since="0.13.0", name="parse_cams", +parse_cams = deprecated(since="0.13.0", removal="0.17.0", name="parse_cams", alternative="read_cams")(read_cams) diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py index 5a4a76df25..791671a642 100644 --- a/pvlib/irradiance.py +++ b/pvlib/irradiance.py @@ -18,6 +18,7 @@ from pvlib._deprecation import pvlibDeprecationWarning import warnings +from pvlib._deprecation import deprecated # Deprecation warning based on https://peps.python.org/pep-0562/ @@ -3087,7 +3088,14 @@ def campbell_norman(zenith, transmittance, pressure=101325.0, return irrads -def _liujordan(zenith, transmittance, airmass, dni_extra=1367.0): +@deprecated( + since="0.15.2", + removal="0.17.0", + name="_liujordan", + addendum=None, +) +def _liujordan(zenith: pd.Series, transmittance: float, + airmass: float, dni_extra=1367.0) -> pd.DataFrame: ''' Determine DNI, DHI, GHI from extraterrestrial flux, transmittance, and optical air mass number. @@ -3106,11 +3114,11 @@ def _liujordan(zenith, transmittance, airmass, dni_extra=1367.0): transmittance: float Atmospheric transmittance between 0 and 1. - pressure: float, default 101325.0 - Air pressure + airmass: float + Absolute airmass. dni_extra: float, default 1367.0 - Direct irradiance incident at the top of the atmosphere. + Direct irradiance incident at the top of the atmosphere. [W/m²] Returns ------- @@ -3126,6 +3134,11 @@ def _liujordan(zenith, transmittance, airmass, dni_extra=1367.0): .. [2] Liu, B. Y., R. C. Jordan, (1960). "The interrelationship and characteristic distribution of direct, diffuse, and total solar radiation". Solar Energy 4:1-19 + + .. deprecated:: 0.15.2 + The ``_liujordan`` function is deprecated and will be + removed in 0.17.0. + Use the ``liujordan`` function instead. ''' tau = transmittance diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index 45374bd6fa..999a35e1fc 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -63,7 +63,7 @@ @deprecated( since="0.13.1", - removal="", + removal="0.17.0", name="pvlib.modelchain.get_orientation", alternative=None, addendum=None, @@ -84,6 +84,10 @@ def get_orientation(strategy, **kwargs): Returns ------- surface_tilt, surface_azimuth + + .. deprecated:: 0.15.2 + The ``get_orientation`` function is deprecated and will be removed + in 0.17.0. """ if strategy == 'south_at_latitude_tilt': surface_azimuth = 180 @@ -1248,6 +1252,13 @@ def _prep_inputs_airmass(self): model=self.airmass_model) return self + @deprecated( + since="0.15.2", + removal="0.17.0", + name="Modelchain._prep_inputs_tracking", + alternative=None, + addendum=None, + ) def _prep_inputs_tracking(self): """ Calculate tracker position and AOI diff --git a/pvlib/tracking.py b/pvlib/tracking.py index 69c679ef79..e234887cd0 100644 --- a/pvlib/tracking.py +++ b/pvlib/tracking.py @@ -1,7 +1,7 @@ import numpy as np import pandas as pd -from pvlib.tools import cosd, sind, tand, acosd, asind +from pvlib.tools import cosd, sind, tand, acosd from pvlib import irradiance from pvlib import shading from pvlib._deprecation import renamed_kwarg_warning diff --git a/tests/test_clearsky.py b/tests/test_clearsky.py index 687dd9133e..a984544c55 100644 --- a/tests/test_clearsky.py +++ b/tests/test_clearsky.py @@ -8,13 +8,15 @@ import pytest from numpy.testing import assert_allclose -from .conftest import assert_frame_equal, assert_series_equal +from .conftest import (assert_frame_equal, assert_series_equal, + fail_on_pvlib_version) from pvlib.location import Location from pvlib import clearsky from pvlib import solarposition from pvlib import atmosphere from pvlib import irradiance +from pvlib._deprecation import pvlibDeprecationWarning from .conftest import TESTS_DATA_DIR @@ -892,5 +894,13 @@ def test_bird(): # XXX: testdata starts at 1am so noon is at index = 11 np.allclose( [Eb3, Ebh3, Gh3, Dh3], - testdata2[['Direct Beam', 'Direct Hz', 'Global Hz', 'Dif Hz']].iloc[11], + testdata2[['Direct Beam', 'Direct Hz', + 'Global Hz', 'Dif Hz']].iloc[11], rtol=1e-3) + + +@fail_on_pvlib_version('0.17.0') +def test_is_leap_year_deprecation(): + with pytest.warns(pvlibDeprecationWarning, + match='will be removed in 0.17.0.'): + clearsky._is_leap_year(2020) diff --git a/tests/test_irradiance.py b/tests/test_irradiance.py index a416636ae9..b49dbb076d 100644 --- a/tests/test_irradiance.py +++ b/tests/test_irradiance.py @@ -14,6 +14,7 @@ from .conftest import ( assert_frame_equal, assert_series_equal, + fail_on_pvlib_version, requires_ephem, requires_numba, ) @@ -1454,3 +1455,11 @@ def test_diffuse_par_spitters(): 0.99591, 0.99576, 0.99472, 0.99270, 0.99283, 0.99406, 0.99581, 0.99591, ]) # fmt: skip assert_allclose(result, expected, atol=1e-5) + + +@fail_on_pvlib_version('0.17.0') +def test_liujordan_deprecation(): + zenith = pd.Series([45.0, 50.0, 55.0]) + with pytest.warns(pvlibDeprecationWarning, + match='will be removed in 0.17.0.'): + irradiance._liujordan(zenith, transmittance=0.7, airmass=1.5) diff --git a/tests/test_modelchain.py b/tests/test_modelchain.py index 9ea804f014..7026a8ea3b 100644 --- a/tests/test_modelchain.py +++ b/tests/test_modelchain.py @@ -1,4 +1,5 @@ import sys +from unittest.mock import MagicMock import numpy as np import pandas as pd @@ -10,7 +11,8 @@ from pvlib._deprecation import pvlibDeprecationWarning -from .conftest import assert_series_equal, assert_frame_equal +from .conftest import (assert_series_equal, assert_frame_equal, + fail_on_pvlib_version) import pytest @@ -1799,12 +1801,36 @@ def test_invalid_models(model, sapm_dc_snl_ac_system, location): ModelChain(sapm_dc_snl_ac_system, location, **kwargs) +@fail_on_pvlib_version('0.17.0') def test_bad_get_orientation(): - with pytest.warns(pvlibDeprecationWarning, match='will be removed soon'): + with pytest.warns(pvlibDeprecationWarning, + match='will be removed in 0.17.0.'): with pytest.raises(ValueError): modelchain.get_orientation('bad value') +@fail_on_pvlib_version('0.17.0') +def test_get_orientation_deprecation(): + with pytest.warns(pvlibDeprecationWarning, + match='will be removed in 0.17.0.'): + surface_tilt, surface_azimuth = modelchain.get_orientation('flat') + assert surface_tilt == 0 + assert surface_azimuth == 180 + + +@fail_on_pvlib_version('0.17.0') +def test_prep_inputs_tracking_deprecation(sapm_dc_snl_ac_system, location): + mc = ModelChain(sapm_dc_snl_ac_system, location) + # Set up mock results and system attributes required by the method + mc.results = MagicMock() + mc.system.singleaxis = MagicMock() + mc.system.axis_tilt = 0.0 + mc.system.axis_azimuth = 180.0 + with pytest.warns(pvlibDeprecationWarning, + match='will be removed in 0.17.0.'): + mc._prep_inputs_tracking() + + # tests for PVSystem with multiple Arrays def test_with_sapm_pvsystem_arrays(sapm_dc_snl_ac_system_Array, location, weather):