Class: Astronoby::EquinoxSolstice

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

Overview

Computes the time of equinoxes and solstices for a given year.

Source:

Title: Astronomical Algorithms
Author: Jean Meeus
Edition: 2nd edition
Chapter: 27 - Equinoxes and Soltices

Constant Summary collapse

EVENTS =
[
  MARCH_EQUINOX = 0,
  JUNE_SOLSTICE = 1,
  SEPTEMBER_EQUINOX = 2,
  DECEMBER_SOLSTICE = 3
].freeze
JDE_COMPONENTS =
{
  MARCH_EQUINOX => [
    2451623.80984,
    365242.37404,
    0.05169,
    -0.00411,
    -0.00057
  ],
  JUNE_SOLSTICE => [
    2451716.56767,
    365241.62603,
    0.00325,
    0.00888,
    -0.00030
  ],
  SEPTEMBER_EQUINOX => [
    2451810.21715,
    365242.01767,
    -0.11575,
    0.00337,
    0.00078
  ],
  DECEMBER_SOLSTICE => [
    2451900.05952,
    365242.74049,
    -0.06223,
    -0.00823,
    0.00032
  ]
}
PERIODIC_TERMS =
[
  [485, 324.96, 1934.136],
  [203, 337.23, 32964.467],
  [199, 342.08, 20.186],
  [182, 27.85, 445267.112],
  [156, 73.14, 45036.886],
  [136, 171.52, 22518.443],
  [77, 222.54, 65928.934],
  [74, 296.72, 3034.906],
  [70, 243.58, 9037.513],
  [58, 119.81, 33718.147],
  [52, 297.17, 150.678],
  [50, 21.02, 2281.226],
  [45, 247.54, 29929.562],
  [44, 325.15, 31555.956],
  [29, 60.93, 4443.417],
  [18, 155.12, 67555.328],
  [17, 288.79, 4562.452],
  [16, 198.04, 62894.029],
  [14, 199.76, 31436.921],
  [12, 95.39, 14577.848],
  [12, 287.11, 31931.756],
  [12, 320.81, 34777.259],
  [9, 227.73, 1222.114],
  [8, 15.45, 16859.074]
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(year, event, ephem) ⇒ EquinoxSolstice

Returns a new instance of EquinoxSolstice.

Parameters:

  • year (Integer)

    the year

  • event (Integer)

    one of MARCH_EQUINOX, JUNE_SOLSTICE, SEPTEMBER_EQUINOX, or DECEMBER_SOLSTICE

  • ephem (::Ephem::SPK)

    ephemeris data source

Raises:



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/astronoby/equinox_solstice.rb', line 110

def initialize(year, event, ephem)
  unless EVENTS.include?(event)
    raise UnsupportedEventError.new(
      "Expected a format between #{EVENTS.join(", ")}, got #{event}"
    )
  end

  @event = event
  @ephem = ephem
  @year = (year.to_i - 2000) / 1000.0
  uncorrected_time = compute
  @instant = Instant.from_time(uncorrected_time)
end

Class Method Details

.december_solstice(year, ephem) ⇒ Time

Returns time of the December solstice.

Parameters:

  • year (Integer)

    the year

  • ephem (::Ephem::SPK)

    ephemeris data source

Returns:

  • (Time)

    time of the December solstice



101
102
103
# File 'lib/astronoby/equinox_solstice.rb', line 101

def self.december_solstice(year, ephem)
  new(year, DECEMBER_SOLSTICE, ephem).time
end

.june_solstice(year, ephem) ⇒ Time

Returns time of the June solstice.

Parameters:

  • year (Integer)

    the year

  • ephem (::Ephem::SPK)

    ephemeris data source

Returns:

  • (Time)

    time of the June solstice



87
88
89
# File 'lib/astronoby/equinox_solstice.rb', line 87

def self.june_solstice(year, ephem)
  new(year, JUNE_SOLSTICE, ephem).time
end

.march_equinox(year, ephem) ⇒ Time

Returns time of the March equinox.

Parameters:

  • year (Integer)

    the year

  • ephem (::Ephem::SPK)

    ephemeris data source

Returns:

  • (Time)

    time of the March equinox



80
81
82
# File 'lib/astronoby/equinox_solstice.rb', line 80

def self.march_equinox(year, ephem)
  new(year, MARCH_EQUINOX, ephem).time
end

.september_equinox(year, ephem) ⇒ Time

Returns time of the September equinox.

Parameters:

  • year (Integer)

    the year

  • ephem (::Ephem::SPK)

    ephemeris data source

Returns:

  • (Time)

    time of the September equinox



94
95
96
# File 'lib/astronoby/equinox_solstice.rb', line 94

def self.september_equinox(year, ephem)
  new(year, SEPTEMBER_EQUINOX, ephem).time
end

Instance Method Details

#timeTime

Returns the corrected UTC time of the event.

Returns:

  • (Time)

    the corrected UTC time of the event



125
126
127
# File 'lib/astronoby/equinox_solstice.rb', line 125

def time
  Instant.from_terrestrial_time(@instant.tt + corrected).to_time.round
end