Question

Given a latitude and longitude, I need to calculate in Ruby the astronomical, nautical, civil twilight, as well as the zeniths of the moon and sun.

A gem which works locally (no network calls necessary) based on a lat/lon and date would be perfect, but a network service I can query would also do.

Weather Underground displays this information via the web but their API does not provide all of the fields (zeniths, for instance, are missing).

solareventcalculator is a gem but it lacks some features and in some cases calculates sunset time correctly but date incorrectly.

RubyGems has only one result for astronomy, setec_astronomy, which appears to be a KeePass search utility.

There is a related answer here but it is less evolved than SolarEventCalculator.

Was it helpful?

Solution

As an update about gems, I seem to have fallen in love with https://rubygems.org/gems/celes I have also put a little of my own C extensions into Eot gem now.

http://www.rubydoc.info/gems/equationoftime/4.1.8

now uses Celes.

http://www.rubydoc.info/gems/celes

You asked for Ruby. You got it.

For other ways try links like http://www.die.net/moon/ or http://www.die.net/earth/

The related link Sunrise / set calculations does components very similar to this ruby gem only is in python. You will see the zenith starts for the different solar events in this question which is a good one. If I look in my local newspaper for these events, which one is it? (astronomical, nautical, civil, official) Official right?

For definitions on twilight see http://aa.usno.navy.mil/faq/docs/RST_defs.php

If you want to see some experimental code that was inspired by this formula http://en.wikipedia.org/wiki/Sunrise_equation

I played around with that in Ruby. see https://github.com/DouglasAllen/Gather_the_gists/blob/master/suntimes_no_gem.rb

I have AstroCpp saved at https://github.com/DouglasAllen/C_Programming_Refference/tree/master/examples_src

The link for it is http://projectpluto.com/source.htm

I like Ruby-Shere too and is an older gem not on github but on sourceforge. http://sourceforge.net/projects/ruby-sphere/

I used Mike's software and it seems to prove itself. He doesn't tell you how it all fits together but it's good code to work with. https://github.com/mikereedell/sunrisesunset-ruby http://www.mikereedell.com/

I have a web site with lots of links at http://equationoftime.herokuapp.com/links

Some code will calculate the Right Ascension of the Sun and that means it will be on your local merridian at that time sidereal. So you will have to convert that back to your time zone for your Solar Transit time then just find the event horizon angles, divide the total by 2 and add or subtract that from your solar transit which is your local longitude. But that is where equation of time comes into play. It's not always right there. The angle is different as the year progresses. So that not only effects your sundial readings but the sunrise and sunset times.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top