diff --git a/docs/sphinx/source/whatsnew/v0.13.1.rst b/docs/sphinx/source/whatsnew/v0.13.1.rst index d83667b302..2029b7596b 100644 --- a/docs/sphinx/source/whatsnew/v0.13.1.rst +++ b/docs/sphinx/source/whatsnew/v0.13.1.rst @@ -6,6 +6,9 @@ v0.13.1 (Anticipated September, 2025) Breaking Changes ~~~~~~~~~~~~~~~~ +* Change refraction for solar elevation angles between 85 and 90 + degrees to be calculated rather than set to 0 in + :py:func:`~pvlib.solarposition.ephemeris`. (:pull:`2524`) Deprecations diff --git a/pvlib/solarposition.py b/pvlib/solarposition.py index 7284191d68..07005c298f 100644 --- a/pvlib/solarposition.py +++ b/pvlib/solarposition.py @@ -828,7 +828,7 @@ def ephemeris(time, latitude, longitude, pressure=101325.0, temperature=12.0): TanEl = pd.Series(np.tan(np.radians(Elevation)), index=time_utc) Refract = pd.Series(0., index=time_utc) - Refract[(Elevation > 5) & (Elevation <= 85)] = ( + Refract[(Elevation > 5) & (Elevation <= 90)] = ( 58.1/TanEl - 0.07/(TanEl**3) + 8.6e-05/(TanEl**5)) Refract[(Elevation > -0.575) & (Elevation <= 5)] = ( diff --git a/tests/test_solarposition.py b/tests/test_solarposition.py index 88093e05f9..5be76ec42c 100644 --- a/tests/test_solarposition.py +++ b/tests/test_solarposition.py @@ -964,3 +964,15 @@ def test_spa_python_numba_physical_dst(expected_solpos, golden): temperature=11, delta_t=67, atmos_refract=0.5667, how='numpy', numthreads=1) + + +def test_ephmeris_refraction_85_90_degrees(): + # Test that refraction is calculated rather than set to zero + # for solar elevatoin angles between 85 and 90 degrees + # PR#2524 + # The below example has a solar elevation angle of 87.9 + result = solarposition.ephemeris( + time=pd.date_range('2020-03-23 12', periods=1, tz='UTC'), + latitude=0, longitude=0) + refraction = (result['apparent_zenith'] - result['zenith']).iloc[0] + assert refraction == -0.0005818446332597205