New! Enter your latitude and longitude.

Latitude Longitude
°N °W
Today's sunrise/sunset calculation for 39.040759 °N, 77.04876 °W.

Note: I am not using the appropriate number of significant figures to calculate sunrise, sunset, and solar noon. While it may appear that my calculations are accurate to one second, they actually have a precision of closer to 3 minutes (mostly due to approximation). Also, this calculation does not take into account the effect of air temperature, altitude, etc. Together, these may affect the time by 5 minutes or more.

Find today's Julian date (days since Jan 1, 2000 + 2451545):

Julian date: 2458044

Now, calculate Jtransit at longitude 77.04876, start with n:

n* = (Jdate - 2451545 - 0.0009) - (lw/360)
n = round(n*)

n* = (2458044 - 2451545 - 0.0009) - (77.04876/360) = 6498.7850756667
n = round(6498.7850756667) = 6499

Now J*:

J* = 2451545 + 0.0009 + (lw/360) + n

J* = 2451545 + 0.0009 + (77.04876/360) + 6499 = 2458044.2149243

Using J*, calculate M (mean anomaly) and then use that to calculate C and λ:

M = [357.5291 + 0.98560028 * (J* - 2451545)] mod 360

M = [357.5291 + 0.98560028 * (2458044.2149243 - 2451545)] mod 360 = 6763.1571492029 mod 360 = 283.15714920293

We need to calculate the equation of center, C:

C = (1.9148 * sin(M)) + (0.0200 * sin(2 * M)) + (0.0003 * sin(3 * M))

C = 1.9148 * sin(283.15714920293) + 0.0200 * sin(2 * 283.15714920293) + 0.0003 * sin(3 * 283.15714920293) = -1.8731696883726

We need λ which is the ecliptical longitude of the sun:

λ = (M + 102.9372 + C + 180) mod 360

λ = (283.15714920293 + 102.9372 + -1.8731696883726 + 180) mod 360 = 564.22117951456 mod 360 = 204.22117951456

Finally, calculate Jtransit:

Jtransit = J* + (0.0053 * sin(M)) - (0.0069 * sin(2 * λ))

Jtransit = 2458044.2149243 + (0.0053 * sin(283.15714920293)) - (0.0069 * sin(2 * 204.22117951456)) = 2458044.2046003

Now, to get an even more accurate number, recursively recalculate M using Jtransit until it stops changing. Notice how close the approximation was.

I1: M = 283.14697380239, C = -1.8732405939779, λ = 204.21093320841, Jtransit = 2458044.2046017
I2: M = 283.14697520542, C = -1.8732405842052, λ = 204.21093462121, Jtransit = 2458044.2046017
I3: M = 283.14697520496, C = -1.8732405842084, λ = 204.21093462075, Jtransit = 2458044.2046017
I4: M = 283.14697520496, C = -1.8732405842084, λ = 204.21093462075, Jtransit = 2458044.2046017

Ok, translate this into something we understand. i.e. When is Solar Noon?

Jtransit = 2458044.2046017 = 10/17/2017 at 12:54:37 -0500

Alrighty, now calculate how long the sun is in the sky at latitude 39.040759:

Now we need to calculate δ which is the declination of the sun:

δ = arcsin( sin(λ) * sin(23.45) )

δ = arcsin(sin(204.21093462075) * sin(23.45)) = -9.3925441843651

Now we can go about calculating H (Hour angle):

H = arccos( [sin(-0.83) - sin(ln) * sin(δ)] / [cos(ln) * cos(δ)] )

H = arccos((sin(-0.83) - sin(39.040759) * sin(-9.3925441843651))/(cos(39.040759) * cos(-9.3925441843651))) = 83.382431926349

Just as above, calculate J*, but this time using hour-angle:

J** = 2451545 + 0.0009 + ((H + lw)/360) + n

J** = 2451545 + 0.0009 + ((83.382431926349 + 77.04876)/360) + 6499 = 2458044.4465422

We can use M from above because it really doesn't change that much over the course of a day, calculate Jset in the same way:

Jset = J** + (0.0053 * sin(M)) - (0.0069 * sin(2 * λ))

Jset = 2458044.4465422 + (0.0053 * sin(283.14697520496)) - (0.0069 * sin(2 * 204.21093462075)) = 2458044.4362196

Now I'm going to cheat and calculate Jrise:

Jrise = Jtransit - (Jset - Jtransit)

Jrise = 2458044.2046017 - (2458044.4362196 - 2458044.2046017) = 2458043.9729838

Using the same idea, figure out when sunrise and sunset are:

Jrise = 2458043.9729838 = 10/17/2017 at 07:21:05 -0500
Jset = 2458044.4362196 = 10/17/2017 at 18:28:09 -0500

A couple anomalies occur. At high latitudes, you will sometimes get H = 0. This means that either the sun does not rise (in the winter) or the sun does not set (in the summer) on that day.


Copyright ©1997 - 2011, Bulent Yilmaz