Prayer Times Calculation
Astronomical Functions
Declination

Solar Declination

The solar declination ( δ\delta ) is the angle between the direction of the Sun and the equatorial plane of the Earth. It ranges from -23°27' during the winter solstice to +23°27' during the summer solstice, and is null during the equinoxes.

We calculate the solar declination using the algorithm of the Global Monitoring Laboratory of the US National Oceania and Atmospheric Administration (NOAA) (Source: https://gml.noaa.gov/grad/solcalc/calcdetails.html (opens in a new tab))

Calculation Step by Step

1. Geometric Mean Longitude of the Sun (degrees):

The average position of the Sun along the ecliptic plane as seen from Earth, measured in degrees. This does not take into account perturbations due to the Earth’s elliptical orbit and other factors.

LS=(280.46646+JC×36000.76983+JC2×0.0003032)mod360\textit{LS} = (280.46646^\circ + \textit{JC} \times 36000.76983^\circ + \textit{JC}^2 \times 0.0003032^\circ) \mod 360

Where:

  • JC\textit{JC} is the Julian Century

2. Geometric Mean Anomaly of the Sun (degrees):

A measure of the Sun’s position along its elliptical orbit around the Earth, relative to its position at perihelion (the closest point to the Earth), expressed in degrees.

MA=(357.52911+JC×35999.05029JC2×0.0001537)mod360\textit{MA} = (357.52911^\circ + \textit{JC} \times 35999.05029^\circ - \textit{JC}^2 \times 0.0001537^\circ) \mod 360

3. Eccentricity of Earth’s Orbit:

A dimensionless parameter that describes the deviation of Earth’s orbit from being a perfect circle. The eccentricity determines how elliptical (oval-shaped) the orbit is.

e=0.016708634JC×0.000042037JC2×0.0000001267e = 0.016708634 - \textit{JC} \times 0.000042037 - \textit{JC}^2 \times 0.0000001267

4. Sun’s Equation of Center:

The correction factor applied to the geometric mean longitude of the Sun to account for the elliptical shape of Earth’s orbit. This correction gives the true position of the Sun in its orbit.

C=sin(MA)×(1.914602JC×0.004817JC2×0.000014)+sin(2×MA)×0.019993+sin(3×MA)×0.000289C = \sin(\textit{MA}) \times (1.914602^\circ - \textit{JC} \times 0.004817^\circ - \textit{JC}^2 \times 0.000014^\circ) + \sin(2\times\textit{MA}) \times 0.019993^\circ + \sin(3\times\textit{MA}) \times 0.000289^\circ

5. Sun’s True Longitude (degrees):

The actual position of the Sun along the ecliptic plane, taking into account the equation of center. This is the geometric mean longitude plus the equation of center.

λ=LS+C\lambda = \textit{LS} + C

6. Sun’s True Anomaly (degrees):

The true angular distance of the Sun from its perihelion, measured along the ecliptic plane. It gives the actual position of the Sun in its orbit relative to the closest point to the Earth.

ν=MA+C\nu = \textit{MA} + C

7. Sun’s Radial Vector (Astronomical Units):

The distance from the Earth to the Sun at a given point in time, measured in Astronomical Units (AU). One AU is the average distance between the Earth and the Sun.

R=1.000001018×(1e2)1+e×cos(ν)R = \frac{1.000001018 \times (1 - e^2)}{1 + e \times \cos(\nu)}

8. Sun’s Apparent Longitude (degrees):

The position of the Sun along the ecliptic plane as observed from Earth, corrected for the Earth’s axial tilt (nutation) and the aberration of light. This is the longitude where the Sun appears to be in the sky.

λapp=λ0.005690.00478×sin(125.041934.136×JC)\lambda_{\text{app}} = \lambda - 0.00569^\circ - 0.00478^\circ \times \sin(125.04^\circ - 1934.136^\circ \times \textit{JC})

9. Mean Obliquity of the Ecliptic (degrees):

The average angle between Earth’s equatorial plane and the ecliptic plane (the plane of Earth’s orbit around the Sun). This angle varies slowly over time due to gravitational interactions.

ϵ0=23+(26+21.448JC×(46.815+JC×(0.00059JC×0.001813))60)/60\epsilon_0 = 23 + \left(26 + \frac{21.448 - \textit{JC} \times \left(46.815 + \textit{JC} \times \left(0.00059 - \textit{JC} \times 0.001813\right)\right)}{60}\right) / 60

10. Obliquity Correction (degrees):

The corrected value of the obliquity of the ecliptic, accounting for the long-term variations in Earth’s tilt. This corrected value is used in precise astronomical calculations.

ϵ=ϵ0+0.00256×cos(125.041934.136×JC)\epsilon = \epsilon_0 + 0.00256^\circ \times \cos(125.04^\circ - 1934.136^\circ \times \textit{JC})

11. Sun’s Right Ascension (degrees):

The angular distance of the Sun measured eastward along the celestial equator from the vernal equinox. Right ascension is one of the coordinates used in the equatorial coordinate system, analogous to longitude on Earth.

α=arctan2(cos(ϵ)×sin(λapp),cos(λapp))\alpha = \arctan2(\cos(\epsilon) \times \sin(\lambda_{\text{app}}), \cos(\lambda_{\text{app}}))

12. Sun’s Declination (degrees):

The angle between the rays of the Sun and the plane of the Earth’s equator. This measures how far north or south of the celestial equator the Sun is at a given time.

δ=arcsin(sin(ϵ)×sin(λapp))\delta = \arcsin(\sin(\epsilon) \times \sin(\lambda_{\text{app}}))

Code Implementation

../prayertimes2025//pt_engine/astro_helpers/sun_declination.py

import math
from .julian_date import julian_date
from .julian_century import julian_century
from .earth_parameters import mean_obliquity_of_ecliptic, obliquity_correction, eccentricity_of_earth_orbit
from .sun_parameters import geom_mean_long_sun, geomc_mean_anom_sun, sun_equation_center, sun_true_long, sun_app_long

def _calculate_sun_declination(epsilon: float, lambda_app: float) -> float:
    return math.degrees(math.asin(math.sin(math.radians(epsilon)) * math.sin(math.radians(lambda_app))))

def sun_declination(year:int, month:int, day:int, hours_past_midnight:float=0, utc_offset:float=0) -> float:
    # Julian Date
    j_d = julian_date(year, month, day, hours_past_midnight, utc_offset)
    # Julian Century
    j_c = julian_century(j_d)
    # Geometric Mean Longitude of the Sun
    sun_longit = geom_mean_long_sun(j_c)
    # Geometric Mean Anomaly of the Sun
    mean_anom = geomc_mean_anom_sun(j_c)
    # Eccentricity of Earth's Orbit
    epsilon = eccentricity_of_earth_orbit(j_c)
    # Sun's Equation of Center
    e_o_c = sun_equation_center(j_c, mean_anom)
    # Sun's True Longitude
    lambda_sun = sun_true_long(sun_longit, e_o_c)
    # Sun's Apparent Longitude
    lambda_app = sun_app_long(lambda_sun, j_c)
    # Mean Obliquity of Ecliptic
    epsilon_0 = mean_obliquity_of_ecliptic(j_c)
    # Obliquity Correction
    epsilon = obliquity_correction(epsilon_0, j_c)
    # Sun's Declination
    delta = _calculate_sun_declination(epsilon, lambda_app)
    return delta
  
↗ View in github