From b8e6d83168944c7753b273a5300500473ed6e69d Mon Sep 17 00:00:00 2001 From: ChenYi-Nnergy Date: Mon, 9 Nov 2026 10:56:22 +0800 Subject: [PATCH 1/3] Add files via upload --- pvlib/pvsystem.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 79d8a58d11..e96842c6f2 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -745,6 +745,12 @@ def first_solar_spectral_loss(self, pw, airmass_absolute): - 'Material' - a string describing the cell type, can be read from the Sandia module database. + A CEC ``Technology`` of ``'Thin Film'`` is not inferred: it is + ambiguous (it may be CdTe, CIGS, or another thin-film type), so + ``first_solar_spectral_loss`` raises a ``ValueError`` unless + user-supplied coefficients are provided or the ``Technology`` is + corrected to the actual cell type (e.g. ``'CdTe'``). + Parameters ---------- pw : array-like @@ -771,6 +777,18 @@ def _spectral_correction(array, pw): 'first_solar_spectral_coefficients' ] module_type = None + elif array.module_parameters.get('Technology') == 'Thin Film': + # GH 1984: 'Thin Film' is ambiguous -- it may be CdTe, + # CIGS, or another thin-film type -- so do not infer + # coefficients from it. The user must specify the actual + # cell type or supply coefficients explicitly. + raise ValueError( + 'Cannot infer First Solar spectral coefficients for ' + 'a module with CEC Technology "Thin Film": the ' + 'technology is ambiguous. Set ' + 'module_parameters["Technology"] to the actual cell ' + 'type (e.g. "CdTe" for First Solar modules) or supply ' + '"first_solar_spectral_coefficients" explicitly.') else: module_type = array._infer_cell_type() coefficients = None From 727145f00f49670f3b750e2044136e76945547e5 Mon Sep 17 00:00:00 2001 From: ChenYi-Nnergy Date: Mon, 9 Nov 2026 10:57:18 +0800 Subject: [PATCH 2/3] Add files via upload --- tests/test_pvsystem.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/test_pvsystem.py b/tests/test_pvsystem.py index 71a515ab03..d4776a23f0 100644 --- a/tests/test_pvsystem.py +++ b/tests/test_pvsystem.py @@ -366,6 +366,35 @@ def test_PVSystem_first_solar_spectral_loss(module_parameters, module_type, assert_allclose(out, 1, atol=0.5) +def test_PVSystem_first_solar_spectral_loss_thin_film(): + # GH 1984: a CEC Technology of 'Thin Film' is ambiguous (it may be + # CdTe, CIGS, or another thin-film type), so coefficients must not + # be inferred from it. + module_parameters = {'Technology': 'Thin Film'} + system = pvsystem.PVSystem(module_parameters=module_parameters) + with pytest.raises(ValueError, match='Thin Film'): + system.first_solar_spectral_loss(3, 3) + + # the two remedies keep working: correct the Technology, or supply + # coefficients explicitly + module_parameters_cdte = {'Technology': 'CdTe'} + system = pvsystem.PVSystem(module_parameters=module_parameters_cdte) + out_cdte = system.first_solar_spectral_loss(3, 3) + assert_allclose(out_cdte, + spectrum.spectral_factor_firstsolar(3, 3, 'cdte')) + + module_parameters_coeffs = { + 'Technology': 'Thin Film', + 'first_solar_spectral_coefficients': ( + 0.84, -0.03, -0.008, 0.14, 0.04, -0.002)} + system = pvsystem.PVSystem(module_parameters=module_parameters_coeffs) + out_coeffs = system.first_solar_spectral_loss(3, 3) + assert_allclose(out_coeffs, + spectrum.spectral_factor_firstsolar( + 3, 3, coefficients=(0.84, -0.03, -0.008, 0.14, + 0.04, -0.002))) + + def test_PVSystem_multi_array_first_solar_spectral_loss(): system = pvsystem.PVSystem( arrays=[ From 3bd4ae67b2eef8423f355e818e8c57a86f44a554 Mon Sep 17 00:00:00 2001 From: ChenYi-Nnergy Date: Mon, 9 Nov 2026 10:58:24 +0800 Subject: [PATCH 3/3] Add files via upload --- docs/sphinx/source/whatsnew/v0.16.2.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.16.2.rst b/docs/sphinx/source/whatsnew/v0.16.2.rst index 5893d8bf46..2e74d453cb 100644 --- a/docs/sphinx/source/whatsnew/v0.16.2.rst +++ b/docs/sphinx/source/whatsnew/v0.16.2.rst @@ -14,6 +14,12 @@ Deprecations Bug fixes ~~~~~~~~~ +* :py:meth:`pvlib.pvsystem.PVSystem.first_solar_spectral_loss` no longer + infers spectral coefficients for modules whose CEC ``Technology`` is + ``"Thin Film"``: the technology is ambiguous (it may be CdTe, CIGS, or + another thin-film type), so it now raises a ``ValueError`` directing the + user to set the actual cell type or supply + ``first_solar_spectral_coefficients`` explicitly. (:issue:`1984`) * Correct the Series name in ``ModelChain.results.dc_ohmic_losses`` from ``i_mp`` to ``p_dc_ohmic_loss`` when using ``dc_ohms_from_percent``. (:issue:`1959`, :pull:`2912`)