Ever been stuck in an office where you couldn't see outside? Or wanted to know if the sun was up somewhere else on the globe? You might find this little page useful.
While working at AFGWC on a radiation package in the '80s for a climate / weather forecast model, I wanted something that could give me the angle of the sun from a grid point on the planet. This algorithm is the result.
It's not terribly fast, but the original was extremely accurate for the 50 years' worth of astronomical data I could find. The requirement wasn't for accuracy, but speed. Oh, well. Over the decades I lost the code and any notes I'd made, and this is the recreation from memory.
The dot-product of two normalized vectors in cartesian space is the cosine of the angle of separation (see the box below). The apparent latitude of the sun doesn't change much over the course of a day so I use an approximation. I simply did the dot-product and solved for the unknown: the longitude of the sun. This is all observer-centric (no offset from the center of the planet - though I think the original used a translation of coordinates).
The two constants I calculated for the two waves for the Equation Of Time are from memory. The only part I vaguely remembered was the math.
The yellow dot is the position where the sun is directly overhead (or within a half of a degree). The blue and yellow circles are where the sun is at 30° and 60° from the vertical (take note if your skin is sensitive to harsh sunlight).
The three stripes show where it's civil, nautical, or astronomical twilight.
The ECMAScript code starts and creates however many worker threads it needs to have one worker per core on the machine. It then divides the problem up into vertical pixel lines and calculates the angle at each pixel.
The page should be updated every minute, unless the checkbox is unselected.
|Twilight - Civil|
|Twilight - Nautical|
|Twilight - Astronomical|
To get the times for sunrise, sunset, and the twilights, enter the latitude and longitude into the input fields. The code will display these values and the time of noon (when the sun is over your longitude).
All times are given in GMT. This makes it easy (or less confusing) when inspecting other latitudes and longitudes.
I haven't checked the accuracy of any of this at present, and my constants for my version of the Equation of Time are only approximations. And since I only work on Linux, and use Firefox, I suspect this might not work on other environments.