Class: Astronoby::Refraction

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(coordinates) ⇒ Refraction

Returns a new instance of Refraction.

Parameters:



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.

Parameters:

Returns:



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.

Parameters:

Returns:



29
30
31
# File 'lib/astronoby/refraction.rb', line 29

def self.correct_horizontal_coordinates(coordinates:)
  new(coordinates).refract
end

Instance Method Details

#refractAstronoby::Coordinates::Horizontal

Returns horizontal coordinates with refraction applied to the altitude.

Returns:



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_angleAstronoby::Angle

Computes the refraction angle based on the observer’s atmospheric conditions and the body’s altitude.

Returns:



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