Repository: pvlib/pvlib-python

Issue:
TypeError: running ModelChain with Arrays and module_temperature
**Describe the bug**
Another bug using Arrays. This time a TypeError is raised in `pvlib.modelchain._get_cell_temperature` because `self.system.temperature_model_parameters` is zipped with dataframe tuples but is never a tuple itself
https://github.com/pvlib/pvlib-python/blob/dc617d0c182bc8eec57898a039cb5115b425645f/pvlib/modelchain.py#L1525

**To Reproduce**
```python
import traceback
import pandas as pd
from pvlib.location import Location
from pvlib.pvsystem import Array, PVSystem
from pvlib.modelchain import ModelChain


array_params = {
    "surface_tilt": 32.0,
    "surface_azimuth": 180.0,
    "module": "Canadian_Solar_Inc__CS5P_220M",
    "albedo": 0.2,
    "temperature_model_parameters": {
        "a": -3.47,
        "b": -0.0594,
        "deltaT": 3.0,
    },
    "strings": 5,
    "modules_per_string": 7,
    "module_parameters": {
        "alpha_sc": 0.004539,
        "gamma_ref": 1.2,
        "mu_gamma": -0.003,
        "I_L_ref": 5.11426,
        "I_o_ref": 8.10251e-10,
        "R_sh_ref": 381.254,
        "R_sh_0": 400.0,
        "R_s": 1.06602,
        "cells_in_series": 96,
        "R_sh_exp": 5.5,
        "EgRef": 1.121,
    },
}
inverter_parameters = {
    "Paco": 250.0,
    "Pdco": 259.589,
    "Vdco": 40.0,
    "Pso": 2.08961,
    "C0": -4.1e-05,
    "C1": -9.1e-05,
    "C2": 0.000494,
    "C3": -0.013171,
    "Pnt": 0.075,
}


location = Location(latitude=33.98, longitude=-115.323, altitude=2300)

array_sys = PVSystem(
    arrays=[
        Array(**array_params, name=0),
    ],
    inverter_parameters=inverter_parameters,
)
poa = pd.DataFrame(
    {
        "poa_global": [1100.0, 1101.0],
        "poa_direct": [1000.0, 1001.0],
        "poa_diffuse": [100.0, 100.0],
        "module_temperature": [35.0, 33.0],
    },
    index=pd.DatetimeIndex(
        [pd.Timestamp("2021-01-20T12:00-05:00"), pd.Timestamp("2021-01-20T12:05-05:00")]
    ),
)
standard = poa.copy().rename(
    columns={"poa_global": "ghi", "poa_direct": "dni", "poa_diffuse": "dhi"}
)
effective = poa.copy()[["module_temperature", "poa_global"]].rename(
    columns={"poa_global": "effective_irradiance"}
)
mc = ModelChain(
    array_sys,
    location,
    aoi_model="no_loss",
    spectral_model="no_loss",
)
try:
    mc.run_model([standard])
except TypeError:
    print(traceback.format_exc())
else:
    raise RuntimeError("expected a type error")
try:
    mc.run_model_from_poa([poa])
except TypeError:
    print(traceback.format_exc())
else:
    raise RuntimeError("expected a type error")
try:
    mc.run_model_from_effective_irradiance([effective])
except TypeError:
    print(traceback.format_exc())
else:
    raise RuntimeError("expected a type error")

```

**Versions:**
 - ``pvlib.__version__``:  master/g684b247



Discussion:

Patch:
diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py
--- a/pvlib/modelchain.py
+++ b/pvlib/modelchain.py
@@ -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.


Test patch:
diff --git a/pvlib/tests/test_modelchain.py b/pvlib/tests/test_modelchain.py
--- a/pvlib/tests/test_modelchain.py
+++ b/pvlib/tests/test_modelchain.py
@@ -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):