Skip to content
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
3 changes: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.13.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Comment on lines +9 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this qualifies more like a bugfix rather than a Breaking Change - I don't see how my code would not run after this update.



Deprecations
Expand Down
2 changes: 1 addition & 1 deletion pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)] = (
Expand Down
12 changes: 12 additions & 0 deletions tests/test_solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading