diff --git a/docs/sphinx/source/whatsnew/v0.10.3.rst b/docs/sphinx/source/whatsnew/v0.10.3.rst index 007eb8d34b..279aac7daa 100644 --- a/docs/sphinx/source/whatsnew/v0.10.3.rst +++ b/docs/sphinx/source/whatsnew/v0.10.3.rst @@ -17,6 +17,8 @@ Bug fixes ~~~~~~~~~ * Fix mapping of the dew point column to ``temp_dew`` when ``map_variables`` is True in :py:func:`pvlib.iotools.get_psm3`. (:pull:`1920`) +* Fix :py:class:`pvlib.modelchain.ModelChain` to use attribute `clearsky_model` + (:pull:`1924`) Testing ~~~~~~~ @@ -28,6 +30,7 @@ Documentation * Create :ref:`weatherdata` User's Guide page. (:pull:`1754`) * Fixed a plotting issue in the IV curve gallery example (:pull:`1895`) * Fixed `detect_clearsky` example in `clearsky.rst` (:issue:`1914`) +* Clarified purpose of `ModelChain.clearsky_model` (:pull:`1924`) Requirements ~~~~~~~~~~~~ @@ -44,3 +47,4 @@ Contributors * Harry Jack (:ghuser:`harry-solcast`) * Adam R. Jensen (:ghuser:`AdamRJensen`) * Kevin Anderson (:ghuser:`kandersolar`) +* Cliff Hansen (:ghuser:`cwhanse`) diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index c88f8a7641..04611fe7e1 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -460,7 +460,8 @@ class ModelChain: the physical location at which to evaluate the model. clearsky_model : str, default 'ineichen' - Passed to location.get_clearsky. + Passed to location.get_clearsky. Only used when DNI is not found in + the weather inputs. transposition_model : str, default 'haydavies' Passed to system.get_irradiance. @@ -1354,7 +1355,8 @@ def _complete_irradiance(self, weather): "https://github.com/pvlib/pvlib-python \n") if {'ghi', 'dhi'} <= icolumns and 'dni' not in icolumns: clearsky = self.location.get_clearsky( - weather.index, solar_position=self.results.solar_position) + weather.index, model=self.clearsky_model, + solar_position=self.results.solar_position) complete_irrad_df = pvlib.irradiance.complete_irradiance( solar_zenith=self.results.solar_position.zenith, ghi=weather.ghi, diff --git a/pvlib/tests/test_modelchain.py b/pvlib/tests/test_modelchain.py index c59a02e9c4..0632d34212 100644 --- a/pvlib/tests/test_modelchain.py +++ b/pvlib/tests/test_modelchain.py @@ -1847,7 +1847,7 @@ def test_complete_irradiance_clean_run(sapm_dc_snl_ac_system, location): pd.Series([9, 5], index=times, name='ghi')) -def test_complete_irradiance(sapm_dc_snl_ac_system, location): +def test_complete_irradiance(sapm_dc_snl_ac_system, location, mocker): """Check calculations""" mc = ModelChain(sapm_dc_snl_ac_system, location) times = pd.date_range('2010-07-05 7:00:00-0700', periods=2, freq='H') @@ -1867,7 +1867,11 @@ def test_complete_irradiance(sapm_dc_snl_ac_system, location): pd.Series([372.103976116, 497.087579068], index=times, name='ghi')) + # check that clearsky_model is used correctly + m_ineichen = mocker.spy(location, 'get_clearsky') mc.complete_irradiance(i[['dhi', 'ghi']]) + assert m_ineichen.call_count == 1 + assert m_ineichen.call_args[1]['model'] == 'ineichen' assert_series_equal(mc.results.weather['dni'], pd.Series([49.756966, 62.153947], index=times, name='dni'))