Skip to content

remove 0.8 deprecations from pvsystem.py, modelchain.py, rework temperature model param deprecation #1033

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 19 commits into from
Aug 27, 2020
Merged
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
2 changes: 1 addition & 1 deletion .stickler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ linters:
flake8:
python: 3
max-line-length: 79
ignore: E201,E241,E226
ignore: E201,E241,E226,W503,W504
files:
ignore:
- 'pvlib/_version.py'
26 changes: 26 additions & 0 deletions docs/sphinx/source/whatsnew/v0.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ API Changes with Deprecations
- :py:func:`pvlib.pvsystem.adrinverter` is now :py:func:`pvlib.inverter.adr`
* Argument ``ac_model`` for :py:class:`pvlib.modelchain.ModelChain` now accepts
``'sandia'``, ``'pvwatts'`` and ``'adr'`` for the inverter models. (:pull:`886`)
* :py:class:`pvlib.pvsystem.PVSystem` ``module_type`` and ``racking_model`` now
default to ``None``. This continues a deprecation of assuming SAPM values
for cell temperature modeling. In this v0.8 release series, calling
:py:meth:`pvlib.pvsystem.PVSystem.sapm_celltemp` without setting ``PVSystem.temperature model parameters``,
or a valid combination of ``PVsystem.module_type`` and ``PVsystem.racking_model``, will cause
``PVSystem.temperature_model_parameters`` to be set to SAPM values for a
glass/glass module in open racking and emit a warning. In v0.9, users must
provide ``temperature_model_parameters`` or a valid combination of
``module_type`` and ``racking_model``. (:issue:`1030`, :pull:`1033`)

API Changes
~~~~~~~~~~~
Expand All @@ -31,6 +40,23 @@ API Changes
:py:func:`pvlib.iotools.read_tmy3`, :py:meth:`pvlib.location.Location.from_tmy`, and
:py:class:`pvlib.pvsystem.LocalizedPVSystem` for alternatives. (:issue:`965`)
(:pull:`1008`)
* The following functions, methods, and arguments were deprecated in a previous
release and have now been removed (:issue:`966`, :pull:`1033`):
* ``pvsystem.PVSystem.ashraeiam``. Use :py:meth:`pvlib.pvsystem.PVSystem.get_iam`.
* ``pvsystem.PVSystem.physicaliam``. Use :py:meth:`pvlib.pvsystem.PVSystem.get_iam`.
* ``pvsystem.PVSystem.sapm_aoi_loss``. Use :py:meth:`pvlib.pvsystem.PVSystem.get_iam`.
* ``pvsystem.ashraeiam``. Use :py:func:`pvlib.iam.ashrae`.
* ``pvsystem.physicaliam``. Use :py:func:`pvlib.iam.physical`.
* ``pvsystem.sapm_aoi_loss``. Use :py:func:`pvlib.iam.sapm`.
* ``pvsystem.sapm_celltemp``. Use :py:func:`pvlib.temperature.sapm_cell`.
* ``pvsystem.pvsyst_celltemp``. Use :py:func:`pvlib.temperature.pvsyst_cell`.
* ``times`` keyword argument of
:py:meth:`pvlib.modelchain.ModelChain.run_model`,
:py:meth:`pvlib.modelchain.ModelChain.complete_irradiance`, and
:py:meth:`pvlib.modelchain.ModelChain.prepare_inputs`.
The index of the input DataFrame is used instead.
* ``temp_model`` keyword argument of
:py:meth:`pvlib.modelchain.ModelChain`. Use ``temperature_model`` instead.

Enhancements
~~~~~~~~~~~~
Expand Down
68 changes: 13 additions & 55 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def basic_chain(times, latitude, longitude,
linke_turbidity,
altitude=altitude,
dni_extra=dni_extra
)
)

total_irrad = pvlib.irradiance.get_total_irradiance(
surface_tilt,
Expand Down Expand Up @@ -346,24 +346,6 @@ def __init__(self, system, location,
self.ac_model = ac_model
self.aoi_model = aoi_model
self.spectral_model = spectral_model

# TODO: deprecated kwarg temp_model. Remove use of temp_model in v0.8
temp_model = kwargs.pop('temp_model', None)
if temp_model is not None:
if temperature_model is None:
warnings.warn('The temp_model keyword argument is deprecated.'
' Use temperature_model instead',
pvlibDeprecationWarning)
temperature_model = temp_model
elif temp_model == temperature_model:
warnings.warn('Provide only one of temperature_model or '
'temp_model (deprecated).',
pvlibDeprecationWarning)
else:
raise ValueError(
'Conflicting temperature_model {} and temp_model {}. '
'temp_model is deprecated. Specify only temperature_model.'
.format(temperature_model, temp_model))
self.temperature_model = temperature_model

self.losses_model = losses_model
Expand Down Expand Up @@ -544,7 +526,7 @@ def __repr__(self):
'transposition_model', 'solar_position_method',
'airmass_model', 'dc_model', 'ac_model', 'aoi_model',
'spectral_model', 'temperature_model', 'losses_model'
]
]

