Class: Astronoby::Body

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

Constant Summary collapse

DEFAULT_REFRACTION_VERTICAL_SHIFT =
Angle.from_dms(0, 34, 0)
RISING_SETTING_HOUR_ANGLE_RATIO_RANGE =
(-1..1)

Instance Method Summary collapse

Constructor Details

#initialize(equatorial_coordinates) ⇒ Body

Returns a new instance of Body.



8
9
10
# File 'lib/astronoby/body.rb', line 8

def initialize(equatorial_coordinates)
  @equatorial_coordinates = equatorial_coordinates
end

Instance Method Details

#rising_azimuth(latitude:, apparent: true, vertical_shift: nil) ⇒ Astronoby::Angle?

Returns Sunrise azimuth.

Parameters:

  • latitude (Astronoby::Angle)

    Latitude of the observer

  • apparent (Boolean) (defaults to: true)

    Compute apparent or true data

  • vertical_shift (Astronoby::Angle) (defaults to: nil)

    Vertical shift correction angle

Returns:



54
55
56
57
58
59
60
61
# File 'lib/astronoby/body.rb', line 54

def rising_azimuth(latitude:, apparent: true, vertical_shift: nil)
  time_ratio = time_ratio(latitude, apparent, vertical_shift)
  return nil unless RISING_SETTING_HOUR_ANGLE_RATIO_RANGE.cover?(time_ratio)

  azimuth_ratio = azimuth_ratio(latitude, apparent, vertical_shift)

  Angle.acos(azimuth_ratio)
end

#rising_time(latitude:, longitude:, date:, apparent: true, vertical_shift: nil) ⇒ Time?

Returns Sunrise time.

Parameters:

  • latitude (Astronoby::Angle)

    Latitude of the observer

  • longitude (Astronoby::Angle)

    Longitude of the observer

  • date (Date)

    Date of the event

  • apparent (Boolean) (defaults to: true)

    Compute apparent or true data

  • vertical_shift (Astronoby::Angle) (defaults to: nil)

    Vertical shift correction angle

Returns:

  • (Time, nil)

    Sunrise time



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/astronoby/body.rb', line 24

def rising_time(
  latitude:,
  longitude:,
  date:,
  apparent: true,
  vertical_shift: nil
)
  time_ratio = time_ratio(latitude, apparent, vertical_shift)
  return nil unless RISING_SETTING_HOUR_ANGLE_RATIO_RANGE.cover?(time_ratio)

  hour_angle = Angle.acos(time_ratio)
  local_sidereal_time = LocalSiderealTime.new(
    date: date,
    time: right_ascension.hours - hour_angle.hours,
    longitude: longitude
  )

  local_sidereal_time.to_gst.to_utc
end

#setting_azimuth(latitude:, apparent: true, vertical_shift: nil) ⇒ Astronoby::Angle?

Returns Sunset azimuth.

Parameters:

  • latitude (Astronoby::Angle)

    Latitude of the observer

  • apparent (Boolean) (defaults to: true)

    Compute apparent or true data

  • vertical_shift (Astronoby::Angle) (defaults to: nil)

    Vertical shift correction angle

Returns:



105
106
107
108
109
110
111
112
# File 'lib/astronoby/body.rb', line 105

def setting_azimuth(latitude:, apparent: true, vertical_shift: nil)
  time_ratio = time_ratio(latitude, apparent, vertical_shift)
  return nil unless RISING_SETTING_HOUR_ANGLE_RATIO_RANGE.cover?(time_ratio)

  azimuth_ratio = azimuth_ratio(latitude, apparent, vertical_shift)

  Angle.from_degrees(360 - Angle.acos(azimuth_ratio).degrees)
end

#setting_time(latitude:, longitude:, date:, apparent: true, vertical_shift: nil) ⇒ Time?

Returns Sunset time.

Parameters:

  • latitude (Astronoby::Angle)

    Latitude of the observer

  • longitude (Astronoby::Angle)

    Longitude of the observer

  • date (Date)

    Date of the event

  • apparent (Boolean) (defaults to: true)

    Compute apparent or true data

  • vertical_shift (Astronoby::Angle) (defaults to: nil)

    Vertical shift correction angle

Returns:

  • (Time, nil)

    Sunset time



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/astronoby/body.rb', line 75

def setting_time(
  latitude:,
  longitude:,
  date:,
  apparent: true,
  vertical_shift: nil
)
  time_ratio = time_ratio(latitude, apparent, vertical_shift)
  return unless RISING_SETTING_HOUR_ANGLE_RATIO_RANGE.cover?(time_ratio)

  hour_angle = Angle.acos(time_ratio)
  local_sidereal_time = LocalSiderealTime.new(
    date: date,
    time: right_ascension.hours + hour_angle.hours,
    longitude: longitude
  )

  local_sidereal_time.to_gst.to_utc
end