Skip to content

Commit 75369dc

Browse files
wholmgrencwhanse
andauthored
remove 0.8 deprecations from pvsystem.py, modelchain.py, rework temperature model param deprecation (#1033)
* pvsystem 0.8 deprecations * rework temp, racking, module deprecations * whats new * remove effective irradiance warning * remove shim code for pre-0.6 from calc params desoto * use pytest match instead of warn_txt * remove times from ModelChain methods * remove temp_model from ModelChain * fix tracking objects reprs * move warning to where it counts: PVSystem.sapm_celltemp * lint * flake8 doesnt complain... * mirror stickler config in setup * agree to disagree on linebreak style rules * cant resist a little more pep8 * update whatsnew * broken link in whatsnew * Update docs/sphinx/source/whatsnew/v0.8.0.rst Co-authored-by: Cliff Hansen <[email protected]> Co-authored-by: Cliff Hansen <[email protected]>
1 parent a7edb8b commit 75369dc

File tree

8 files changed

+111
-414
lines changed

8 files changed

+111
-414
lines changed

.stickler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ linters:
22
flake8:
33
python: 3
44
max-line-length: 79
5-
ignore: E201,E241,E226
5+
ignore: E201,E241,E226,W503,W504
66
files:
77
ignore:
88
- 'pvlib/_version.py'

docs/sphinx/source/whatsnew/v0.8.0.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ API Changes with Deprecations
1212
- :py:func:`pvlib.pvsystem.adrinverter` is now :py:func:`pvlib.inverter.adr`
1313
* Argument ``ac_model`` for :py:class:`pvlib.modelchain.ModelChain` now accepts
1414
``'sandia'``, ``'pvwatts'`` and ``'adr'`` for the inverter models. (:pull:`886`)
15+
* :py:class:`pvlib.pvsystem.PVSystem` ``module_type`` and ``racking_model`` now
16+
default to ``None``. This continues a deprecation of assuming SAPM values
17+
for cell temperature modeling. In this v0.8 release series, calling
18+
:py:meth:`pvlib.pvsystem.PVSystem.sapm_celltemp` without setting ``PVSystem.temperature model parameters``,
19+
or a valid combination of ``PVsystem.module_type`` and ``PVsystem.racking_model``, will cause
20+
``PVSystem.temperature_model_parameters`` to be set to SAPM values for a
21+
glass/glass module in open racking and emit a warning. In v0.9, users must
22+
provide ``temperature_model_parameters`` or a valid combination of
23+
``module_type`` and ``racking_model``. (:issue:`1030`, :pull:`1033`)
1524

1625
API Changes
1726
~~~~~~~~~~~
@@ -31,6 +40,23 @@ API Changes
3140
:py:func:`pvlib.iotools.read_tmy3`, :py:meth:`pvlib.location.Location.from_tmy`, and
3241
:py:class:`pvlib.pvsystem.LocalizedPVSystem` for alternatives. (:issue:`965`)
3342
(:pull:`1008`)
43+
* The following functions, methods, and arguments were deprecated in a previous
44+
release and have now been removed (:issue:`966`, :pull:`1033`):
45+
* ``pvsystem.PVSystem.ashraeiam``. Use :py:meth:`pvlib.pvsystem.PVSystem.get_iam`.
46+
* ``pvsystem.PVSystem.physicaliam``. Use :py:meth:`pvlib.pvsystem.PVSystem.get_iam`.
47+
* ``pvsystem.PVSystem.sapm_aoi_loss``. Use :py:meth:`pvlib.pvsystem.PVSystem.get_iam`.
48+
* ``pvsystem.ashraeiam``. Use :py:func:`pvlib.iam.ashrae`.
49+
* ``pvsystem.physicaliam``. Use :py:func:`pvlib.iam.physical`.
50+
* ``pvsystem.sapm_aoi_loss``. Use :py:func:`pvlib.iam.sapm`.
51+
* ``pvsystem.sapm_celltemp``. Use :py:func:`pvlib.temperature.sapm_cell`.
52+
* ``pvsystem.pvsyst_celltemp``. Use :py:func:`pvlib.temperature.pvsyst_cell`.
53+
* ``times`` keyword argument of
54+
:py:meth:`pvlib.modelchain.ModelChain.run_model`,
55+
:py:meth:`pvlib.modelchain.ModelChain.complete_irradiance`, and
56+
:py:meth:`pvlib.modelchain.ModelChain.prepare_inputs`.
57+
The index of the input DataFrame is used instead.
58+
* ``temp_model`` keyword argument of
59+
:py:meth:`pvlib.modelchain.ModelChain`. Use ``temperature_model`` instead.
3460

3561
Enhancements
3662
~~~~~~~~~~~~

pvlib/modelchain.py

Lines changed: 13 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def basic_chain(times, latitude, longitude,
179179
linke_turbidity,
180180
altitude=altitude,
181181
dni_extra=dni_extra
182-
)
182+
)
183183

