From c5788ba6bd11115eca2d66daeb938118b6757c5d Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 26 Sep 2024 14:48:15 -0700 Subject: [PATCH 01/15] accept floats in PVSystem.get_irradiance --- pvlib/pvsystem.py | 5 ++++- pvlib/tests/test_pvsystem.py | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 926da5548f..a24e4cf561 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1120,8 +1120,11 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, albedo = self.albedo # not needed for all models, but this is easier - if dni_extra is None: + if dni_extra is None and hasattr(solar_zenith, 'index'): dni_extra = irradiance.get_extra_radiation(solar_zenith.index) + else: + # use the solar constant + dni_extra = 1367 if airmass is None: airmass = atmosphere.get_relative_airmass(solar_zenith) diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index c98c201af4..a0ecd9a0e8 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -1870,7 +1870,6 @@ def test_PVSystem_get_irradiance(solar_pos): irrads['dni'], irrads['ghi'], irrads['dhi']) - expected = pd.DataFrame(data=np.array( [[883.65494055, 745.86141676, 137.79352379, 126.397131, 11.39639279], [0., -0., 0., 0., 0.]]), @@ -1881,6 +1880,23 @@ def test_PVSystem_get_irradiance(solar_pos): assert_frame_equal(irradiance, expected, check_less_precise=2) +def test_PVSystem_get_irradiance_float(): + system = pvsystem.PVSystem(surface_tilt=32, surface_azimuth=135) + irrads = {'dni': 900., 'ghi': 600., 'dhi': 100.} + zenith = 55.366831 + azimuth = 172.320038 + irradiance = system.get_irradiance(zenith, + azimuth, + irrads['dni'], + irrads['ghi'], + irrads['dhi']) + expected = {'poa_global': 884.80903423, 'poa_direct': 745.84258835, + 'poa_diffuse': 138.96644588, 'poa_sky_diffuse': 127.57005309, + 'poa_ground_diffuse': 11.39639279} + for k, v in irradiance.items(): + assert np.isclose(v, expected[k], rtol=1e-6) + + def test_PVSystem_get_irradiance_albedo(solar_pos): system = pvsystem.PVSystem(surface_tilt=32, surface_azimuth=135) irrads = pd.DataFrame({'dni': [900, 0], 'ghi': [600, 0], 'dhi': [100, 0], From 09d8743674c8e2ee27b488c7c868064c7c4ededa Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 26 Sep 2024 14:51:02 -0700 Subject: [PATCH 02/15] add note --- pvlib/pvsystem.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index a24e4cf561..59d4a25902 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -349,6 +349,9 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, If passed as a tuple the length must be the same as the number of Arrays. + If `dni_extra` is omitted and parameters are passed as float, then + ``dni_extra=1367`` is assumed. + Returns ------- poa_irradiance : DataFrame or tuple of DataFrame @@ -1112,6 +1115,11 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Column names are: ``'poa_global', 'poa_direct', 'poa_diffuse', 'poa_sky_diffuse', 'poa_ground_diffuse'``. + Notes + ----- + If `dni_extra` is omitted and parameters are passed as float, then + ``dni_extra=1367`` is assumed. + See also -------- :py:func:`pvlib.irradiance.get_total_irradiance` From 811dcf794f695e731b8d6d0b439929b9c0a41946 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 27 Sep 2024 11:00:59 -0700 Subject: [PATCH 03/15] docstring edits, check for DatetimeIndex --- pvlib/pvsystem.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 59d4a25902..16ae9e0d99 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -323,13 +323,13 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Solar zenith angle. solar_azimuth : float or Series Solar azimuth angle. - dni : float or Series or tuple of float or Series + dni : float or Series or tuple of Series Direct Normal Irradiance. [W/m2] - ghi : float or Series or tuple of float or Series + ghi : float or Series or tuple of Series Global horizontal irradiance. [W/m2] - dhi : float or Series or tuple of float or Series + dhi : float or Series or tuple of Series Diffuse horizontal irradiance. [W/m2] - dni_extra : float, Series or tuple of float or Series, optional + dni_extra : float, Series or tuple of Series, optional Extraterrestrial direct normal irradiance. [W/m2] airmass : float or Series, optional Airmass. [unitless] @@ -344,13 +344,15 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Notes ----- Each of `dni`, `ghi`, and `dni` parameters may be passed as a tuple - to provide different irradiance for each array in the system. If not - passed as a tuple then the same value is used for input to each Array. - If passed as a tuple the length must be the same as the number of - Arrays. + of Series to provide different irradiance for each array in the system. + If passed as a tuple of Series the tuple length must be the same + as the number of Arrays. If not passed as a tuple then the same values + are used for each Array. - If `dni_extra` is omitted and parameters are passed as float, then - ``dni_extra=1367`` is assumed. + Some sky irradiance models require `dni_extra`. For these models, + if `dni_extra` is not provided and ``solar_zenith`` has a + ``DatetimeIndex``, then `dni_extra` is calculated. + Otherwise, ``dni_extra=1367`` is assumed. Returns ------- @@ -1117,8 +1119,10 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Notes ----- - If `dni_extra` is omitted and parameters are passed as float, then - ``dni_extra=1367`` is assumed. + Some sky irradiance models require `dni_extra`. For these models, + if `dni_extra` is not provided and ``solar_zenith`` has a + ``DatetimeIndex``, then `dni_extra` is calculated. + Otherwise, ``dni_extra=1367`` is assumed. See also -------- @@ -1127,8 +1131,9 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, if albedo is None: albedo = self.albedo - # not needed for all models, but this is easier - if dni_extra is None and hasattr(solar_zenith, 'index'): + # dni_extra is not needed for all models, but this is easier + if dni_extra is None and hasattr(solar_zenith, 'index') and \ + isinstance(solar_zenith.index, pd.DatetimeIndex): dni_extra = irradiance.get_extra_radiation(solar_zenith.index) else: # use the solar constant From 19664be0d7cbca4706cc22b78054588afb88c113 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 27 Sep 2024 11:16:58 -0700 Subject: [PATCH 04/15] format and docstring edits --- pvlib/pvsystem.py | 27 ++++++++++++++------------- pvlib/tests/test_pvsystem.py | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 16ae9e0d99..822f9405c9 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -312,7 +312,7 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, dni_extra=None, airmass=None, albedo=None, model='haydavies', **kwargs): """ - Uses the :py:func:`irradiance.get_total_irradiance` function to + Uses :py:func:`pvlib.irradiance.get_total_irradiance` to calculate the plane of array irradiance components on the tilted surfaces defined by each array's ``surface_tilt`` and ``surface_azimuth``. @@ -339,19 +339,20 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Irradiance model. kwargs - Extra parameters passed to :func:`irradiance.get_total_irradiance`. + Extra parameters passed to + :py:func:`pvlib.irradiance.get_total_irradiance`. Notes ----- - Each of `dni`, `ghi`, and `dni` parameters may be passed as a tuple + Each of ``dni``, ``ghi``, and ``dni`` may be passed as a tuple of Series to provide different irradiance for each array in the system. If passed as a tuple of Series the tuple length must be the same as the number of Arrays. If not passed as a tuple then the same values are used for each Array. - Some sky irradiance models require `dni_extra`. For these models, - if `dni_extra` is not provided and ``solar_zenith`` has a - ``DatetimeIndex``, then `dni_extra` is calculated. + Some sky irradiance models require ``dni_extra``. For these models, + if ``dni_extra`` is not provided and ``solar_zenith`` has a + ``DatetimeIndex``, then ``dni_extra`` is calculated. Otherwise, ``dni_extra=1367`` is assumed. Returns @@ -362,7 +363,7 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, See also -------- - pvlib.irradiance.get_total_irradiance + :py:func:`pvlib.irradiance.get_total_irradiance` """ dni = self._validate_per_array(dni, system_wide=True) ghi = self._validate_per_array(ghi, system_wide=True) @@ -1082,7 +1083,7 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, """ Get plane of array irradiance components. - Uses the :py:func:`pvlib.irradiance.get_total_irradiance` function to + Uses :py:func:`pvlib.irradiance.get_total_irradiance` to calculate the plane of array irradiance components for a surface defined by ``self.surface_tilt`` and ``self.surface_azimuth``. @@ -1119,9 +1120,9 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Notes ----- - Some sky irradiance models require `dni_extra`. For these models, - if `dni_extra` is not provided and ``solar_zenith`` has a - ``DatetimeIndex``, then `dni_extra` is calculated. + Some sky irradiance models require ``dni_extra``. For these models, + if ``dni_extra`` is not provided and ``solar_zenith`` has a + ``DatetimeIndex``, then ``dni_extra`` is calculated. Otherwise, ``dni_extra=1367`` is assumed. See also @@ -1132,8 +1133,8 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, albedo = self.albedo # dni_extra is not needed for all models, but this is easier - if dni_extra is None and hasattr(solar_zenith, 'index') and \ - isinstance(solar_zenith.index, pd.DatetimeIndex): + if (dni_extra is None and hasattr(solar_zenith, 'index') and + isinstance(solar_zenith.index, pd.DatetimeIndex)): dni_extra = irradiance.get_extra_radiation(solar_zenith.index) else: # use the solar constant diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index a0ecd9a0e8..fd482c5127 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -1896,7 +1896,7 @@ def test_PVSystem_get_irradiance_float(): for k, v in irradiance.items(): assert np.isclose(v, expected[k], rtol=1e-6) - + def test_PVSystem_get_irradiance_albedo(solar_pos): system = pvsystem.PVSystem(surface_tilt=32, surface_azimuth=135) irrads = pd.DataFrame({'dni': [900, 0], 'ghi': [600, 0], 'dhi': [100, 0], From da0b3e656c6e9d7a291f0cafb75c9b7e9c98bb42 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 27 Sep 2024 11:23:22 -0700 Subject: [PATCH 05/15] pacify linter --- pvlib/pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 822f9405c9..7b548f2b5f 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1135,7 +1135,7 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, # dni_extra is not needed for all models, but this is easier if (dni_extra is None and hasattr(solar_zenith, 'index') and isinstance(solar_zenith.index, pd.DatetimeIndex)): - dni_extra = irradiance.get_extra_radiation(solar_zenith.index) + dni_extra = irradiance.get_extra_radiation(solar_zenith.index) else: # use the solar constant dni_extra = 1367 From 9c06acddd737d423c4716fdc29984445c2c4cf32 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 27 Sep 2024 11:34:11 -0700 Subject: [PATCH 06/15] play nice now --- pvlib/pvsystem.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 7b548f2b5f..640f4f4b05 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1133,9 +1133,9 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, albedo = self.albedo # dni_extra is not needed for all models, but this is easier - if (dni_extra is None and hasattr(solar_zenith, 'index') and - isinstance(solar_zenith.index, pd.DatetimeIndex)): - dni_extra = irradiance.get_extra_radiation(solar_zenith.index) + if (dni_extra is None and hasattr(solar_zenith, 'index') + and isinstance(solar_zenith.index, pd.DatetimeIndex)): + dni_extra = irradiance.get_extra_radiation(solar_zenith.index) else: # use the solar constant dni_extra = 1367 From f15a289de5c7d6f23323a03bc5c20a752e464774 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 27 Sep 2024 12:05:39 -0700 Subject: [PATCH 07/15] whatsnew --- docs/sphinx/source/whatsnew/v0.11.2.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.11.2.rst b/docs/sphinx/source/whatsnew/v0.11.2.rst index 9d7129d50d..3c31c5d247 100644 --- a/docs/sphinx/source/whatsnew/v0.11.2.rst +++ b/docs/sphinx/source/whatsnew/v0.11.2.rst @@ -11,11 +11,18 @@ Deprecations Enhancements ~~~~~~~~~~~~ +Bug Fixes +~~~~~~~~~ +* :py:meth:`~pvlib.pvsystem.PVSystem.get_irradiance` accepts float inputs. + (:issue:`1338`, :pull:`2227`) Documentation ~~~~~~~~~~~~~ * Edited docstrings for :py:func:`~pvlib.pvsystem.dc_ohms_from_percent` and :py:func:`~pvlib.pvsystem.dc_ohmic_loss` for clarity. (:issue:`1601`, :pull:`2229`) +* Clarified that :py:meth:`~pvlib.pvsystem.PVSystem.get_irradiance` and + :py:meth:`~pvlib.pvsystem.Array.get_irradiance` do not accept tuple of float + as input. (:pull:`2227`) Testing From 745ba8112e1214122ba4f8524f102f6d8ad5467c Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Tue, 29 Oct 2024 15:11:26 -0700 Subject: [PATCH 08/15] edit docstring --- pvlib/pvsystem.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 6b116da89f..39f2234182 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -323,11 +323,11 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Solar zenith angle. solar_azimuth : float or Series Solar azimuth angle. - dni : float or Series or tuple of Series + dni : float, Series, or tuple of Series Direct Normal Irradiance. [W/m2] - ghi : float or Series or tuple of Series + ghi : float, Series, or tuple of Series Global horizontal irradiance. [W/m2] - dhi : float or Series or tuple of Series + dhi : float, Series, or tuple of Series Diffuse horizontal irradiance. [W/m2] dni_extra : float, Series or tuple of Series, optional Extraterrestrial direct normal irradiance. [W/m2] @@ -344,11 +344,12 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Notes ----- - Each of ``dni``, ``ghi``, and ``dni`` may be passed as a tuple - of Series to provide different irradiance for each array in the system. - If passed as a tuple of Series the tuple length must be the same - as the number of Arrays. If not passed as a tuple then the same values - are used for each Array. + Each of ``dni``, ``ghi``, and ``dni`` may be passed as a float, Series, + or tuple of Series. If passed as a float or Series, these values are + used for each Array. If passed as a tuple of Series the tuple length + must be the same as the number of Arrays. The first tuple element is + used for the first Array, the second tuple element for the second + Array, and so forth. Some sky irradiance models require ``dni_extra``. For these models, if ``dni_extra`` is not provided and ``solar_zenith`` has a From 1976d8137fe176182e9b91bfacc411ce5dba50c9 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 31 Oct 2024 08:50:44 -0700 Subject: [PATCH 09/15] review --- docs/sphinx/source/whatsnew/v0.11.2.rst | 8 ++++---- pvlib/pvsystem.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.11.2.rst b/docs/sphinx/source/whatsnew/v0.11.2.rst index b16f0f5e43..8cc2165625 100644 --- a/docs/sphinx/source/whatsnew/v0.11.2.rst +++ b/docs/sphinx/source/whatsnew/v0.11.2.rst @@ -24,10 +24,10 @@ Bug fixes Documentation ~~~~~~~~~~~~~ * Edited docstrings for :py:func:`~pvlib.pvsystem.dc_ohms_from_percent` and - :py:func:`~pvlib.pvsystem.dc_ohmic_loss` for clarity. (:issue:`1601`, :pull:`2229`) -* Clarified that :py:meth:`~pvlib.pvsystem.PVSystem.get_irradiance` and - :py:meth:`~pvlib.pvsystem.Array.get_irradiance` do not accept tuple of float - as input. (:pull:`2227`) + :py:func:`~pvlib.pvsystem.dc_ohmic_losses` for clarity. (:issue:`1601`, :pull:`2229`) +* Corrected a bug in :py:meth:`~pvlib.pvsystem.PVSystem.get_irradiance` and + :py:meth:`~pvlib.pvsystem.Array.get_irradiance` when `solar_zenith` is passed + float as input. (:issue:`1338`, :pull:`2227`) * Added a new citation style guide (:ref:`references`) to the contributing page. (:issue:`2202`, :pull:`2226`) * Updated :py:func:`~pvlib.irradiance.reindl` to include definitions of terms diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 39f2234182..e4125b99fa 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -323,13 +323,13 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Solar zenith angle. solar_azimuth : float or Series Solar azimuth angle. - dni : float, Series, or tuple of Series + dni : float, Series, or tuple of float or Series Direct Normal Irradiance. [W/m2] - ghi : float, Series, or tuple of Series + ghi : float, Series, or tuple of float or Series Global horizontal irradiance. [W/m2] - dhi : float, Series, or tuple of Series + dhi : float, Series, or tuple of float or Series Diffuse horizontal irradiance. [W/m2] - dni_extra : float, Series or tuple of Series, optional + dni_extra : float, Series or tuple of float or Series, optional Extraterrestrial direct normal irradiance. [W/m2] airmass : float or Series, optional Airmass. [unitless] @@ -364,7 +364,7 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, See also -------- - :py:func:`pvlib.irradiance.get_total_irradiance` + pvlib.irradiance.get_total_irradiance """ dni = self._validate_per_array(dni, system_wide=True) ghi = self._validate_per_array(ghi, system_wide=True) From 9b86d3abf160fa51d0d661fd01aa143daa6aeff4 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 31 Oct 2024 09:02:32 -0700 Subject: [PATCH 10/15] Update docs/sphinx/source/whatsnew/v0.11.2.rst --- docs/sphinx/source/whatsnew/v0.11.2.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.11.2.rst b/docs/sphinx/source/whatsnew/v0.11.2.rst index 8cc2165625..601315fc33 100644 --- a/docs/sphinx/source/whatsnew/v0.11.2.rst +++ b/docs/sphinx/source/whatsnew/v0.11.2.rst @@ -25,9 +25,6 @@ Documentation ~~~~~~~~~~~~~ * Edited docstrings for :py:func:`~pvlib.pvsystem.dc_ohms_from_percent` and :py:func:`~pvlib.pvsystem.dc_ohmic_losses` for clarity. (:issue:`1601`, :pull:`2229`) -* Corrected a bug in :py:meth:`~pvlib.pvsystem.PVSystem.get_irradiance` and - :py:meth:`~pvlib.pvsystem.Array.get_irradiance` when `solar_zenith` is passed - float as input. (:issue:`1338`, :pull:`2227`) * Added a new citation style guide (:ref:`references`) to the contributing page. (:issue:`2202`, :pull:`2226`) * Updated :py:func:`~pvlib.irradiance.reindl` to include definitions of terms From 9103a36a7d4a233c38a9eb5b31f0994051944773 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 31 Oct 2024 09:04:55 -0700 Subject: [PATCH 11/15] true up docstring --- pvlib/pvsystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index e4125b99fa..637701c65d 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -345,8 +345,8 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, Notes ----- Each of ``dni``, ``ghi``, and ``dni`` may be passed as a float, Series, - or tuple of Series. If passed as a float or Series, these values are - used for each Array. If passed as a tuple of Series the tuple length + or tuple of float or Series. If passed as a float or Series, these + values are used for all Arrays. If passed as a tuple, the tuple length must be the same as the number of Arrays. The first tuple element is used for the first Array, the second tuple element for the second Array, and so forth. From 6e794cdf55ba013d4b5863e06882e457e614c31d Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 31 Oct 2024 15:01:51 -0700 Subject: [PATCH 12/15] Update pvlib/pvsystem.py Co-authored-by: Kevin Anderson --- pvlib/pvsystem.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 637701c65d..cccabf0024 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1134,12 +1134,13 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, albedo = self.albedo # dni_extra is not needed for all models, but this is easier - if (dni_extra is None and hasattr(solar_zenith, 'index') - and isinstance(solar_zenith.index, pd.DatetimeIndex)): - dni_extra = irradiance.get_extra_radiation(solar_zenith.index) - else: - # use the solar constant - dni_extra = 1367 + if dni_extra is None: + if (hasattr(solar_zenith, 'index') and + isinstance(solar_zenith.index, pd.DatetimeIndex)): + dni_extra = irradiance.get_extra_radiation(solar_zenith.index) + else: + # use the solar constant + dni_extra = 1367 if airmass is None: airmass = atmosphere.get_relative_airmass(solar_zenith) From de82003bce57170ed258ea3500bf21be0f135269 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 31 Oct 2024 15:03:13 -0700 Subject: [PATCH 13/15] float not int --- pvlib/pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index cccabf0024..9db3827a57 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1140,7 +1140,7 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, dni_extra = irradiance.get_extra_radiation(solar_zenith.index) else: # use the solar constant - dni_extra = 1367 + dni_extra = 1367.0 if airmass is None: airmass = atmosphere.get_relative_airmass(solar_zenith) From 610ad96e83d7b0d1f7b7672a6ad02081ab269b1f Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 31 Oct 2024 15:19:16 -0700 Subject: [PATCH 14/15] tab --- pvlib/pvsystem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 9db3827a57..84fe59bdae 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1137,7 +1137,8 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, if dni_extra is None: if (hasattr(solar_zenith, 'index') and isinstance(solar_zenith.index, pd.DatetimeIndex)): - dni_extra = irradiance.get_extra_radiation(solar_zenith.index) + dni_extra = irradiance.get_extra_radiation( + solar_zenith.index) else: # use the solar constant dni_extra = 1367.0 From e3e47a42f794f6a4ee9241024ac733fcc5cbe4c6 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Thu, 31 Oct 2024 15:41:27 -0700 Subject: [PATCH 15/15] pacify the linter --- pvlib/pvsystem.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 84fe59bdae..76872248a4 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1136,9 +1136,10 @@ def get_irradiance(self, solar_zenith, solar_azimuth, dni, ghi, dhi, # dni_extra is not needed for all models, but this is easier if dni_extra is None: if (hasattr(solar_zenith, 'index') and - isinstance(solar_zenith.index, pd.DatetimeIndex)): - dni_extra = irradiance.get_extra_radiation( - solar_zenith.index) + isinstance(solar_zenith.index, pd.DatetimeIndex)): + # calculate extraterrestrial irradiance + dni_extra = irradiance.get_extra_radiation( + solar_zenith.index) else: # use the solar constant dni_extra = 1367.0