Class: Astronoby::ExtremumFinder
- Inherits:
-
Object
- Object
- Astronoby::ExtremumFinder
- Defined in:
- lib/astronoby/extremum_finder.rb
Constant Summary collapse
- PHI =
(1 + Math.sqrt(5)) / 2
- INVPHI =
1 / PHI
- GOLDEN_SECTION_TOLERANCE =
1e-5- MIN_SAMPLES_PER_PERIOD =
20- DUPLICATE_THRESHOLD_DAYS =
0.5- BOUNDARY_BUFFER_DAYS =
0.01
Instance Method Summary collapse
-
#extrema(start_jd, end_jd, type: :maximum) ⇒ Array<Hash>
Extrema as {jd: Float, value: Comparable}, sorted by time.
-
#initialize(value_at:, period:, samples_per_period: 60) ⇒ ExtremumFinder
constructor
A new instance of ExtremumFinder.
Constructor Details
#initialize(value_at:, period:, samples_per_period: 60) ⇒ ExtremumFinder
Returns a new instance of ExtremumFinder.
18 19 20 21 22 |
# File 'lib/astronoby/extremum_finder.rb', line 18 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
#extrema(start_jd, end_jd, type: :maximum) ⇒ Array<Hash>
Returns extrema as {jd: Float, value: Comparable}, sorted by time.
29 30 31 32 33 34 |
# File 'lib/astronoby/extremum_finder.rb', line 29 def extrema(start_jd, end_jd, type: :maximum) candidates = find_candidates(start_jd, end_jd, type) refined = candidates.map { |candidate| refine(candidate, type) }.compact refined = remove_duplicates(refined) filter_boundary_artifacts(refined, start_jd, end_jd) end |