0.0
The project is in a healthy, maintained state
This ruby class let you get important data (ra, dec, distance as well as rise, transit and set times) for the Sun, the Moon and all major planets for a given date and location. You can also print out a table with all the data in one fell swoop. Check out the Github page for detailed information on how to use this Ruby class: https://github.com/isene/ephemeris
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Ephemeris

Gem Version Ruby License GitHub stars Stay Amazing

Ruby Class::Ephemeris

This is a complete ephemeris class for Ruby. The code can easily be used in other languages or wrapped for use as a CLI application or on a web page.

The system is an implementation of this in-depth description and with Jean Meeus' "Astronomical Formulae for Calculators" as reference. The basic data from the in-depth description has been tweaked somewhat to better fit our era.

Version 1.2.0 - Improved Accuracy

This version includes significant accuracy improvements:

  • Updated obliquity of ecliptic to IAU 2006 standard (23.439279444°) with proper time-dependent formula
  • Implemented higher-precision planetary mean motion values for all planets
  • Enhanced calculations now use research-validated constants from JPL ephemeris data
  • Better long-term accuracy especially for dates far from J2000.0 epoch

Usage is simple and straightforward:

o = Ephemeris.new(date, lat, lon, tz)

...creates a new ephemeris object for the "date" (a string in ISO format 2020-12-16) by supplying the observer's latitude (lat), longitude (lon) and time zone (tz).

Example: today = Ephemeris.new("2020-12-16", 59.568, 10.02, 1)

You will then have access to the following data:

today.sun
today.moon 
today.mercury
today.venus
today.mars
today.jupiter
today.saturn
today.uranus
today.neptune

By calling any of these, you will get back an array with the following data:

[ra, dec, distance, ra_string, dec_string, rise, transit, set]

where:

ra         = object's Right Ascension (float)
dec        = object's Declination (float)
distance   = object's distance from Earth in AUs (float) - except for the Moon
ra_string  = ra in a presentable string, e.g "17h 24m 31s"
dec_string = dec in a presentable string, e.g "-24° 16´ 47˝"
rise       = object's time of rise above the horizon (float, fraction of 24h)
transit    = object's time of transit (float, fraction of 24h)
set        = object's time of setting (float, fraction of 24h)

You will also get access to the method "print" that will print out a nice table with data fro the planets:

today.print

Planet  │ RA          │ Dec          │ Dist. │ Rise  │ Trans │ Set
────────┼─────────────┼──────────────┼───────┼───────┼───────┼──────
Mercury │ 17h 24m 31s │ -24° 16´ 47˝ │  1.44 │ 09:27 │ 12:02 │ 14:38
Venus   │ 15h 53m  7s │ -18° 57´ 29˝ │  1.50 │ 06:56 │ 10:31 │ 14:05
Mars    │  1h 16m 21s │   8° 34´ 10˝ │  0.75 │ 12:54 │ 19:54 │ 02:54
Jupiter │ 20h  4m 43s │ -20° 49´ 46˝ │  5.87 │ 11:27 │ 14:42 │ 17:58
Saturn  │ 20h  7m 11s │ -20° 35´ 38˝ │ 10.79 │ 11:27 │ 14:45 │ 18:03
Uranus  │  2h 18m 28s │  13° 20´ 44˝ │ 19.08 │ 13:19 │ 20:56 │ 04:33
Neptune │ 23h 17m 19s │  -5° 45´ 42˝ │ 29.99 │ 12:35 │ 17:55 │ 23:15