Class: Astronoby::Refraction
- Inherits:
-
Object
- Object
- Astronoby::Refraction
- Defined in:
- lib/astronoby/refraction.rb
Overview
Computes atmospheric refraction corrections for horizontal coordinates.
Source:
Title: Practical Astronomy with your Calculator or Spreadsheet
Authors: Peter Duffett-Smith and Jonathan Zwart
Edition: Cambridge University Press
Chapter: 37 - Refraction
Constant Summary collapse
- LOW_ALTITUDE_BODY_ANGLE =
Angle.from_degrees(15)
- ZENITH =
Angle.from_degrees(90)
Class Method Summary collapse
-
.angle(coordinates:) ⇒ Astronoby::Angle
Computes the refraction angle for the given horizontal coordinates.
-
.correct_horizontal_coordinates(coordinates:) ⇒ Astronoby::Coordinates::Horizontal
Returns horizontal coordinates corrected for atmospheric refraction.
Instance Method Summary collapse
-
#initialize(coordinates) ⇒ Refraction
constructor
A new instance of Refraction.
-
#refract ⇒ Astronoby::Coordinates::Horizontal
Returns horizontal coordinates with refraction applied to the altitude.
-
#refraction_angle ⇒ Astronoby::Angle
Computes the refraction angle based on the observer’s atmospheric conditions and the body’s altitude.
Constructor Details
#initialize(coordinates) ⇒ Refraction
Returns a new instance of Refraction.
35 36 37 |
# File 'lib/astronoby/refraction.rb', line 35 def initialize(coordinates) @coordinates = coordinates end |
Class Method Details
.angle(coordinates:) ⇒ Astronoby::Angle
Computes the refraction angle for the given horizontal coordinates.
20 21 22 |
# File 'lib/astronoby/refraction.rb', line 20 def self.angle(coordinates:) new(coordinates).refraction_angle end |
.correct_horizontal_coordinates(coordinates:) ⇒ Astronoby::Coordinates::Horizontal
Returns horizontal coordinates corrected for atmospheric refraction.
29 30 31 |
# File 'lib/astronoby/refraction.rb', line 29 def self.correct_horizontal_coordinates(coordinates:) new(coordinates).refract end |
Instance Method Details
#refract ⇒ Astronoby::Coordinates::Horizontal
Returns horizontal coordinates with refraction applied to the altitude.
42 43 44 45 46 47 48 |
# File 'lib/astronoby/refraction.rb', line 42 def refract Coordinates::Horizontal.new( azimuth: @coordinates.azimuth, altitude: @coordinates.altitude + refraction_angle, observer: @coordinates.observer ) end |
#refraction_angle ⇒ Astronoby::Angle
Computes the refraction angle based on the observer’s atmospheric conditions and the body’s altitude.
54 55 56 57 58 59 60 |
# File 'lib/astronoby/refraction.rb', line 54 def refraction_angle if @coordinates.altitude > LOW_ALTITUDE_BODY_ANGLE high_altitude_angle else low_altitude_angle end end |