From 7ccddd4d8db91d42cc2af5af2e9c69c317ec2753 Mon Sep 17 00:00:00 2001 From: Solarboaters <354059055+Solarboaters@users.noreply.github.com> Date: Wed, 18 Nov 2026 07:50:00 +0000 Subject: [PATCH] Do not infer CIGS spectral coefficients for ambiguous Thin Film modules --- docs/sphinx/source/whatsnew/v0.16.2.rst | 5 +++++ pvlib/pvsystem.py | 10 ++++++++-- tests/test_pvsystem.py | 26 +++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.16.2.rst b/docs/sphinx/source/whatsnew/v0.16.2.rst index 5893d8bf46..df63630352 100644 --- a/docs/sphinx/source/whatsnew/v0.16.2.rst +++ b/docs/sphinx/source/whatsnew/v0.16.2.rst @@ -14,6 +14,10 @@ Deprecations Bug fixes ~~~~~~~~~ +* Stop inferring CIGS coefficients for ambiguous ``Thin Film`` modules in + :py:meth:`pvlib.pvsystem.PVSystem.first_solar_spectral_loss`. These modules + now require an explicit cell technology or user-supplied spectral + coefficients. (: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`) @@ -80,3 +84,4 @@ Contributors * :ghuser:`bfs2021` * :ghuser:`xiajiahang` * Jakub Krasuski (:ghuser:`Blizzeq`) +* :ghuser:`Solarboaters` diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 79d8a58d11..e602d445d6 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -745,6 +745,11 @@ def first_solar_spectral_loss(self, pw, airmass_absolute): - 'Material' - a string describing the cell type, can be read from the Sandia module database. + ``'Thin Film'`` is ambiguous and does not identify a cell type. + For these modules, supply ``first_solar_spectral_coefficients`` or + set ``Technology`` to a known cell type, such as ``'CdTe'`` or + ``'CIGS'``. Otherwise, a ``TypeError`` is raised. + Parameters ---------- pw : array-like @@ -1084,13 +1089,14 @@ def _infer_cell_type(self): Returns ------- - cell_type: str + cell_type: str or None + None if the cell type cannot be inferred. """ _cell_type_dict = {'Multi-c-Si': 'multisi', 'Mono-c-Si': 'monosi', - 'Thin Film': 'cigs', + 'Thin Film': None, 'a-Si/nc': 'asi', 'CIS': 'cigs', 'CIGS': 'cigs', diff --git a/tests/test_pvsystem.py b/tests/test_pvsystem.py index 71a515ab03..07f387209c 100644 --- a/tests/test_pvsystem.py +++ b/tests/test_pvsystem.py @@ -366,6 +366,32 @@ def test_PVSystem_first_solar_spectral_loss(module_parameters, module_type, assert_allclose(out, 1, atol=0.5) +@pytest.mark.parametrize('key', ['Technology', 'Material']) +def test_first_solar_ambiguous_thin_film(key): + system = pvsystem.PVSystem(module_parameters={key: 'Thin Film'}) + assert system.arrays[0]._infer_cell_type() is None + with pytest.raises(TypeError, match='both module_type and coefficients'): + system.first_solar_spectral_loss(3, 3) + + +@pytest.mark.parametrize('technology, module_type', [ + ('CdTe', 'cdte'), ('CIGS', 'cigs'), ('CIS', 'cigs')]) +def test_first_solar_explicit_thin_film_technology(technology, module_type): + system = pvsystem.PVSystem(module_parameters={'Technology': technology}) + expected = spectrum.spectral_factor_firstsolar(3, 3, module_type) + assert_allclose(system.first_solar_spectral_loss(3, 3), expected) + + +def test_first_solar_thin_film_explicit_coefficients(): + coefficients = (0.84, -0.03, -0.008, 0.14, 0.04, -0.002) + system = pvsystem.PVSystem(module_parameters={ + 'Technology': 'Thin Film', + 'first_solar_spectral_coefficients': coefficients}) + expected = spectrum.spectral_factor_firstsolar( + 3, 3, coefficients=coefficients) + assert_allclose(system.first_solar_spectral_loss(3, 3), expected) + + def test_PVSystem_multi_array_first_solar_spectral_loss(): system = pvsystem.PVSystem( arrays=[