Class: Astronoby::GreatestElongationCalculator

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

Instance Method Summary collapse

Constructor Details

#initialize(body:, ephem:, samples_per_period: 60) ⇒ GreatestElongationCalculator

Returns a new instance of GreatestElongationCalculator.

Parameters:

  • body (Astronoby::SolarSystemBody)

    the planet to track

  • ephem (::Ephem::SPK)

    ephemeris data source

  • samples_per_period (Integer) (defaults to: 60)

    number of samples per synodic period



8
9
10
11
12
# File 'lib/astronoby/events/greatest_elongation_calculator.rb', line 8

def initialize(body:, ephem:, samples_per_period: 60)
  @body = body
  @ephem = ephem
  @samples_per_period = samples_per_period
end

Instance Method Details

#greatest_elongation_events_between(start_time, end_time) ⇒ Array<Astronoby::GreatestElongation>

Returns greatest elongations in the range.

Parameters:

  • start_time (Time)

    start time

  • end_time (Time)

    end time

Returns:



18
19
20
21
22
23
24
# File 'lib/astronoby/events/greatest_elongation_calculator.rb', line 18

def greatest_elongation_events_between(start_time, end_time)
  finder.extrema(
    Instant.from_time(start_time).tt,
    Instant.from_time(end_time).tt,
    type: :maximum
  ).map { |extremum| build_event(extremum) }
end