Solar Compass

February 7, 2012

In 1836, a surveyor named William Burt invented a solar compass that determined true north from the Sun; he needed it because iron-bearing rock made his magnetic compass give inaccurate readings. His device was levelled on top of a tripod, then one scale was set to the Sun’s declination (Burt used a table, which repeated each year), a second scale at an angle to the first was set to the latitude, a third scale was set to the current time, and then the Sun was sighted through a pinhole to set a third scale; with the compass set up, any compass point could be determined through the sights of the instrument. Surveyors still use Burt’s compass today.

Nowadays, smart phones and tablet computers have built-in clocks to tell the time and GPS devices to give the latitude and longitude, and they even have magnetic compasses so you know which direction is north. If the Sun is shining, such devices could be made into a solar compass, so you could determine true north; the device could display a compass rose with an indication of the Sun’s azimuth, the user lays the device flat and points the azimuth indicator to the Sun, and the compass rose indicates true north.

In today’s exercise we will write a function to compute the Sun’s elevation (angle above the horizon) and azimuth (compass direction); you’ll have to draw the compass rose yourself. We’ll use as an example the site of the Gateway Arch in Saint Louis, Missouri, located at 38.6N, 90.2W, and find the Sun’s elevation and azimuth at 7:00am on February 7, 2012.

The first calculation is the Sun’s declination, which varies through the year as the sun’s daily high point moves north and south of the equator due to the tilt of the Earth’s axis; Burt looked up the declination in an almanac, but we can make the calculation ourselves. Declination is always between 23.45° north of the equator (the Tropic of Cancer) and 23.45° south of the equator (the Tropic of Capricorn), and is the same at all points on the globe; it is 0° at the spring and autumn equinoxes, 23.45° north at the summer solstice, and 23.45° south at the winter solstice. The formula is 23.45 sin(B), where B = 360/365 (d − 81); in this calculation, 360 is the number of degrees in a circle, 365 is the number of days in the year (use 366 in leap years), d is the day number with January 1st = 1, January 2nd = 2, and so on, and 81 is the day number of March 22nd, which is the spring equinox.

The second calculation is the local solar time. Burt used the latitude scale on his device to build a sundial that gave the local solar time directly, but we must calculate the difference between the local clock time and the local solar time. We begin with a calculation called the equation of time, which corrects for (“equates”) the eccentricity of the Earth’s orbit around the Sun and the tilt of the Earth on its axis; like the declination, the equation of time repeats each year, and is based on the number of days since the beginning of the year. The formula is 9.87 sin(2B) − 7.53 cos(B) − 1.5 sin(B), where B is the same calculation we made to compute the declination. The equation of time is given in minutes.

Given the equation of time, we can calculate the time correction factor that adjusts between local clock time and local sun time, which adjusts for variation within a time zone due to longitude and also incorporates the equation of time. The formula is 4(long − 15t) + eot, where 4 = 24 × 60 ÷ 360 is the number of minutes it takes the Earth to spin 1 degree, 15 = 360 ÷ 24 is the number of degrees the Earth spins in one hour, long is the longitude of the current location, t is the number of hours east (positive) or west (negative) the local time zone is from the Greenwich meridian (remember to add 1 hour if daylight saving time is in effect), and eot is the equation of time. The time correction is given in minutes. Then, the local solar time is just the local time plus the time correction factor divided by 60; the local solar time is measured in hours, with a fractional part indicating the minutes after the hour.

Burt’s third scale, sighting the sun through the pinhole, calculated the solar hour angle, which is 0° at local solar noon, negative in the solar morning and positive in the solar afternoon. The solar hour angle changes by 15° every hour as the Earth spins, so the calculation is 15(lst − 12), where lst is the local solar time.

Now the elevation is easy to calculate by the formula sin−1(sin(dec) sin(lat) + cos(dec) cos(lat) cos(hra)) where dec is the declination, lat is the latitude of the current location, and hra is the solar hour angle. The azimuth is equally easy to calculate by the formula cos−1((sin(dec) cos(lat) − cos(dec) sin(lat) cos(hra)) ÷ cos(α)) where α, which is the elevation angle at solar noon, is 90 − lat + dec in the northern hemisphere and 90 + latdec in the southern hemisphere.

Let’s make some calculations. February 7th is the 38th day of the year, b = 360 ÷ 366 × (38 − 81) = −42.3°, the declination is 23.45° × sin(−42.3°) = −15.8° and the equation of time is 9.87 sin(−84.6°) − 7.53 cos(−42.3°) − 1.5 sin(−42.3°) = −14.4 minutes. Saint Louis is 6 hours west of Greenwich, and daylight savings time is not in effect, so the time correction is 4(−90.2 − −90) − 14.4 = −15.2 minutes, the local solar time is 7 + 0/60 − 15.2/60 = 6.75 hours (that’s 6:45am), and the solar hour angle is 15(6.75 − 12) = −78.8°. The elevation is sin−1(sin(−15.8°) sin(38.6°) − cos(-15.8°) cos(38.6°) cos(−78.8°)) = −1.3°, so the Sun has not yet risen. Now α = 90° − 38.6° − 15.8° = 35.6° and the azimuth is cos−1((sin(−15.8°) cos(38.6°) − cos(−15.8°) sin(38.6°) cos(−78.8°)) ÷ cos(35.6°))= 113.9°. I was at the Gateway Arch this morning at 7:00am (I attend Mass every morning at the Basilica of Saint Louis, King of France (the Old Cathedral), which is just a few hundred feet from the Arch), and can testify that the Sun was just about to rise over the Mississippi River a little bit south of due East.

Your task is to write a function that returns the Sun’s elevation and azimuth given latitude, longitude and the current date and time. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.


Pages: 1 2

2 Responses to “Solar Compass”

  1. There is a low-tech way to build a solar compass. Create a level table. Put a pointer above it so it casts a shadow on the table. Mark the shadow’s position. Wait until the shadow has moved, then mark its new position. The ray from the first to second position points due east.

    This has some error, as the sun isn’t moving* _exactly_ east-to-west. The error increases
    with latitude and at times closest to the equinoxes. Here at 45° north latitude, on the equinox, the error is about 0.2°.

    *Pedantically, the sun isn’t moving, the earth is rotating.

  2. programmingpraxis said

    Burt’s compass does much the same thing. The latitude scale builds a sundial. Then the third scale marks the solar hour angle, from which you can calculate any compass point. And you don’t have to wait an hour.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: