Home | Science | Solar Computer |     Share This Page
Solar Computer

A recently updated, interactive JavaScript application that computes
sunrise/sunset/day length for any location on Earth.

— Copyright © 2012, P. Lutus  Message Page

Introduction | Solar Computer | Documentation
The "Sun Computer" Story

(double-click any word to see its definition)

Introduction

Solar Computer provides an easy way to compute sunrise and sunset times, and some other useful values, for any date and geographical location.

This version of Solar Computer is the most recent in a series of programs I have written over the years to provide a variety of useful solar computations. This version is written in JavaScript and replaces an older Java page (archived here). I replaced the old version because many people have requested a more flexible data source that can produce a table of values covering a year, rather than just one day. Also, over time there have been many changes in Java that had the side effect of preventing older programs from running properly. This is something that should never happen to a computer language, but it does happen, regularly, ultimately disabling any computer programs that are not rewritten over and over again to keep up with arbitrary changes in the language.

The new version is quite easy to use. Detailed documentation is provided below, but for those who want a quick result, here is how to proceed:

  • Wait for the network to automatically provide your location.
  • If the above operation fails, or if you want sunrise/sunset times for a location other than your own,
    enter a geographic location for the place of interest.
  • You can also zoom the map in and out, and choose a different location by clicking it.
  • Enter the date of interest if not today.
  • Enter a time zone if the automatically generated zone is not correct.
  • Compute solar values for the present date.
  • Optionally generate a data table for an entire year.

To copy the generated yearly data table, click on the table display, press Ctrl+A (select all), then Ctrl+C (copy). The data table will then be located on the system clipboard, suitable for pasting into a spreadsheet or database file.

Again, complete documentation and technical notes for Solar Computer are located .

Solar Computer is released under the GPL.

Solar Computer

Wait for Network Approximate Location and Map: 

Awaiting network location ...

  Or Enter a Geographic Location:
Degrees Minutes Hemisphere
Latitude
North South
Longitude
West East
Enter Date and Time Zone:

Year Month Day

Time Zone
   
Compute Solar Data for Selected Date and Location:
   24 Hour AM/PM

Results for Selected Date and Location:

Rise Transit Set Duration
Sun Rise/Set 00:00:00 00:00:00 00:00:00 00:00:00
Civil Twilight 00:00:00   00:00:00 00:00:00
Nautical Twilight 00:00:00   00:00:00 00:00:00
Astronomical Twilight 00:00:00   00:00:00 00:00:00
Generate Year Table or Database for Selected Year and Location:

Brief form Full form

  

Data Table:

(press "Create Table" or "Create Database" above)

Maxima and Minima: (available after year table generation)

Date Sunrise Sunset Duration
Earliest Sunrise 0000-00-00 00:00:00 00:00:00 00:00:00
Latest Sunset 0000-00-00 00:00:00 00:00:00 00:00:00
Longest Day 0000-00-00 00:00:00 00:00:00 00:00:00
 
Latest Sunrise 0000-00-00 00:00:00 00:00:00 00:00:00
Earliest Sunset 0000-00-00 00:00:00 00:00:00 00:00:00
Shortest Day 0000-00-00 00:00:00 00:00:00 00:00:00
Documentation
Computation Theory
Solar position computation relies on a mathematical model of the sun-earth orbital system. There are several factors that make this computation somewhat complex, among which are the eccentricity of Earth's orbit and Earth's axial tilt that is responsible for the seasons.

After the sun's position relative to the Earth has been computed for a given date, one must then acquire a relative position based on a specified geographical location. This set of computations relies on a number of methods including Fourier series and three-dimensional trigonometry.

It is important to note that an observer who views a sunrise or sunset normally is looking through Earth's atmosphere, which has optical properties not unlike a lens. This lens effect causes the sun's apparent position to differ from its computed position, and this lens effect must be taken into account in predicting a sunrise or sunset as seen by an observer. Unfortunately, a solar prediction must necessarily assume average atmospheric conditions, and there will be times when the sun's apparent position differs from the prediction. This variation may typically cause an error of several minutes in the time of an observed sunrise or sunset.

Also, computation of sunrise and sunset times assumes an observer is looking toward a level horizon that is at the same altitude as the observer, something that is rarely true. The only place in the author's experience where sunrises and sunsets reliably take place near predicted times is while sailing on the open ocean — and even then, abnormal atmospheric conditions sometimes prevent an accurate prediction.

Data Categories
The solar computer provides four classes of predictions for different purposes:

