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
7 changes: 6 additions & 1 deletion docs/sphinx/source/whatsnew/v0.16.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ v0.16.2 (Anticipated December, 2026)
Breaking Changes
~~~~~~~~~~~~~~~~


Deprecations
~~~~~~~~~~~~

Expand All @@ -28,6 +27,12 @@ Enhancements
allowing for choosing between ERA5 and ERA5-Land datasets.
(:pull:`2780`)

* Pass ``offset`` directly to ``_calculate_simple_day_angle`` in
:py:func:`pvlib.solarposition.equation_of_time_pvcdrom` and
:py:func:`pvlib.solarposition.declination_cooper69` instead of
adding or subtracting equivalent multiples of 2*pi/365 afterwards.
(:issue:`2902`, :pull:`2911`)

Documentation
~~~~~~~~~~~~~
* Clarified in :py:func:`pvlib.tracking.singleaxis` that the tracker
Expand Down
7 changes: 3 additions & 4 deletions pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,7 @@ def equation_of_time_pvcdrom(dayofyear):
equation_of_time_spencer71
"""
# day angle relative to Vernal Equinox, typically March 22 (day number 81)
bday = \
_calculate_simple_day_angle(dayofyear) - (2.0 * np.pi / 365.0) * 80.0
bday = _calculate_simple_day_angle(dayofyear, offset=81)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is offset=81 and not offset=80 as in the original code?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

_calculate_simple_day_angle(dayofyear, offset=1) is the function signature, this is its implementation:
return (2. * np.pi / 365.) * (dayofyear - offset). Both offsets must be added for mathematical equivalence, I've checked that. I haven't checked against the original source.

# same value but about 2x faster than Spencer (1971)
return 9.87 * np.sin(2.0 * bday) - 7.53 * np.cos(bday) - 1.5 * np.sin(bday)

Expand Down Expand Up @@ -1236,8 +1235,8 @@ def declination_cooper69(dayofyear):
--------
declination_spencer71
"""
day_angle = _calculate_simple_day_angle(dayofyear)
dec = np.deg2rad(23.45 * np.sin(day_angle + (2.0 * np.pi / 365.0) * 285.0))
day_angle = _calculate_simple_day_angle(dayofyear, offset=-284)
dec = np.deg2rad(23.45 * np.sin(day_angle))
return dec


Expand Down
Loading