Class: Astronoby::RootFinder
- Inherits:
-
Object
- Object
- Astronoby::RootFinder
- Defined in:
- lib/astronoby/root_finder.rb
Constant Summary collapse
- MIN_SAMPLES_PER_PERIOD =
20- BISECTION_TOLERANCE_DAYS =
1e-5
Instance Method Summary collapse
-
#initialize(value_at:, period:, samples_per_period: 60) ⇒ RootFinder
constructor
A new instance of RootFinder.
-
#roots(start_jd, end_jd, accept: nil) ⇒ Array<Float>
Root times in Julian Date (Terrestrial Time), sorted by time.
Constructor Details
#initialize(value_at:, period:, samples_per_period: 60) ⇒ RootFinder
Returns a new instance of RootFinder.
12 13 14 15 16 |
# File 'lib/astronoby/root_finder.rb', line 12 def initialize(value_at:, period:, samples_per_period: 60) @value_at = value_at @period = period @samples_per_period = samples_per_period end |
Instance Method Details
#roots(start_jd, end_jd, accept: nil) ⇒ Array<Float>
Returns root times in Julian Date (Terrestrial Time), sorted by time.
24 25 26 27 28 |
# File 'lib/astronoby/root_finder.rb', line 24 def roots(start_jd, end_jd, accept: nil) brackets = find_brackets(start_jd, end_jd) located = brackets.map { |a, b| bisect(a, b) } located.select { |jd| accept.nil? || accept.call(jd) } end |