Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise helpful exceptions for irradiance.gti_dirint #2347

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,9 @@ def gti_dirint(poa_global, aoi, solar_zenith, solar_azimuth, times,
irradiance, Solar Energy 122, 1037-1046.
:doi:`10.1016/j.solener.2015.10.024`
"""
# check input data and raise Exceptions where data will cause the
# algorithm to fail
_gti_dirint_check_input(aoi)

aoi_lt_90 = aoi < 90

Expand Down Expand Up @@ -2399,6 +2402,17 @@ def gti_dirint(poa_global, aoi, solar_zenith, solar_azimuth, times,
return output


def _gti_dirint_check_input(aoi):
r"""
Helper for gti_dirint

Raises Exceptions from input data that cause the algorithm to fail.
"""
if (aoi >= 90).all():
raise ValueError("AOI >= 90 for all input data to gti_dirint. "
"gti_dirint requires some data with AOI < 90.")


def _gti_dirint_lt_90(poa_global, aoi, aoi_lt_90, solar_zenith, solar_azimuth,
times, surface_tilt, surface_azimuth, pressure=101325.,
use_delta_kt_prime=True, temp_dew=None, albedo=.25,
Expand Down
17 changes: 17 additions & 0 deletions pvlib/tests/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,23 @@ def test_gti_dirint():
assert_frame_equal(output, expected)


def test_gti_dirint_data_error():
times = pd.DatetimeIndex(
['2014-06-24T06-0700', '2014-06-24T09-0700', '2014-06-24T12-0700'])
poa_global = np.array([20, 300, 1000])
zenith = np.array([80, 45, 20])
azimuth = np.array([90, 135, 180])
surface_tilt = 30
surface_azimuth = 180

aoi = np.array([100, 170, 110])
with pytest.raises(
ValueError, match="AOI >= 90 for all input data to gti_dirint"):
irradiance.gti_dirint(
poa_global, aoi, zenith, azimuth, times, surface_tilt,
surface_azimuth)


def test_erbs():
index = pd.DatetimeIndex(['20190101']*3 + ['20190620'])
ghi = pd.Series([0, 50, 1000, 1000], index=index)
Expand Down
Loading