Class: Astronoby::JulianDate

Inherits:
Object
  • Object
show all
Defined in:
lib/astronoby/julian_date.rb

Overview

Constant Summary collapse

BESSELIAN_EPOCH_STARTING_YEAR =

Starting year for Besselian epoch calculations

Returns:

  • (Integer)

    1900

1900
JULIAN_EPOCH_STARTING_YEAR =

Starting year for Julian epoch calculations

Returns:

  • (Integer)

    2000

2000
B1875 =

Julian Date for Besselian epoch 1875.0

Returns:

  • (Float)

    2405889.258550475

2405889.258550475
B1900 =

Julian Date for Besselian epoch 1900.0

Returns:

  • (Float)

    2415020.31352

2415020.31352
J1950 =

Julian Date for Julian epoch 1950.0

Returns:

  • (Float)

    2433282.5

2433282.5
J2000 =

Julian Date for Julian epoch 2000.0 (current standard)

Returns:

  • (Float)

    2451545.0

2451545.0
DEFAULT_EPOCH =

Default epoch used by the library

Returns:

  • (Float)

    2451545.0

J2000

Class Method Summary collapse

Class Method Details

.from_besselian_year(besselian_year) ⇒ Float

Converts a Besselian year to Julian Date

Uses the formula: JD = B1900 + 365.242198781 * (year - 1900) where 365.242198781 is the tropical year length at B1900.

Examples:

JulianDate.from_besselian_year(1875.0)
# => 2405889.258550475

Parameters:

  • besselian_year (Float)

    the Besselian year

Returns:

  • (Float)

    the Julian Date



73
74
75
76
# File 'lib/astronoby/julian_date.rb', line 73

def self.from_besselian_year(besselian_year)
  B1900 + Constants::TROPICAL_YEAR_AT_B1900 *
    (besselian_year - BESSELIAN_EPOCH_STARTING_YEAR)
end

.from_julian_year(julian_year) ⇒ Float

Converts a Julian year to Julian Date

Uses the formula: JD = J2000 + 365.25 * (year - 2000)

Examples:

JulianDate.from_julian_year(2025.0)
# => 2460676.25

Parameters:

  • julian_year (Float)

    the Julian year

Returns:

  • (Float)

    the Julian Date



57
58
59
60
# File 'lib/astronoby/julian_date.rb', line 57

def self.from_julian_year(julian_year)
  J2000 + Constants::DAYS_PER_JULIAN_YEAR *
    (julian_year - JULIAN_EPOCH_STARTING_YEAR)
end

.from_time(time) ⇒ Rational

Converts a Time object to Julian Date

Examples:

JulianDate.from_time(Time.utc(2000, 1, 1, 12, 0, 0))
# => 2451545.0

Parameters:

  • time (Time)

    the time to convert

Returns:

  • (Rational)

    the Julian Date



43
44
45
# File 'lib/astronoby/julian_date.rb', line 43

def self.from_time(time)
  time.to_datetime.ajd
end