184184
total_irrad = pvlib.irradiance.get_total_irradiance(
185185
surface_tilt,
@@ -346,24 +346,6 @@ def __init__(self, system, location,
346346
self.ac_model = ac_model
347347
self.aoi_model = aoi_model
348348
self.spectral_model = spectral_model
349-
350-
# TODO: deprecated kwarg temp_model. Remove use of temp_model in v0.8
351-
temp_model = kwargs.pop('temp_model', None)
352-
if temp_model is not None:
353-
if temperature_model is None:
354-
warnings.warn('The temp_model keyword argument is deprecated.'
355-
' Use temperature_model instead',
356-
pvlibDeprecationWarning)
357-
temperature_model = temp_model
358-
elif temp_model == temperature_model:
359-
warnings.warn('Provide only one of temperature_model or '
360-
'temp_model (deprecated).',
361-
pvlibDeprecationWarning)
362-
else:
363-
raise ValueError(
364-
'Conflicting temperature_model {} and temp_model {}. '
365-
'temp_model is deprecated. Specify only temperature_model.'
366-
.format(temperature_model, temp_model))
367349
self.temperature_model = temperature_model
368350

369351
self.losses_model = losses_model
@@ -544,7 +526,7 @@ def __repr__(self):
544526
'transposition_model', 'solar_position_method',
545527
'airmass_model', 'dc_model', 'ac_model', 'aoi_model',
546528
'spectral_model', 'temperature_model', 'losses_model'
547-
]
529+
]
548530

549531
def getmcattr(self, attr):
550532
"""needed to avoid recursion in property lookups"""
@@ -588,8 +570,8 @@ def dc_model(self, model):
588570
model = model.lower()
589571
if model in _DC_MODEL_PARAMS.keys():
590572
# validate module parameters
591-
missing_params = _DC_MODEL_PARAMS[model] - \
592-
set(self.system.module_parameters.keys())
573+
missing_params = (_DC_MODEL_PARAMS[model]
574+
- set(self.system.module_parameters.keys()))
593575
if missing_params: # some parameters are not in module.keys()
594576
raise ValueError(model + ' selected for the DC model but '
595577
'one or more required parameters are '
@@ -834,8 +816,8 @@ def infer_spectral_model(self):
834816

835817
def first_solar_spectral_loss(self):
836818
self.spectral_modifier = self.system.first_solar_spectral_loss(
837-
self.weather['precipitable_water'],
838-
self.airmass['airmass_absolute'])
819+
self.weather['precipitable_water'],
820+
self.airmass['airmass_absolute'])
839821
return self
840822

841823
def sapm_spectral_loss(self):
@@ -878,7 +860,10 @@ def temperature_model(self, model):
878860

879861
def infer_temperature_model(self):
880862
params = set(self.system.temperature_model_parameters.keys())
881-
if set(['a', 'b', 'deltaT']) <= params:
863+
# remove or statement in v0.9
864+
if set(['a', 'b', 'deltaT']) <= params or (
865+
not params and self.system.racking_model is None
866+
and self.system.module_type is None):
882867
return self.sapm_temp
883868
elif set(['u_c', 'u_v']) <= params:
884869
return self.pvsyst_temp
@@ -945,7 +930,7 @@ def effective_irradiance_model(self):
945930
fd*self.total_irrad['poa_diffuse'])
946931
return self
947932

