Class: Astronoby::Moon

Inherits:
SolarSystemBody show all
Defined in:
lib/astronoby/bodies/moon.rb

Overview

Represents the Moon. Provides phase events, apoapsis/periapsis events, and phase fraction.

Constant Summary collapse

SEMIDIAMETER_VARIATION =
0.7275
EQUATORIAL_RADIUS =
Distance.from_meters(1_737_400)
ABSOLUTE_MAGNITUDE =
0.28
ORBITAL_PERIOD =
27.504339

Constants inherited from SolarSystemBody

SolarSystemBody::EARTH, SolarSystemBody::EARTH_MOON_BARYCENTER, SolarSystemBody::JUPITER_BARYCENTER, SolarSystemBody::MARS_BARYCENTER, SolarSystemBody::MERCURY, SolarSystemBody::MERCURY_BARYCENTER, SolarSystemBody::MOON, SolarSystemBody::NEPTUNE_BARYCENTER, SolarSystemBody::SATURN_BARYCENTER, SolarSystemBody::SOLAR_SYSTEM_BARYCENTER, SolarSystemBody::SUN, SolarSystemBody::URANUS_BARYCENTER, SolarSystemBody::VENUS, SolarSystemBody::VENUS_BARYCENTER

Instance Attribute Summary

Attributes inherited from SolarSystemBody

#ephem, #instant, #orientation

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SolarSystemBody

#angular_diameter, #apparent, #apparent_magnitude, #approaching_primary?, #astrometric, at, #body, compute_geometric, conjunction_events, #constellation, #earth_geometric, #eastern?, #elongation, geometric, #geometric, greatest_elongation_events, #illuminated_fraction, inferior_planet?, #initialize, #mean_of_date, opposition_events, #phase_angle, planet?, #receding_from_primary?, rise_transit_set_events, superior_planet?, #western?

Methods included from Position

#observed_by

Constructor Details

This class inherits a constructor from Astronoby::SolarSystemBody

Class Method Details

.absolute_magnitudeFloat

Returns absolute magnitude.

Returns:

  • (Float)

    absolute magnitude



42
43
44
# File 'lib/astronoby/bodies/moon.rb', line 42

def self.absolute_magnitude
  ABSOLUTE_MAGNITUDE
end

.apoapsis_events(ephem:, start_time:, end_time:, samples_per_period: 60) ⇒ Array<Astronoby::ExtremumEvent>

Finds all apoapsis events between two times

Parameters:

  • ephem (::Ephem::SPK)

    Ephemeris data source

  • start_time (Time)

    Start time

  • end_time (Time)

    End time

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/astronoby/bodies/moon.rb', line 51

def self.apoapsis_events(
  ephem:,
  start_time:,
  end_time:,
  samples_per_period: 60
)
  ExtremumCalculator.new(
    body: self,
    primary_body: Earth,
    ephem: ephem,
    samples_per_period: samples_per_period
  ).apoapsis_events_between(start_time, end_time)
end

.eclipse_events(ephem:, start_time:, end_time:) ⇒ Array<Astronoby::LunarEclipse>

Finds all lunar eclipses whose greatest instant falls between two times

Parameters:

  • ephem (::Ephem::SPK)

    Ephemeris data source

  • start_time (Time)

    Start time

  • end_time (Time)

    End time

Returns:



89
90
91
92
93
# File 'lib/astronoby/bodies/moon.rb', line 89

def self.eclipse_events(ephem:, start_time:, end_time:)
  LunarEclipseCalculator
    .new(ephem: ephem)
    .events_between(start_time, end_time)
end

.ephemeris_segments(ephem_source) ⇒ Array<Array>

Returns ephemeris segment identifiers.

Parameters:

  • ephem_source (Symbol)

    the ephemeris source type

Returns:

  • (Array<Array>)

    ephemeris segment identifiers



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/astronoby/bodies/moon.rb', line 14

def self.ephemeris_segments(ephem_source)
  if ephem_source == ::Ephem::SPK::JPL_DE
    [
      [SOLAR_SYSTEM_BARYCENTER, EARTH_MOON_BARYCENTER],
      [EARTH_MOON_BARYCENTER, MOON]
    ]
  elsif ephem_source == ::Ephem::SPK::INPOP
    [
      [SOLAR_SYSTEM_BARYCENTER, EARTH],
      [EARTH, MOON]
    ]
  end