def getmcattr(self, attr):
"""needed to avoid recursion in property lookups"""
Expand Down Expand Up @@ -588,8 +570,8 @@ def dc_model(self, model):
model = model.lower()
if model in _DC_MODEL_PARAMS.keys():
# validate module parameters
missing_params = _DC_MODEL_PARAMS[model] - \
set(self.system.module_parameters.keys())
missing_params = (_DC_MODEL_PARAMS[model]
- set(self.system.module_parameters.keys()))
if missing_params: # some parameters are not in module.keys()
raise ValueError(model + ' selected for the DC model but '
'one or more required parameters are '
Expand Down Expand Up @@ -834,8 +816,8 @@ def infer_spectral_model(self):

def first_solar_spectral_loss(self):
self.spectral_modifier = self.system.first_solar_spectral_loss(
self.weather['precipitable_water'],
self.airmass['airmass_absolute'])
self.weather['precipitable_water'],
self.airmass['airmass_absolute'])
return self

def sapm_spectral_loss(self):
Expand Down Expand Up @@ -878,7 +860,10 @@ def temperature_model(self, model):

def infer_temperature_model(self):
params = set(self.system.temperature_model_parameters.keys())
if set(['a', 'b', 'deltaT']) <= params:
# remove or statement in v0.9
if set(['a', 'b', 'deltaT']) <= params or (
not params and self.system.racking_model is None
and self.system.module_type is None):
return self.sapm_temp
elif set(['u_c', 'u_v']) <= params:
return self.pvsyst_temp
Expand Down Expand Up @@ -945,7 +930,7 @@ def effective_irradiance_model(self):
fd*self.total_irrad['poa_diffuse'])
return self

def complete_irradiance(self, weather, times=None):
def complete_irradiance(self, weather):
"""
Determine the missing irradiation columns. Only two of the
following data columns (dni, ghi, dhi) are needed to calculate
Expand All @@ -962,10 +947,6 @@ def complete_irradiance(self, weather, times=None):
``'wind_speed'``, ``'temp_air'``. All irradiance components
are required. Air temperature of 20 C and wind speed
of 0 m/s will be added to the DataFrame if not provided.
times : None, deprecated
Deprecated argument included for API compatibility, but not
used internally. The index of the weather DataFrame is used
for times.

Returns
-------
Expand Down Expand Up @@ -994,11 +975,6 @@ def complete_irradiance(self, weather, times=None):
"""
self.weather = weather

if times is not None:
warnings.warn('times keyword argument is deprecated and will be '
'removed in 0.8. The index of the weather DataFrame '
'is used for times.', pvlibDeprecationWarning)

self.solar_position = self.location.get_solarposition(
self.weather.index, method=self.solar_position_method)

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

return self

def prepare_inputs(self, weather, times=None):
def prepare_inputs(self, weather):
"""
Prepare the solar position, irradiance, and weather inputs to
the model.
Expand All @@ -1041,10 +1017,6 @@ def prepare_inputs(self, weather, times=None):
``'wind_speed'``, ``'temp_air'``. All irradiance components
are required. Air temperature of 20 C and wind speed
of 0 m/s will be added to the DataFrame if not provided.
times : None, deprecated
Deprecated argument included for API compatibility, but not
used internally. The index of the weather DataFrame is used
for times.

Notes
-----
Expand All @@ -1064,11 +1036,6 @@ def prepare_inputs(self, weather, times=None):

self.weather = weather

if times is not None:
warnings.warn('times keyword argument is deprecated and will be '
'removed in 0.8. The index of the weather DataFrame '
'is used for times.', pvlibDeprecationWarning)

self.times = self.weather.index
try:
kwargs = _build_kwargs(['pressure', 'temp_air'], weather)
Expand Down Expand Up @@ -1126,7 +1093,7 @@ def prepare_inputs(self, weather, times=None):
self.weather['temp_air'] = 20
return self

def run_model(self, weather, times=None):
def run_model(self, weather):
"""
Run the model.

Expand All @@ -1137,10 +1104,6 @@ def run_model(self, weather, times=None):
``'wind_speed'``, ``'temp_air'``. All irradiance components
are required. Air temperature of 20 C and wind speed
of 0 m/s will be added to the DataFrame if not provided.
times : None, deprecated
Deprecated argument included for API compatibility, but not
used internally. The index of the weather DataFrame is used
for times.

Returns
-------
Expand All @@ -1152,11 +1115,6 @@ def run_model(self, weather, times=None):
``dc``, ``ac``, ``losses``,
``diode_params`` (if dc_model is a single diode model)
"""
if times is not None:
warnings.warn('times keyword argument is deprecated and will be '
'removed in 0.8. The index of the weather DataFrame '
'is used for times.', pvlibDeprecationWarning)

self.prepare_inputs(weather)
self.aoi_model()
self.spectral_model()
Expand Down
Loading