Skip to content

Fix and document clearsky_model for ModelChain #1924

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 7 commits into from
Dec 14, 2023
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
4 changes: 4 additions & 0 deletions docs/sphinx/source/whatsnew/v0.10.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~
Expand All @@ -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
~~~~~~~~~~~~
Expand All @@ -44,3 +47,4 @@ Contributors
* Harry Jack (:ghuser:`harry-solcast`)
* Adam R. Jensen (:ghuser:`AdamRJensen`)
* Kevin Anderson (:ghuser:`kandersolar`)
* Cliff Hansen (:ghuser:`cwhanse`)
6 changes: 4 additions & 2 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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'))
Expand Down