Skip to content
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
8 changes: 6 additions & 2 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,10 +1519,14 @@ def _prepare_temperature(self, data=None):
if not isinstance(data, tuple):
# broadcast data to all arrays
data = (data,) * self.system.num_arrays
# data is tuple, so temperature_model_parameters must also be
# tuple. system.temperature_model_parameters is reduced to a dict
# if system.num_arrays == 1, so manually access parameters. GH 1192
t_mod_params = tuple(array.temperature_model_parameters
for array in self.system.arrays)
# find where cell or module temperature is specified in input data
given_cell_temperature = tuple(itertools.starmap(
self._get_cell_temperature,
zip(data, poa, self.system.temperature_model_parameters)
self._get_cell_temperature, zip(data, poa, t_mod_params)
))
# If cell temperature has been specified for all arrays return
# immediately and do not try to compute it.
Expand Down
32 changes: 32 additions & 0 deletions pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,38 @@ def test__prepare_temperature(sapm_dc_snl_ac_system, location, weather,
assert_series_equal(mc.results.cell_temperature, data['cell_temperature'])


def test__prepare_temperature_len1_weather_tuple(
sapm_dc_snl_ac_system, location, weather, total_irrad):
# GH 1192
weather['module_temperature'] = [40., 30.]
data = weather.copy()

mc = ModelChain(sapm_dc_snl_ac_system, location, aoi_model='no_loss',
spectral_model='no_loss')
mc.run_model([data])
expected = pd.Series([42.617244212941394, 30.0], index=data.index)
assert_series_equal(mc.results.cell_temperature[0], expected)

data = weather.copy().rename(
columns={
"ghi": "poa_global", "dhi": "poa_diffuse", "dni": "poa_direct"}
)
mc = ModelChain(sapm_dc_snl_ac_system, location, aoi_model='no_loss',
spectral_model='no_loss')
mc.run_model_from_poa([data])
expected = pd.Series([41.5, 30.0], index=data.index)
assert_series_equal(mc.results.cell_temperature[0], expected)

data = weather.copy()[["module_temperature", "ghi"]].rename(
columns={"ghi": "effective_irradiance"}
)
mc = ModelChain(sapm_dc_snl_ac_system, location, aoi_model='no_loss',
spectral_model='no_loss')
mc.run_model_from_effective_irradiance([data])
expected = pd.Series([41.5, 30.0], index=data.index)
assert_series_equal(mc.results.cell_temperature[0], expected)


def test__prepare_temperature_arrays_weather(sapm_dc_snl_ac_system_same_arrays,
location, weather,
total_irrad):
Expand Down