Name Sun's Distance Below Horizon Definition
Sunrise/Sunset 0° 50' In normal conditions of of atmospheric refraction, the sun's upper limb appears to be touching the horizon.
Civil Twilight The time after which city streetlights are lit, automobiles begin using headlights, in general, the time after which we begin to use artificial light.
Nautical Twilight 12° The best time for a sailor to use a sextant to take a star sight — the horizon is still visible, and many navigational stars are also visible. Earlier, some important navigational stars will not be visible. Later, the horizon becomes too difficult to see through the sextant.
Astronomical Twilight 18° After this time, the sky is dark enough for astronomers to make productive use of powerful telescopes. Only the faintest glow is visible near the sun's position.

Data Entry Notes
There are a number of different angular notation conventions in current use, and Solar Computer will easily accommodate most of them. If the user has a geographic location expressed in degrees and decimal degrees (no minutes or seconds), he can type these values into the "Degrees" entry and disregard the "Minutes" and "Seconds" entries.

Another popular data format, used widely in GPS receivers, is degrees, minutes and decimal minutes (no seconds). Enter this in much the same way — enter the degree value, then enter the minutes and decimal minutes value into the "Minutes" entry, skipping the "Seconds" entry. Because of this flexible entry arrangement, the user should never have to convert any of the common geographical coordinate notations into a different form while using Solar Computer.

High Latitude Notes
For locations near or within the Arctic and Antarctic circles, there are dates when no sunrise or sunset take place (the sun is continually above or below the horizon). Solar Computer will indicate this with special labels — "[Above]" or "[Below]" — instead of times, for dates where the computation could not produce meaningful results.

Reusable Entries
Because a user may want to re-use an entered geographical location and option settings, Solar Computer saves these entries between uses. This means a visitor can return to this page and compute sunrise and sunset times for a new date with a previously entered geographic location and option settings.

Database Table Export Notes
To export the most portable and useful database table, be sure to use 24 hour time formatting, rather than AM/PM. The database table created by this page uses industry-standard record formatting (comma separated values) and standard date syntax, thus it can be imported directly into many database programs without change. To save the database table, click the table display, press Ctrl+A to select the entire table, then press Ctrl+C to copy the table onto the system clipboard. The copied table can be pasted into a plain text file that, in turn, can be imported into a database program or spreadsheet.

This clipboard export procedure is required because JavaScript cannot save files directly, although in every other respect JavaScript turns out to be the most convenient way to provide this data resource.

The "Sun Computer" Story
This is an interesting anecdote about this page and its predecessor — it's not part of the documentation per se.

When I wrote my first Web Web-based sunrise/sunset computer, without any deep thought I named the page "Sun Computer". That seemed a reasonable name and was in keeping with the widely respected idea that a short name that conveys the essentials is better than a long one.

In the meantime, widespread changes were taking place on the Web, the most important being that people began to find what they sought by way of search engines like Google, rather than visiting what were called "gateway sites," as Yahoo once was.

One day I got an official-looking, registered letter in the conventional mail, that turned out to be from a corporate law office. The letter's tone was unashamedly adversarial, as legal letters tend to be, starting out with something like "Sun Computer must protect its intellectual property and trademarks ...", then going on to argue that my having named my page "Sun Computer" infringed on Sun Computer's trademark.

I very foolishly replied that there was a heavenly body with that name, I had to refer to it by name in order to describe my page, and people who name their companies using common dictionary words are just asking for trouble. Those readers who conclude from this reply that I had not talked very much with lawyers are quite right. On the other hand, I had no idea what was going on, and the lawyers' adversarial stance left no latitude for simple explanations.

After an exchange of letters, during which the lawyers did what they do best (threaten legal action to keep me from misusing the "Sun" name), I finally sorted it out. It turns out that my "Sun Computer" page appeared above their "Sun Computer" page in Google's search listings, which needlessly misdirected people to a sun computer rather than the Sun Computer.

This confusion was certainly not my intention, and I hadn't named my page with the intention of misdirecting people who wanted the Sun Computer. This was before people began registering common misspellings of domain names, hoping to take advantage of keyboard mistakes, and nothing was further from my mind.

On my own I figured out what the problem was, and I fixed it in a matter of minutes. I got over my giggles that Sun Computer expected to keep people from using the word "Sun," and I changed my page's name to "Solar Calculator." My point? "Sun Computer" could simply have explained the problem and asked me to change my page's name to something that wouldn't trigger a confusing search engine result. That would have saved a lot of time, trouble and expense for both Sun Computer and me, because I had to figure out on my own what they wanted, and why.

What I found astonishing was the corporate lawyers never considered the possibility that I had no nefarious intent and didn't care very much what my page was called. They could have showed up at my door, borrowed a cup of sugar, and solved the problem in a matter of minutes. On the other hand, if they had done that they wouldn't have been able to charge Sun Computer several thousand dollars in billable legal hours.

And that, boys and girls, is why this page is named "Solar Computer" instead of "Sun Computer," a concise and obvious choice.

 

Home | Science | Solar Computer |     Share This Page