948-
def complete_irradiance(self, weather, times=None):
933+
def complete_irradiance(self, weather):
949934
"""
950935
Determine the missing irradiation columns. Only two of the
951936
following data columns (dni, ghi, dhi) are needed to calculate
@@ -962,10 +947,6 @@ def complete_irradiance(self, weather, times=None):
962947
``'wind_speed'``, ``'temp_air'``. All irradiance components
963948
are required. Air temperature of 20 C and wind speed
964949
of 0 m/s will be added to the DataFrame if not provided.
965-
times : None, deprecated
966-
Deprecated argument included for API compatibility, but not
967-
used internally. The index of the weather DataFrame is used
968-
for times.
969950
970951
Returns
971952
-------
@@ -994,11 +975,6 @@ def complete_irradiance(self, weather, times=None):
994975
"""
995976
self.weather = weather
996977

997-
if times is not None:
998-
warnings.warn('times keyword argument is deprecated and will be '
999-
'removed in 0.8. The index of the weather DataFrame '
1000-
'is used for times.', pvlibDeprecationWarning)
1001-
1002978
self.solar_position = self.location.get_solarposition(
1003979
self.weather.index, method=self.solar_position_method)
1004980

@@ -1029,7 +1005,7 @@ def complete_irradiance(self, weather, times=None):
10291005

10301006
return self
10311007

1032-
def prepare_inputs(self, weather, times=None):
1008+
def prepare_inputs(self, weather):
10331009
"""
10341010
Prepare the solar position, irradiance, and weather inputs to
10351011
the model.
@@ -1041,10 +1017,6 @@ def prepare_inputs(self, weather, times=None):
10411017
``'wind_speed'``, ``'temp_air'``. All irradiance components
10421018
are required. Air temperature of 20 C and wind speed
10431019
of 0 m/s will be added to the DataFrame if not provided.
1044-
times : None, deprecated
1045-
Deprecated argument included for API compatibility, but not
1046-
used internally. The index of the weather DataFrame is used
1047-
for times.
10481020
10491021
Notes
10501022
-----
@@ -1064,11 +1036,6 @@ def prepare_inputs(self, weather, times=None):
10641036

10651037
self.weather = weather
10661038

1067-
if times is not None:
1068-
warnings.warn('times keyword argument is deprecated and will be '
1069-
'removed in 0.8. The index of the weather DataFrame '
1070-
'is used for times.', pvlibDeprecationWarning)
1071-
10721039
self.times = self.weather.index
10731040
try:
10741041
kwargs = _build_kwargs(['pressure', 'temp_air'], weather)
@@ -1126,7 +1093,7 @@ def prepare_inputs(self, weather, times=None):
11261093
self.weather['temp_air'] = 20
11271094
return self
11281095

1129-
def run_model(self, weather, times=None):
1096+
def run_model(self, weather):
11301097
"""
11311098
Run the model.
11321099
@@ -1137,10 +1104,6 @@ def run_model(self, weather, times=None):
11371104
``'wind_speed'``, ``'temp_air'``. All irradiance components
11381105
are required. Air temperature of 20 C and wind speed
11391106
of 0 m/s will be added to the DataFrame if not provided.
1140-
times : None, deprecated
1141-
Deprecated argument included for API compatibility, but not
1142-
used internally. The index of the weather DataFrame is used
1143-
for times.
11441107
11451108
Returns
11461109
-------
@@ -1152,11 +1115,6 @@ def run_model(self, weather, times=None):
11521115
``dc``, ``ac``, ``losses``,
11531116
``diode_params`` (if dc_model is a single diode model)
11541117
"""
1155-
if times is not None:
1156-
warnings.warn('times keyword argument is deprecated and will be '
1157-
'removed in 0.8. The index of the weather DataFrame '
1158-
'is used for times.', pvlibDeprecationWarning)
1159-
11601118
self.prepare_inputs(weather)
11611119
self.aoi_model()
11621120
self.spectral_model()

0 commit comments

Comments
 (0)