# Calculating Times of Rise, Set, and Culmination

Suppose we want to calculate when a given celestial object rises above the horizon, sets below the horizon, or reaches the highest point above the horizon (*culminates*), as seen by an observer at a given location on the surface of the Earth.

### Azimuth and altitude

Let us consider how this observer can describe the apparent location of the celestial object, say a star, at a specific moment in time using a pair of angles.  Let the *azimuth* $A$ be the angle measured westward from due south along the horizon needed to face the star. Let the *altitude* $h$ be the angle of the star above the horizon. (If the star is below the horizon, $h < 0$.)

We define a pair of co-rotating Cartesian coordinate systems for such an observer, called *horizontal* coordinates and *local equatorial* coordinates.  In both systems we treat the entire sky as a sphere of unit radius centered on the observer.

### Horizontal coordinates

In the horizontal coordinate system we have three directions $x$, $y$, and $z$ such that
- $x$ points due south toward the horizon, 
- $y$ points due west toward the horizon, and
- $z$ points straight up toward the zenith.

Thus it is possible to relate the angles $A$ and $h$ with horizontal Cartesian coordinates $x$, $y$, and $z$ by

\begin{align}
x & = \cos{h} \cos{A} \\
y & = \cos{h} \sin{A} \tag{1} \\
z & = \sin{h}
\end{align}

To understand these equations a little more intuitively, consider a star that is exactly on the horizon and due west. Then $h=0$, which means $\cos{h}=1$ and $\sin{h}=0$.  Also, $A=90^{\circ}$, so $\cos{A}=0$ and $\sin{A}=1$. This results in $x=0$, $y=1$, $z=0$, which is consistent with the above descriptions of the three coordinates. Another example is where $h=90^{\circ}$ and $A$ has any value, resulting in the vertical vector $x=0$, $y=0$, $z=1$.

### Declination and hour angle

Usually in astronomy when you see the phrase "equatorial coordinates," it refers to right ascension $\alpha$ and declination $\delta$. We need those two quantities for this discussion, but they are not the same as local equatorial coordinates.  Here I will refer to right ascension and declination as "celestial equatorial coordinates" to avoid ambiguity.

Like their celestial counterparts, local equatorial coordinates are defined with respect to the plane of the Earth's equator. But being local means they rotate along with the observer, while celestial equatorial coordinates are fixed to the starry background of the celestial sphere.  In other words, an earthbound observer experiences stationary local equatorial coordinates, but sees stars rotating around him. Meanwhile, an observer far out in space sees fixed celestial equatorial coordinates, but sees a rotating Earth.

*Declination* $\delta$ is the angle of a star north ($\delta>0$) or south ($\delta<0$) of the celestial equator. For example, the north celestial pole has $\delta=90^{\circ}$. 

I will describe right ascension later.

*Hour angle* $\tau$ is the angle from the local meridian westward toward a given star. It is measured around a celestial circle having same declination as the star.  It represents the amount of time that has passed since the star last crossed the meridian, or equivalently, since the star culminated (reached its highest point above the horizon).  Hour angle can be measured in degrees (0 to 360) or in sidereal hours (0 to 24). You can divide degrees by 15 to get sidereal hours.

### Local equatorial coordinates

Specifically, local equatorial coordinates are Cartesian coordinates $\hat{x}$, $\hat{y}$, $\hat{z}$ such that

- $\hat{x}$ points to where the celestial equator intersects the meridian,
- $\hat{y}$ points due west toward the horizon, and
- $\hat{z}$ points to the north celestial pole.

Using $\delta$ as the star's declination and $\tau$ as the star's hour angle at a given time, we can write the local equatorial coordinates of the star as

\begin{align}
\hat{x} & = \cos{\delta} \cos{\tau}  \\
\hat{y} & = \cos{\delta} \sin{\tau} \tag{2} \\
\hat{z} & = \sin{\delta} \nonumber
\end{align}

Note that $\tau$ changes with the Earth's rotation but $\delta$ does not. Therefore, for a fixed star, $\hat{x}$ and $\hat{y}$ change with time but $\hat{z}$ remains constant.

### Relating the two local systems

We can write a system of equations that relates these two local rotating coordinate systems. 

First note that the $y$-axis is the same as the $\hat{y}$-axis; they are both aimed at the point on the horizon due west from the observer.

The $\hat{z}$-axis, pointing toward the north celestial pole, has an angle $\phi$ above the due-north point on the horizon, where $\phi$ is the geographic latitude of the observer. (If the observer is in the southern hemisphere, then $\phi$ is negative and the north celestial pole is below the horizon.)  That northernmost point on the horizon is in the $-x$ direction, because $x$ points due south.  Similarly, the $\hat{x}$-axis is rotated by $\phi$ from the vertical $z$-axis.  In general, $x$ and $z$ each depend on both $\hat{x}$ and $\hat{z}$ through a rotation of $\phi$.

We can express horizontal coordinates in terms of local equatorial coordinates as

