Skip to content

Commit ae84817

Browse files
authored
Fix and document clearsky_model for ModelChain (#1924)
* add note about clearsky_model * whatsnew * pass clearsky_model to get_clearsky * add bug fix note * test for correct argument * test for correct argument * test for correct argument
1 parent 304fbb5 commit ae84817

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

docs/sphinx/source/whatsnew/v0.10.3.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Bug fixes
2222
:py:func:`pvlib.iotools.get_cams` (:issue:`1799`, :pull:`1905`)
2323
* Fix mapping of the dew point column to ``temp_dew`` when ``map_variables``
2424
is True in :py:func:`pvlib.iotools.get_psm3`. (:pull:`1920`)
25+
* Fix :py:class:`pvlib.modelchain.ModelChain` to use attribute `clearsky_model`
26+
(:pull:`1924`)
2527

2628
Testing
2729
~~~~~~~
@@ -34,6 +36,7 @@ Documentation
3436
* Fixed a plotting issue in the IV curve gallery example (:pull:`1895`)
3537
* Added two examples to demonstrate reverse transposition (:pull:`1907`)
3638
* Fixed `detect_clearsky` example in `clearsky.rst` (:issue:`1914`)
39+
* Clarified purpose of `ModelChain.clearsky_model` (:pull:`1924`)
3740

3841

3942
Requirements
@@ -52,3 +55,4 @@ Contributors
5255
* :ghuser:`matsuobasho`
5356
* Harry Jack (:ghuser:`harry-solcast`)
5457
* Kevin Anderson (:ghuser:`kandersolar`)
58+
* Cliff Hansen (:ghuser:`cwhanse`)

pvlib/modelchain.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ class ModelChain:
460460
the physical location at which to evaluate the model.
461461
462462
clearsky_model : str, default 'ineichen'
463-
Passed to location.get_clearsky.
463+
Passed to location.get_clearsky. Only used when DNI is not found in
464+
the weather inputs.
464465
465466
transposition_model : str, default 'haydavies'
466467
Passed to system.get_irradiance.
@@ -1354,7 +1355,8 @@ def _complete_irradiance(self, weather):
13541355
"https://github.com/pvlib/pvlib-python \n")
13551356
if {'ghi', 'dhi'} <= icolumns and 'dni' not in icolumns:
13561357
clearsky = self.location.get_clearsky(
1357-
weather.index, solar_position=self.results.solar_position)
1358+
weather.index, model=self.clearsky_model,
1359+
solar_position=self.results.solar_position)
13581360
complete_irrad_df = pvlib.irradiance.complete_irradiance(
13591361
solar_zenith=self.results.solar_position.zenith,
13601362
ghi=weather.ghi,

pvlib/tests/test_modelchain.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ def test_complete_irradiance_clean_run(sapm_dc_snl_ac_system, location):
18471847
pd.Series([9, 5], index=times, name='ghi'))
18481848

18491849

1850-
def test_complete_irradiance(sapm_dc_snl_ac_system, location):
1850+
def test_complete_irradiance(sapm_dc_snl_ac_system, location, mocker):
18511851
"""Check calculations"""
18521852
mc = ModelChain(sapm_dc_snl_ac_system, location)
18531853
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):
18671867
pd.Series([372.103976116, 497.087579068],
18681868
index=times, name='ghi'))
18691869

1870+
# check that clearsky_model is used correctly
1871+
m_ineichen = mocker.spy(location, 'get_clearsky')
18701872
mc.complete_irradiance(i[['dhi', 'ghi']])
1873+
assert m_ineichen.call_count == 1
1874+
assert m_ineichen.call_args[1]['model'] == 'ineichen'
18711875
assert_series_equal(mc.results.weather['dni'],
18721876
pd.Series([49.756966, 62.153947],
18731877
index=times, name='dni'))

0 commit comments

Comments
 (0)