Module: Lunation::Calculation::SunPosition

Included in:
Lunation::Calculation
Defined in:
lib/lunation/calculation/sun_position.rb

Instance Method Summary collapse

Instance Method Details

#corrected_obliquity_of_eclipticObject

(corrected ε) corrected true obliquity of the ecliptic (A.A. p. 165) UNIT: Angle



97
98
99
100
101
102
103
# File 'lib/lunation/calculation/sun_position.rb', line 97

def corrected_obliquity_of_ecliptic
  @corrected_obliquity_of_ecliptic ||= begin
    result = mean_obliquity_of_ecliptic.decimal_degrees +
      0.00256 * longitude_of_ascending_node.cos
    Angle.from_decimal_degrees(result)
  end
end

#distance_between_earth_and_sun_in_astronomical_unitsObject

® earth_sun_distance (25.5, A.A. p. 164) UNIT: Astronomical Units (AU)



59
60
61
62
63
64
65
66
67
# File 'lib/lunation/calculation/sun_position.rb', line 59

def distance_between_earth_and_sun_in_astronomical_units
  @distance_between_earth_and_sun_in_astronomical_units ||= begin
    result = 1.000001018 *
      (1 - earth_orbit_eccentricity**2) / (
        (1 + earth_orbit_eccentricity * sun_anomaly.cos)
      )
    result.round(7)
  end
end

#distance_between_earth_and_sun_in_kilometersObject

® earth_sun_distance (25.5, A.A. p. 164) UNIT: Kilometers (km)



71
72
73
74
# File 'lib/lunation/calculation/sun_position.rb', line 71

def distance_between_earth_and_sun_in_kilometers
  @distance_between_earth_and_sun_in_kilometers ||=
    (distance_between_earth_and_sun_in_astronomical_units * 149_597_870).floor
end

#earth_orbit_eccentricityObject

(e) eccentricity of the earth’s orbit (25.4, A.A. p. 163) UNIT: Astronomical Units (AU)



28
29
30
31
# File 'lib/lunation/calculation/sun_position.rb', line 28

def earth_orbit_eccentricity
  @earth_orbit_eccentricity ||=
    Horner.compute(time, [0.016708634, -0.000042037, -0.0000001267]).round(9)
end

#longitude_of_ascending_node_low_precisionObject

(Ω) Longitude of the ascending node of the Moon’s mean orbit on the ecliptic

(low precision) A.A. p. 164

UNIT: Angle



79
80
81
82
# File 'lib/lunation/calculation/sun_position.rb', line 79

def longitude_of_ascending_node_low_precision
  @longitude_of_ascending_node_low_precision ||=
    Angle.from_decimal_degrees(125.04 - 1934.136 * time)
end

#sun_anomalyObject

(v) true anomaly of the sun (A.A. p. 164) UNIT: Angle



53
54
55
# File 'lib/lunation/calculation/sun_position.rb', line 53

def sun_anomaly
  @sun_anomaly ||= sun_mean_anomaly2 + sun_equation_of_center
end

#sun_declinationObject

(δ0) geocentric declination (of the sun) (13.4) A.A. p. 93 UNIT: Angle



118
119
120
121
122
123
124
# File 'lib/lunation/calculation/sun_position.rb', line 118

def sun_declination
  @sun_declination ||= begin
    result = corrected_obliquity_of_ecliptic.sin *
      sun_ecliptic_longitude.sin
    Angle.from_radians(Math.asin(result), normalize: false)
  end
end

#sun_ecliptic_longitudeObject

(apparent λ0) Sun apparent longitude (A.A. p. 169) UNIT: Angle



86
87
88
89
90
91
92
93
# File 'lib/lunation/calculation/sun_position.rb', line 86

def sun_ecliptic_longitude
  @sun_ecliptic_longitude ||= begin
    result = sun_true_longitude.decimal_degrees +
      - 0.00569 +
      - 0.00478 * longitude_of_ascending_node_low_precision.sin
    Angle.from_decimal_degrees(result)
  end
end

#sun_equation_of_centerObject

© Sun’s equation of the center (A.A. p. 164) UNIT: Angle



35
36
37
38
39
40
41
42
43
# File 'lib/lunation/calculation/sun_position.rb', line 35

def sun_equation_of_center
  @sun_equation_of_center ||= begin
    result = Horner.compute(time, [1.914602, -0.004817, -0.000014]) *
      sun_mean_anomaly2.sin +
      (0.019993 - 0.000101 * time) * Math.sin(2 * sun_mean_anomaly2.radians) +
      0.000289 * Math.sin(3 * sun_mean_anomaly2.radians)
    Angle.from_decimal_degrees(result, normalize: false)
  end
end

#sun_mean_anomaly2Object

(M) Sun mean_anomaly (25.3, A.A. p. 163) There is another, similar definition of the mean anomaly of the sun in (A.A. p. 144). This method seems to be slightly less precise. UNIT: Angle



19
20
21
22
23
24
# File 'lib/lunation/calculation/sun_position.rb', line 19

def sun_mean_anomaly2
  @sun_mean_anomaly2 ||= begin
    result = Horner.compute(time, [357.52911, 35_999.05029, -0.0001537])
    Angle.from_decimal_degrees(result)
  end
end

#sun_mean_longitudeObject

(L0) Geometric mean longitude of the sun (25.2, A.A. p. 163) UNIT: Angle



8
9
10
11
12
13
# File 'lib/lunation/calculation/sun_position.rb', line 8

def sun_mean_longitude
  @sun_mean_longitude ||= begin
    result = Horner.compute(time, [280.46646, 36_000.76983, 0.0003032])
    Angle.from_decimal_degrees(result)
  end
end

#sun_right_ascensionObject

(α0) geocentric (apparent) right ascension of the sun (25.6 A.A. p. 165) UNIT: Angle



107
108
109
110
111
112
113
114
# File 'lib/lunation/calculation/sun_position.rb', line 107

def sun_right_ascension
  @sun_right_ascension ||= begin
    numerator = corrected_obliquity_of_ecliptic.cos *
      sun_ecliptic_longitude.sin
    denominator = sun_ecliptic_longitude.cos
    Angle.from_radians(Math.atan2(numerator, denominator))
  end
end

#sun_true_longitudeObject

(☉) true longitude of the sun (A.A. p. 164) UNIT: Angle



47
48
49
# File 'lib/lunation/calculation/sun_position.rb', line 47

def sun_true_longitude
  @sun_true_longitude ||= sun_mean_longitude + sun_equation_of_center
end