end

.monthly_phase_events(year:, month:) ⇒ Array<Astronoby::MoonPhase>

Returns Moon phases for the requested year.

Parameters:

  • year (Integer)

    Requested year

  • month (Integer)

    Requested month

Returns:



37
38
39
# File 'lib/astronoby/bodies/moon.rb', line 37

def self.monthly_phase_events(year:, month:)
  Events::MoonPhases.phases_for(year: year, month: month)
end

.periapsis_events(ephem:, start_time:, end_time:, samples_per_period: 60) ⇒ Array<Astronoby::ExtremumEvent>

Finds all periapsis events between two times

Parameters:

  • ephem (::Ephem::SPK)

    Ephemeris data source

  • start_time (Time)

    Start time

  • end_time (Time)

    End time

Returns:



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/astronoby/bodies/moon.rb', line 70

def self.periapsis_events(
  ephem:,
  start_time:,
  end_time:,
  samples_per_period: 60
)
  ExtremumCalculator.new(
    body: self,
    primary_body: Earth,
    ephem: ephem,
    samples_per_period: samples_per_period
  ).periapsis_events_between(start_time, end_time)
end

Instance Method Details

#bright_limb_position_angleAstronoby::Angle?

Position angle of the Moon’s bright limb: the position angle of the midpoint of the illuminated limb, measured eastward from the north point of the disk. Geocentric, from the apparent equatorial coordinates of the Moon and the Sun.

Source:

Title: Astronomical Algorithms
Author: Jean Meeus
Edition: 2nd edition
Chapter: 48 - Illuminated Fraction of the Moon's Disk

Returns:

  • (Astronoby::Angle, nil)

    Position angle of the bright limb, between 0 and 360 degrees



136
137
138
139
140
141
142
143
# File 'lib/astronoby/bodies/moon.rb', line 136

def bright_limb_position_angle
  return unless sun

  @bright_limb_position_angle ||= begin
    angle = apparent.equatorial.position_angle_to(sun.apparent.equatorial)
    Angle.from_degrees(angle.degrees % Constants::DEGREES_PER_CIRCLE)
  end
end

#current_phase_fractionFloat

Returns Phase fraction, from 0 to 1.

Returns:

  • (Float)

    Phase fraction, from 0 to 1



96
97
98
# File 'lib/astronoby/bodies/moon.rb', line 96

def current_phase_fraction
  mean_elongation.degrees / Constants::DEGREES_PER_CIRCLE
end

#librationAstronoby::Libration

Total geocentric libration of the Moon, in longitude and latitude.

With an orientation kernel (see orientation: on the constructor), this is the sub-Earth point from the integrated DE orientation, accurate to better than an arcsecond. Without one, it is the analytic optical plus physical libration (Meeus, Astronomical Algorithms, 2nd ed., chapter 53).

Returns:



108
109
110
# File 'lib/astronoby/bodies/moon.rb', line 108

def libration
  lunar_ephemeris.libration
end

#parallactic_angle(observer:) ⇒ Astronoby::Angle

Parallactic angle of the Moon for a given observer: the angle at the Moon between the direction of the north celestial pole and the direction of the observer’s zenith. Computed from the topocentric place, where lunar parallax is significant.

Source:

Title: Astronomical Algorithms
Author: Jean Meeus
Edition: 2nd edition
Chapter: 14 - The Parallactic Angle

Parameters:

Returns:



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/astronoby/bodies/moon.rb', line 158

def parallactic_angle(observer:)
  equatorial = observed_by(observer).equatorial
  declination = equatorial.declination
  hour_angle = equatorial.compute_hour_angle(
    time: @instant.to_time,
    longitude: observer.longitude
  )

  Angle.from_radians(
    Math.atan2(
      hour_angle.sin,
      observer.latitude.tan * declination.cos -
        declination.sin * hour_angle.cos
    )
  )
end

#position_angle_of_axisAstronoby::Angle

Position angle of the Moon’s axis of rotation, measured eastward from the north point of the disk.

With an orientation kernel this comes from the integrated DE orientation; without one, from the analytic series (Meeus, Astronomical Algorithms, 2nd ed., chapter 53).

Returns:



120
121
122
# File 'lib/astronoby/bodies/moon.rb', line 120

def position_angle_of_axis
  lunar_ephemeris.position_angle_of_axis
end