Skip to content

Commit d979187

Browse files
Jonathan Gaffiotwholmgren
authored andcommitted
Fix crash in ModelChain.infer_spectral_model due to incorrect method call (2) (#629)
* Fix incorrect call to pvsystem instead of self.system * Update whatsnew * Add a test for infer_spectral_model * Add name to whatsnew * Revert change in comment
1 parent e5473bd commit d979187

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Bug fixes
5555
and < 1900, fix year 2050 which was returning 0.
5656
* Fix and improve :func:`~pvlib.solarposition.hour_angle` (:issue:`598`)
5757
* Fix error in :func:`pvlib.clearsky.detect_clearsky` (:issue:`506`)
58+
* Fix error in :func:`pvlib.modelchain.ModelChain.infer_spectral_model` (:issue:`619`)
5859

5960

6061
Testing
@@ -72,3 +73,4 @@ Contributors
7273
* Cliff Hansen (:ghuser:`cwhanse`)
7374
* Mark Mikofski (:ghuser:`mikofski`)
7475
* Anton Driesse (:ghuser:`adriesse`)
76+
* Jonathan Gaffiot (:ghuser:`jgaffiot`)

pvlib/modelchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def infer_spectral_model(self):
622622
return self.sapm_spectral_loss
623623
elif ((('Technology' in params or
624624
'Material' in params) and
625-
(pvsystem._infer_cell_type() is not None)) or
625+
(self.system._infer_cell_type() is not None)) or
626626
'first_solar_spectral_coefficients' in params):
627627
return self.first_solar_spectral_loss
628628
else:

pvlib/test/test_modelchain.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ def cec_dc_snl_ac_system(sam_data):
5454
return system
5555

5656

57+
@pytest.fixture
58+
def cec_dc_native_snl_ac_system(sam_data):
59+
module = 'Canadian_Solar_CS5P_220M'
60+
module_parameters = sam_data['cecmod'][module].copy()
61+
inverters = sam_data['cecinverter']
62+
inverter = inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'].copy()
63+
system = PVSystem(surface_tilt=32.2, surface_azimuth=180,
64+
module=module,
65+
module_parameters=module_parameters,
66+
inverter_parameters=inverter)
67+
return system
68+
69+
5770
@pytest.fixture
5871
def pvsyst_dc_snl_ac_system(sam_data, pvsyst_module_params):
5972
module = 'PVsyst test module'
@@ -251,6 +264,21 @@ def test_infer_dc_model(system, cec_dc_snl_ac_system, pvsyst_dc_snl_ac_system,
251264
assert isinstance(mc.dc, (pd.Series, pd.DataFrame))
252265

253266

267+
@pytest.mark.parametrize('dc_model', [
268+
'sapm',
269+
pytest.param('cec', marks=requires_scipy),
270+
pytest.param('cec_native', marks=requires_scipy)])
271+
def test_infer_spectral_model(location, system, cec_dc_snl_ac_system,
272+
cec_dc_native_snl_ac_system, dc_model):
273+
dc_systems = {'sapm': system,
274+
'cec': cec_dc_snl_ac_system,
275+
'cec_native': cec_dc_native_snl_ac_system}
276+
system = dc_systems[dc_model]
277+
mc = ModelChain(system, location,
278+
orientation_strategy='None', aoi_model='physical')
279+
assert isinstance(mc, ModelChain)
280+
281+
254282
def test_dc_model_user_func(pvwatts_dc_pvwatts_ac_system, location, weather,
255283
mocker):
256284
m = mocker.spy(sys.modules[__name__], 'poadc')

0 commit comments

Comments
 (0)