A rubygem that provides a C extension for the Swiss Ephemeris library (http://www.astro.com/swisseph/)
C Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
ext/swe4r
lib
test
.gitignore
COPYING
README.rdoc
Rakefile
swe4r.gemspec

README.rdoc

Swe4r (Swiss Ephemeris 2.0 for Ruby)

The Swe4r rubygem provides a C extension for the standard functions of the Swiss Ephemeris API.

This version has been updated to use the latest (fev/2014) Swiss Ephemeris API.

Installation

Install the gem as usual:

[sudo] gem install swe4r

Methods

The following functions of the Swiss Ephemeris API are supported…

swe_calc_ut

Calculation of planets, moon, asteroids, lunar nodes, apogees, fictitious bodies

swe_houses

This function computes house cusps, ascendant, midheaven, etc

swe_set_ephe_path

Set directory path of ephemeris files (not required for Moshier Ephemeris)

swe_julday

Get the Julian day number from year, month, day, hour

swe_set_topo

Set the geographic location for topocentric planet computation

swe_set_sid_mode

This function can be used to specify the mode for sidereal computations

swe_get_ayanamsa

This function computes the ayanamsha, the distance of the tropical vernal point from the sidereal zero point of the zodiac

Examples

The following example demonstrates how to calculate the position of a celestial body such as a planet using the swe_calc_ut function

require 'swe4r'

# Date Information
year = 2012
month = 5
day = 14
hour = 10.15

# Geographic Location
longitude = -112.183333
latitidue = 45.45
altitude = 1468

# Get the Julian day number
jd = Swe4r::swe_julday(year, month, day, hour)

# Set the geographic location for topocentric positions
Swe4r::swe_set_topo(longitude, latitidue, altitude)

# Set the sidereal mode for sidereal positions
Swe4r::swe_set_sid_mode(Swe4r::SE_SIDM_LAHIRI, 0, 0)

# Get the ayanamsha (the distance of the tropical vernal point from the sidereal zero point of the zodiac)
ayanamsha = Swe4r::swe_get_ayanamsa_ut(jd)

# Calculate the position of the Sun
# Use the Moshier Ephemeris (does not require ephemeris files)
# Get high precision speed and sidereal/topocentric positions
body = Swe4r::swe_calc_ut(jd, Swe4r::SE_SUN, Swe4r::SEFLG_MOSEPH|Swe4r::SEFLG_SPEED|Swe4r::SEFLG_TOPOCTR|Swe4r::SEFLG_SIDEREAL)

# Print the results
puts "Longitude: #{body[0]}"
puts "Latitude: #{body[1]}"
puts "Distance in AU: #{body[2]}"
puts "Speed in longitude (deg/day): #{body[3]}"
puts "Speed in latitude (deg/day): #{body[4]}"
puts "Speed in distance (AU/day): #{body[5]}"
puts "Ayanamsha: #{ayanamsha}"

The following example demonstrates how to calculate house cusps, the ascendant, midheaven, and other points on the zodiac using the swe_houses function

require 'swe4r'

# Date Information
year = 2012
month = 5
day = 14
hour = 10.15

# Geographic Location
longitude = -112.183333
latitidue = 45.45
altitude = 1468

# Get the Julian day number
jd = Swe4r::swe_julday(year, month, day, hour)

# Get house details using the Placidus house system
houses = Swe4r::swe_houses(jd, latitidue, longitude, 'P')

# Print the house cusps
(1..12).each do |i|
  puts "House ##{i} Cusp: #{houses[i]}"
end

# Print ascendant, midheaven, etc
puts "Ascendant: #{houses[13]}"
puts "Midheaven (MC): #{houses[14]}"
puts "ARMC: #{houses[15]}"
puts "Equatorial Ascendant: #{houses[16]}"
puts "Co-Ascendant (Walter Koch): #{houses[17]}"
puts "Co-Ascendant (Michael Munkasey): #{houses[18]}"
puts "Polar Ascendant (M. Munkasey) : #{houses[19]}"

License

Swe4r is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Swe4r is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Swe4r. If not, see www.gnu.org/licenses/.