\begin{align}
x & = \hat{x} \sin{\phi} - \hat{z} \cos{\phi} \\
y & = \hat{y} \tag{3} \\
z & = \hat{x} \cos{\phi} + \hat{z} \sin{\phi}
\end{align}

### Relating (azimuth, altitude) to (hour angle, declination)

Substituting equations (1) and (2) into (3), we can write a new system of equations that relate azimuth, altitude, hour angle, and declination:

\begin{align}
\cos{h} \cos{A} &= \cos{\delta} \cos{\tau} \sin{\phi} - \sin{\delta} \cos{\phi} \\
\cos{h} \sin{A} &= \cos{\delta} \sin{\tau} \tag{4} \\
\sin{h} &= \cos{\delta} \cos{\tau} \cos{\phi} + \sin{\delta} \sin{\phi}
\end{align}

The third equation in (4) is most helpful for finding rise and set times because it eliminates the azimuth as a factor.

### Calculating hour angle for a given star at a given time

To calculate hour angle $\tau$ we need to use

\begin{equation}
\tau = \theta + \frac{\lambda}{15} - \alpha \tag{5}
\end{equation}

where 
- $\theta$ is the current Greenwich Apparent Sidereal Time (GAST) at the moment of observation,
- $\lambda$ is the geographic longitude of the observer east of Greenwich in degrees, and
- $\alpha$ is the right ascension of the star.

Note that $\tau$, $\theta$, and $\alpha$ are all expressed in sidereal hours. We divide $\lambda$ by 15 to convert degrees to hours.

### Determining when the object is highest or lowest in the sky

The object reaches maximum altitude angle $h_1$ when its hour angle $\tau=0$ and its minimum value of $h_2$ when $\tau = 12$ hours. Let's look at the general case where we are trying to find the *event time* when the object reaches an arbitrary hour angle $\tau$:

\begin{align}
\theta + \frac{\lambda}{15} - \alpha & = \tau \\
\theta = \tau + \alpha - \frac{\lambda}{15} \tag{6}
\end{align}

A star's right ascension $\alpha$ is almost constant over time, and we assume the observer's longitude $\lambda$ is fixed.  In practice, $\alpha$ for the Sun, the Moon, or a planet is not constant. The Moon especially will move in right ascension significantly over the course of a few hours. So we will end up needing to numerically iterate to find the exact event time.

The approach I use in the Astronomy library is to determine the GAST at a start search time. This start search time represents a time after which the next event is to be found. This initial guess $\theta_{x}$ of the GAST value will be incorrect by the approximate amount

\begin{align}
\Delta \theta = \left( \tau + \alpha - \frac{\lambda}{15} \right) - \theta_x \tag{7}
\end{align}

On the first iteration, if $\Delta\theta$ is negative, it is corrected by adding 24 sidereal hours to guarantee finding a culmination time after the start search time. On subsequent iterations, the correction may be positive or negative to home in on the correct time.

At this point, it is important to note that sidereal hours are not exactly the same as clock hours.  The Earth rotates with respect to a fixed star once every 23 hours, 56 minutes, and 4.091 seconds, or 86164.091 seconds. This is compared to a mean solar day of 24 hours = 86400 seconds. This gives a ratio of $\rho = 0.99726957$ mean solar days per sidereal day.

After each iteration, we correct by adding $\rho \Delta \theta$ days of terrestrial time and calculating the right ascension $\alpha$ and declination $\delta$ of the object, and GAST, again at the new time. We plug the updated values of $\theta_x$ and $\alpha$ back into (7) to obtain a more accurate estimate. We keep iterating until $\Delta \theta$ is tolerably small (less than 0.1 seconds). This typically takes 4 or 5 iterations.

### Calculating rise and set times

Now that we can determine when an object reaches its highest and lowest altitudes in the sky for a given observer, we know that *if* the object rises or sets, it will be bounded by those two events. At locations close to one of the Earth's poles, an object may stay in the sky for weeks at a time, never setting, or it may stay below the horizon for weeks at a time, never rising. 

Specifically, if the object is at its lowest at time $t_L$ and at its highest at $t_H \approx t_L + 12$ hours, then we can calculate the object's altitudes $h_L$ and $h_H$ at those respective times.  If $h_L \lt 0$ and $h_H \gt 0$, we know the object must have risen at some time $t_R$ such that $t_L \lt t_R \lt t_H$.

8623a62f24e213acf4ab2113f6c244d3718f4782
ipynb
Jupyter Notebook
theory/rise_set_culm.ipynb
matheo/astronomy
3a1d4ea47a0c04d83bd8ede43dc564e956e999fe
MIT
theory/rise_set_culm.ipynb
matheo/astronomy
3a1d4ea47a0c04d83bd8ede43dc564e956e999fe
MIT
theory/rise_set_culm.ipynb
matheo/astronomy
3a1d4ea47a0c04d83bd8ede43dc564e956e999fe
MIT
Qwen/Qwen-72B
1. YES
2. YES