Class: Astronoby::Sun
- Inherits:
-
SolarSystemBody
- Object
- SolarSystemBody
- Astronoby::Sun
- Defined in:
- lib/astronoby/bodies/sun.rb
Overview
Represents the Sun. Provides twilight events, equinox/solstice calculations, and equation of time.
Constant Summary collapse
- EQUATORIAL_RADIUS =
Distance.from_meters(695_700_000)
- ABSOLUTE_MAGNITUDE =
-26.74
Constants inherited from SolarSystemBody
Astronoby::SolarSystemBody::EARTH, Astronoby::SolarSystemBody::EARTH_MOON_BARYCENTER, Astronoby::SolarSystemBody::JUPITER_BARYCENTER, Astronoby::SolarSystemBody::MARS_BARYCENTER, Astronoby::SolarSystemBody::MERCURY, Astronoby::SolarSystemBody::MERCURY_BARYCENTER, Astronoby::SolarSystemBody::MOON, Astronoby::SolarSystemBody::NEPTUNE_BARYCENTER, Astronoby::SolarSystemBody::SATURN_BARYCENTER, Astronoby::SolarSystemBody::SOLAR_SYSTEM_BARYCENTER, Astronoby::SolarSystemBody::SUN, Astronoby::SolarSystemBody::URANUS_BARYCENTER, Astronoby::SolarSystemBody::VENUS, Astronoby::SolarSystemBody::VENUS_BARYCENTER
Instance Attribute Summary
Attributes inherited from SolarSystemBody
#ephem, #instant, #orientation
Class Method Summary collapse
-
.absolute_magnitude ⇒ Float
Absolute magnitude.
-
.december_solstice(year, ephem:) ⇒ Time
Time of the December solstice for the given year.
-
.ephemeris_segments(_ephem_source) ⇒ Array<Array>
Ephemeris segment identifiers.
-
.june_solstice(year, ephem:) ⇒ Time
Time of the June solstice for the given year.
-
.march_equinox(year, ephem:) ⇒ Time
Time of the March equinox for the given year.
-
.september_equinox(year, ephem:) ⇒ Time
Time of the September equinox for the given year.
-
.twilight_events(observer:, ephem:, date: nil, start_time: nil, end_time: nil, utc_offset: 0) ⇒ Astronoby::TwilightEvent+
Twilight events for the given date or time range.
Instance Method Summary collapse
-
#apparent_magnitude ⇒ Float
Source: Title: Explanatory Supplement to the Astronomical Almanac Authors: Sean E.
-
#approaching_primary? ⇒ Boolean
Always false; the Sun has no primary body.
-
#equation_of_time ⇒ Astronoby::Duration
Equation of time.
-
#phase_angle ⇒ nil
The Sun has no phase angle as seen from Earth.
-
#receding_from_primary? ⇒ Boolean
Always false; the Sun has no primary body.
Methods inherited from SolarSystemBody
#angular_diameter, #apparent, #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, planet?, rise_transit_set_events, superior_planet?, #western?
Methods included from Position
Constructor Details
This class inherits a constructor from Astronoby::SolarSystemBody
Class Method Details
.absolute_magnitude ⇒ Float
Returns absolute magnitude.
17 18 19 |
# File 'lib/astronoby/bodies/sun.rb', line 17 def self.absolute_magnitude ABSOLUTE_MAGNITUDE end |
.december_solstice(year, ephem:) ⇒ Time
Returns Time of the December solstice for the given year.
71 72 73 |
# File 'lib/astronoby/bodies/sun.rb', line 71 def self.december_solstice(year, ephem:) EquinoxSolstice.december_solstice(year, ephem) end |
.ephemeris_segments(_ephem_source) ⇒ Array<Array>
Returns ephemeris segment identifiers.
12 13 14 |
# File 'lib/astronoby/bodies/sun.rb', line 12 def self.ephemeris_segments(_ephem_source) [[SOLAR_SYSTEM_BARYCENTER, SUN]] end |
.june_solstice(year, ephem:) ⇒ Time
Returns Time of the June solstice for the given year.
57 58 59 |
# File 'lib/astronoby/bodies/sun.rb', line 57 def self.june_solstice(year, ephem:) EquinoxSolstice.june_solstice(year, ephem) end |
.march_equinox(year, ephem:) ⇒ Time
Returns Time of the March equinox for the given year.
50 51 52 |
# File 'lib/astronoby/bodies/sun.rb', line 50 def self.march_equinox(year, ephem:) EquinoxSolstice.march_equinox(year, ephem) end |
.september_equinox(year, ephem:) ⇒ Time
Returns Time of the September equinox for the given year.
64 65 66 |
# File 'lib/astronoby/bodies/sun.rb', line 64 def self.september_equinox(year, ephem:) EquinoxSolstice.september_equinox(year, ephem) end |
.twilight_events(observer:, ephem:, date: nil, start_time: nil, end_time: nil, utc_offset: 0) ⇒ Astronoby::TwilightEvent+
Returns Twilight events for the given date or time range.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/astronoby/bodies/sun.rb', line 31 def self.twilight_events( observer:, ephem:, date: nil, start_time: nil, end_time: nil, utc_offset: 0 ) calculator = TwilightCalculator.new(observer: observer, ephem: ephem) if date calculator.event_on(date, utc_offset: utc_offset) else calculator.events_between(start_time, end_time) end end |
Instance Method Details
#apparent_magnitude ⇒ Float
Source:
Title: Explanatory Supplement to the Astronomical Almanac
Authors: Sean E. Urban and P. Kenneth Seidelmann
Edition: University Science Books
Chapter: 10.3 - Phases and Magnitudes
Apparent magnitude of the body, as seen from Earth.
82 83 84 85 |
# File 'lib/astronoby/bodies/sun.rb', line 82 def apparent_magnitude @apparent_magnitude ||= self.class.absolute_magnitude + 5 * Math.log10(astrometric.distance.au) end |
#approaching_primary? ⇒ Boolean
Returns always false; the Sun has no primary body.
124 125 126 |
# File 'lib/astronoby/bodies/sun.rb', line 124 def approaching_primary? false end |
#equation_of_time ⇒ Astronoby::Duration
Returns Equation of time.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/astronoby/bodies/sun.rb', line 94 def equation_of_time right_ascension = apparent.equatorial.right_ascension t = (@instant.julian_date - JulianDate::J2000) / Constants::DAYS_PER_JULIAN_MILLENIA l0 = (280.4664567 + 360_007.6982779 * t + 0.03032028 * t**2 + t**3 / 49_931 - t**4 / 15_300 - t**5 / 2_000_000) % Constants::DEGREES_PER_CIRCLE nutation = Nutation.new(instant: instant).nutation_in_longitude obliquity = TrueObliquity.at(@instant) seconds = ( Angle .from_degrees( l0 - Constants::EQUATION_OF_TIME_CONSTANT - right_ascension.degrees + nutation.degrees * obliquity.cos ).hours * Constants::SECONDS_PER_HOUR ).round Duration.from_seconds(seconds) end |
#phase_angle ⇒ nil
Returns the Sun has no phase angle as seen from Earth.
119 120 121 |
# File 'lib/astronoby/bodies/sun.rb', line 119 def phase_angle nil end |
#receding_from_primary? ⇒ Boolean
Returns always false; the Sun has no primary body.
129 130 131 |
# File 'lib/astronoby/bodies/sun.rb', line 129 def receding_from_primary? false end |