From 01a68f7af1d98575582988a6426a6152c6135b5c Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Sun, 22 Nov 2026 09:06:13 -0700 Subject: [PATCH 1/7] remove fillna from modelchain.dc and .ac --- pvlib/modelchain.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index d2112ac25a..f385192db2 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -626,7 +626,7 @@ def _make_diode_params(photocurrent, saturation_current, self.results.dc, unwrap=False ) - self.results.dc = tuple(dc.fillna(0) for dc in self.results.dc) + # self.results.dc = tuple(dc.fillna(0) for dc in self.results.dc) # If the system has one Array, unwrap the single return value # to preserve the original behavior of ModelChain if self.system.num_arrays == 1: @@ -726,8 +726,8 @@ def adr_inverter(self): return self def pvwatts_inverter(self): - ac = self.system.get_ac('pvwatts', self.results.dc) - self.results.ac = ac.fillna(0) + self.results.ac = self.system.get_ac('pvwatts', self.results.dc) + # self.results.ac = ac.fillna(0) return self @property From 57b6bc739692764b85d8de234b5cf5c4db1ec3bf Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Sun, 22 Nov 2026 09:23:23 -0700 Subject: [PATCH 2/7] whatsnew --- docs/sphinx/source/whatsnew/v0.16.2.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.16.2.rst b/docs/sphinx/source/whatsnew/v0.16.2.rst index fb3ff54f76..3b57fa6eba 100644 --- a/docs/sphinx/source/whatsnew/v0.16.2.rst +++ b/docs/sphinx/source/whatsnew/v0.16.2.rst @@ -6,7 +6,8 @@ v0.16.2 (Anticipated December, 2026) Breaking Changes ~~~~~~~~~~~~~~~~ - +* ``ModelChain`` no longer fills NaN with 0 in DC power and AC power. + (:issue:`1409`, :pull:`2955`) Deprecations ~~~~~~~~~~~~ From 3531b3ebdea4d5bc5281c3bb03e9359f9fc30b50 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Tue, 24 Nov 2026 17:58:41 -0700 Subject: [PATCH 3/7] v0.17.0 --- docs/sphinx/source/whatsnew/v0.17.0.rst | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 docs/sphinx/source/whatsnew/v0.17.0.rst diff --git a/docs/sphinx/source/whatsnew/v0.17.0.rst b/docs/sphinx/source/whatsnew/v0.17.0.rst new file mode 100644 index 0000000000..b7f5b698d7 --- /dev/null +++ b/docs/sphinx/source/whatsnew/v0.17.0.rst @@ -0,0 +1,50 @@ +.. _whatsnew_0_X_Y: + + +v0.X.Y (Month XX, 20YY) +----------------------- + +Breaking Changes +~~~~~~~~~~~~~~~~ +* ``ModelChain`` no longer infers cell type for modules in the CEC database + with Technology of 'Thin Film'. Previously cell type 'cigs' was assigned + for all such modules, which is incorrect for some. Cell type is used to + infer default parameters for :py:func:`pvlib.spectrum.spectral_factor_firstsolar` + Users should assign spectral model parameters in ``PVSystem.module_parameters`` + or set ``PVSystem.Technology`` to the correct cell type. + +Deprecations +~~~~~~~~~~~~ + + +Bug fixes +~~~~~~~~~ + + +Enhancements +~~~~~~~~~~~~ + + +Documentation +~~~~~~~~~~~~~ + + +Testing +~~~~~~~ + + +Benchmarking +~~~~~~~~~~~~ + + +Requirements +~~~~~~~~~~~~ + + +Maintenance +~~~~~~~~~~~ + + +Contributors +~~~~~~~~~~~~ +* Cliff Hansen (:ghuser:`cwhanse`) From 613da41274d521c7d9c163f47dfef730ddf61a39 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Tue, 24 Nov 2026 18:08:36 -0700 Subject: [PATCH 4/7] move to v0.17.0 --- docs/sphinx/source/whatsnew/v0.16.2.rst | 3 +-- docs/sphinx/source/whatsnew/v0.17.0.rst | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.16.2.rst b/docs/sphinx/source/whatsnew/v0.16.2.rst index 3b57fa6eba..fb3ff54f76 100644 --- a/docs/sphinx/source/whatsnew/v0.16.2.rst +++ b/docs/sphinx/source/whatsnew/v0.16.2.rst @@ -6,8 +6,7 @@ v0.16.2 (Anticipated December, 2026) Breaking Changes ~~~~~~~~~~~~~~~~ -* ``ModelChain`` no longer fills NaN with 0 in DC power and AC power. - (:issue:`1409`, :pull:`2955`) + Deprecations ~~~~~~~~~~~~ diff --git a/docs/sphinx/source/whatsnew/v0.17.0.rst b/docs/sphinx/source/whatsnew/v0.17.0.rst index b7f5b698d7..da4241bb9f 100644 --- a/docs/sphinx/source/whatsnew/v0.17.0.rst +++ b/docs/sphinx/source/whatsnew/v0.17.0.rst @@ -6,12 +6,8 @@ v0.X.Y (Month XX, 20YY) Breaking Changes ~~~~~~~~~~~~~~~~ -* ``ModelChain`` no longer infers cell type for modules in the CEC database - with Technology of 'Thin Film'. Previously cell type 'cigs' was assigned - for all such modules, which is incorrect for some. Cell type is used to - infer default parameters for :py:func:`pvlib.spectrum.spectral_factor_firstsolar` - Users should assign spectral model parameters in ``PVSystem.module_parameters`` - or set ``PVSystem.Technology`` to the correct cell type. +* ``ModelChain`` no longer fills NaN with 0 in DC power and AC power. + (:issue:`1409`, :pull:`2955`) Deprecations ~~~~~~~~~~~~ From fcfffa5bfd1bc4e773e5b04bb219c27dd027a0de Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 25 Nov 2026 09:39:19 -0700 Subject: [PATCH 5/7] add test for nan in, nan out --- tests/test_modelchain.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_modelchain.py b/tests/test_modelchain.py index 6b443ac0fc..65a926db6b 100644 --- a/tests/test_modelchain.py +++ b/tests/test_modelchain.py @@ -1282,6 +1282,31 @@ def test_singlediode_dc_arrays(location, dc_model, assert isinstance(dc, (pd.Series, pd.DataFrame)) +@pytest.mark.parametrize('dc_model', ['cec']) +def test_singlediode_nan_policy(location, dc_model, + cec_dc_snl_ac_arrays): + times = pd.date_range('20160101 1200-0700', periods=2, freq='6h') + weather = pd.DataFrame({'ghi': [500, np.nan], + 'dni': [800, 0], 'dhi': [100, 0]}, + index=times) + temp_model_params = {'a': -3.40641, 'b': -0.0842075, 'deltaT': 3} + temp_model = 'sapm' + system = cec_dc_snl_ac_arrays + for array in system.arrays: + array.temperature_model_parameters = temp_model_params + mc = ModelChain(system, location, + aoi_model='no_loss', spectral_model='no_loss', + temperature_model=temp_model) + mc.run_model(weather) + assert isinstance(mc.results.dc, tuple) + assert len(mc.results.dc) == system.num_arrays + # check each array + for dc in mc.results.dc: + assert isinstance(dc, (pd.Series, pd.DataFrame)) + # ghi is NaN at 2nd time step, all DC outputs should be NaN + assert (dc.iloc[1, :].isna()).all() + + @pytest.mark.parametrize('temp_model', [ 'sapm_temp', 'faiman_temp', 'pvsyst_temp', 'fuentes_temp', 'noct_sam_temp']) From 12ebfb837900b60d7667095aabc4f54295efaaad Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 25 Nov 2026 09:53:14 -0700 Subject: [PATCH 6/7] extend to AC check and PVWatts --- tests/test_modelchain.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/test_modelchain.py b/tests/test_modelchain.py index 65a926db6b..a12396cdd6 100644 --- a/tests/test_modelchain.py +++ b/tests/test_modelchain.py @@ -1282,16 +1282,18 @@ def test_singlediode_dc_arrays(location, dc_model, assert isinstance(dc, (pd.Series, pd.DataFrame)) -@pytest.mark.parametrize('dc_model', ['cec']) -def test_singlediode_nan_policy(location, dc_model, - cec_dc_snl_ac_arrays): +@pytest.mark.parametrize('case', ['cec_dc', 'pvwatts_ac']) +def test_nan_policy(location, case, cec_dc_snl_ac_arrays, + pvwatts_dc_pvwatts_ac_system_arrays): times = pd.date_range('20160101 1200-0700', periods=2, freq='6h') weather = pd.DataFrame({'ghi': [500, np.nan], 'dni': [800, 0], 'dhi': [100, 0]}, index=times) temp_model_params = {'a': -3.40641, 'b': -0.0842075, 'deltaT': 3} temp_model = 'sapm' - system = cec_dc_snl_ac_arrays + cases = {'cec_dc': cec_dc_snl_ac_arrays, + 'pvwatts_ac': pvwatts_dc_pvwatts_ac_system_arrays} + system = cases[case] for array in system.arrays: array.temperature_model_parameters = temp_model_params mc = ModelChain(system, location, @@ -1302,9 +1304,16 @@ def test_singlediode_nan_policy(location, dc_model, assert len(mc.results.dc) == system.num_arrays # check each array for dc in mc.results.dc: - assert isinstance(dc, (pd.Series, pd.DataFrame)) # ghi is NaN at 2nd time step, all DC outputs should be NaN - assert (dc.iloc[1, :].isna()).all() + if isinstance(dc, pd.DataFrame): + assert (dc.iloc[1, :].isna()).all() + elif isinstance(dc, pd.Series): + assert np.isnan(dc.iloc[1]) + else: + assert False + assert isinstance(mc.results.ac, (pd.Series)) + # ghi is NaN at 2nd time step, AC output should be NaN + assert np.isnan(mc.results.ac.iloc[1]) @pytest.mark.parametrize('temp_model', [ From 7ae2dff38d335737267d967a758a58b8e5eab6f1 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 25 Nov 2026 09:56:10 -0700 Subject: [PATCH 7/7] remove commented lines --- pvlib/modelchain.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index f385192db2..0623efcc37 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -626,7 +626,6 @@ def _make_diode_params(photocurrent, saturation_current, self.results.dc, unwrap=False ) - # self.results.dc = tuple(dc.fillna(0) for dc in self.results.dc) # If the system has one Array, unwrap the single return value # to preserve the original behavior of ModelChain if self.system.num_arrays == 1: @@ -727,7 +726,6 @@ def adr_inverter(self): def pvwatts_inverter(self): self.results.ac = self.system.get_ac('pvwatts', self.results.dc) - # self.results.ac = ac.fillna(0) return self @property