1
$\begingroup$

If I observe the sun and measure the local azimuth and elevation, and I also have my latitude, can I calculate the local sunrise and local sunset times? If so, how would I calculate it?

Further, can the same calculations be used for the moonrise and moonset?

$\endgroup$
4
  • $\begingroup$ Please clarify: at what clock time are you measuring Az and El? Would you have a reference table of, say, azimuth vs. latitude vs. day of year? $\endgroup$ May 9, 2017 at 12:34
  • $\begingroup$ It could be at any clock time. I think I've seen some calculations based on noon. A table would work, however it would be a pretty big look up table in order to account for different latitudes and spanning through each day in a century. This is why I'd like to try to calculate it instead of simply looking it up. $\endgroup$
    – jlaverde
    May 9, 2017 at 18:18
  • $\begingroup$ I'm going to look into this, but I think you'd need some combination of the time (or sidereal time) and your longitude to determine the Sun's RA. Are you willing to live with the approximation that the Sun's RA/DEC is nearly fixed over a given day? $\endgroup$
    – user21
    May 11, 2017 at 17:31
  • $\begingroup$ @barrycarter yeah that sounds good. I know it should vary by a few seconds, right? Approximation to the nearest minute would be great. Thanks for your help! $\endgroup$
    – jlaverde
    May 12, 2017 at 3:30

1 Answer 1

5
$\begingroup$

$ \cos ^{-1}\left(-\frac{\tan (\lambda ) (\cos (\lambda ) \cos (\phi ) \cos (Z)+\sin (\lambda ) \sin (Z))}{\sqrt{(\cos (\lambda ) \sin (Z)-\sin (\lambda) \cos (\phi ) \cos (Z))^2+\sin ^2(\phi ) \cos ^2(Z)}}\right)-\tan^{-1} (\cos (\lambda ) \sin (Z)-\sin (\lambda ) \cos (\phi ) \cos (Z),\sin (\phi ) (-\cos (Z))) $

is the amount of time from now (see important notes below) a celestial object will set, where:

  • $\phi$ is the azimuth of the object
  • $Z$ is the altitude of the object above the horizon
  • $\lambda$ is the latitude of the observer

Note the two-argument form of arctangent is required for accuracy: https://en.wikipedia.org/wiki/Inverse_trigonometric_functions#Two-argument_variant_of_arctangent

Important notes (MUST READ!):

  • The result is in radians. To convert to sidereal hours, multiple by $\frac{12}{\pi }$

  • If the object has a fixed right ascension and declination, divide sidereal hours by 1.002737909350795 to get clock hours.

  • For the Sun (which doesn't have fixed right ascension/declination), do NOT divide as above. By not dividing, you compensate for the Sun's change in right ascension.

  • For the Moon, see "The Moon" section below.

  • The time computed above is for geometric midpoint setting. In reality, refraction near the horizon means the object will set later. Additionally, for objects that have an angular diameter (eg, the Sun), setting usually means when the top edge disappears over the horizon, which will make the set time even later. Accounting for both effects should be possible, but might require numerical methods instead of a closed form formula as above.

  • If the quantity inside the arccosine is greater than 1, the object is always in the sky and never sets or rises.

  • If the quantity inside the arccosine is less than -1, the object is never in the sky and thus also never sets or rises.

  • I did only minimal testing. As always, do not rely on my answers for anything important.

The Moon:

  • The Moon's right ascension and declination change rapidly, so this calculation does not work well for the moon.

  • You could compensate for the change in right ascension (and thus hour angle) by approximating the increase as 24 hours every 27.32158 days (its sidereal period) and do an iterative calculation.

  • An even better compensation for the change in right ascension would be to approximate the moon's movement in ecliptic longitude (which is more constant than its movement its right ascension) as 360 degrees per 27.32158 days and then project the ecliptic longitude back to right ascension, and then iterate.

  • Compensating for the moon's change in declination is more difficult. The moon's ecliptic latitude (which can be converted to declination) varies sinusoidally, but the equation $\sin (x)=a$ normally has two solutions. Unless you know whether the moon's ecliptic latitude is increasing or decreasing (ie, whether it's between ascending and descending nodes or vice versa), you won't know the direction of declination change.

Less important notes (optional):

Solution notes:

I learned quite a bit answering this question, and thought it was only solvable numerically until I figured out the shortcut:

  • To convert from the azimuth/elevation sphere to the hour angle/declination sphere, you just rotate around the y axis by $\frac{\pi }{2}-\lambda$ (90 degrees minus the latitude) and then rotate $pi$ (180 degrees) around the z axis.

  • Once you have the declination, computing the hour angle when an object sets is easy.

  • You then subtract the setting time from the current hour angle to get the answer.

TODO: I was hoping to add some graphs/visualizations to this answer but couldn't quite get things working.

$\endgroup$
8
  • $\begingroup$ This is an amazing answer. Thanks for taking the time to do this. I almost marked it as the answer. Only problem is that I can't seem to get it working. I put it on an Excel file with some known values, but I get errors. It seems that I'm getting answers > 1 or < -1 for the arccos part. Could you check it this is correct, whenever you have the time? $\endgroup$
    – jlaverde
    May 24, 2017 at 0:52
  • $\begingroup$ You're saying the part under the arccosine is ALWAYS > 1 or < -1? Could you give me some sample values that fail? Make sure you're using the right unit (degrees or radians) consistently. $\endgroup$
    – user21
    May 24, 2017 at 4:31
  • $\begingroup$ Sure. I'm not 100% sure if I'm using the correct forms, but using the NOAA site, if I put in May 25, 2017 at Noon, it gives me an azimuth and elevation of 78.00471, and 196.0226 respectively at a latitude of 32.6716. However, this is giving me an error using your calculations. The top part of the arccos is giving me 2.4994 and the bottom 0.5797. The arccos part gives me an error, I believe because it is out of bounds. $\endgroup$
    – jlaverde
    May 25, 2017 at 16:15
  • $\begingroup$ OK, I will try to work that example "soon", but, if it's not private, could you post the spreadsheet and maybe I can fix or look? I did some verification by Mathematica, but it's possible I messed up. $\endgroup$
    – user21
    May 26, 2017 at 13:25
  • $\begingroup$ of course! no problem. I'm going to see if I could figure out how to post something here. If not, I'll put it on dropbox or something. $\endgroup$
    – jlaverde
    May 26, 2017 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .