Class: Astronoby::GeocentricParallax

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

Constant Summary collapse

ASTRONOMICAL_UNIT_IN_METERS =

Source:

Title: Practical Astronomy with your Calculator or Spreadsheet
Authors: Peter Duffett-Smith and Jonathan Zwart
Edition: Cambridge University Press
Chapter: 39 - Calculating correction for parallax
149_597_870_700
EARTH_FLATTENING_CORRECTION =
0.996647
EARTH_EQUATORIAL_RADIUS =
6378140.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(latitude, longitude, elevation, time, coordinates, distance) ⇒ GeocentricParallax

Returns a new instance of GeocentricParallax.

Parameters:

  • latitude (Astronoby::Angle)

    Observer’s latitude

  • longitude (Astronoby::Angle)

    Observer’s longitude

  • elevation (Numeric)

    Observer’s elevation above sea level in meters

  • time (Time)

    Date-time of the observation

  • coordinates (Astronoby::Coordinates::Equatorial)

    Equatorial coordinates of the observed body

  • distance (Numeric)

    Distance of the observed body from the center of the Earth, in meters



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/astronoby/geocentric_parallax.rb', line 61

def initialize(
  latitude,
  longitude,
  elevation,
  time,
  coordinates,
  distance
)
  @latitude = latitude
  @longitude = longitude
  @elevation = elevation
  @time = time
  @coordinates = coordinates
  @distance = distance
end

Class Method Details

.angle(distance:) ⇒ Astronoby::Angle

Equatorial horizontal parallax

Parameters:

  • distance (Numeric)

    Distance of the body from the center of the Earth, in meters

Returns:



19
20
21
22
# File 'lib/astronoby/geocentric_parallax.rb', line 19

def self.angle(distance:)
  distance_in_earth_radius = distance / EARTH_EQUATORIAL_RADIUS
  Angle.asin(1 / distance_in_earth_radius)
end

.for_equatorial_coordinates(latitude:, longitude:, elevation:, time:, coordinates:, distance:) ⇒ Astronoby::Coordinates::Equatorial

Correct equatorial coordinates with the equatorial horizontal parallax

Parameters:

  • latitude (Astronoby::Angle)

    Observer’s latitude

  • longitude (Astronoby::Angle)

    Observer’s longitude

  • elevation (Numeric)

    Observer’s elevation above sea level in meters

  • time (Time)

    Date-time of the observation

  • coordinates (Astronoby::Coordinates::Equatorial)

    Equatorial coordinates of the observed body

  • distance (Numeric)

    Distance of the observed body from the center of the Earth, in meters

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/astronoby/geocentric_parallax.rb', line 35

def self.for_equatorial_coordinates(
  latitude:,
  longitude:,
  elevation:,
  time:,
  coordinates:,
  distance:
)
  new(
    latitude,
    longitude,
    elevation,
    time,
    coordinates,
    distance
  ).apply
end

Instance Method Details

#applyObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/astronoby/geocentric_parallax.rb', line 77

def apply
  term1 = Angle.atan(EARTH_FLATTENING_CORRECTION * @latitude.tan)
  quantity1 = term1.cos + elevation_ratio * @latitude.cos
  quantity2 = EARTH_FLATTENING_CORRECTION * term1.sin +
    elevation_ratio * @latitude.sin

  term2 = quantity1 * hour_angle.sin
  term3 = distance_in_earth_radius * declination.cos -
    quantity1 * hour_angle.cos

  delta = Angle.atan(term2 / term3)

  apparent_hour_angle = hour_angle + delta
  apparent_right_ascension = right_ascension - delta
  apparent_declination = Angle.atan(
    (
      apparent_hour_angle.cos *
        (distance_in_earth_radius * declination.sin - quantity2)
    ) / (
      distance_in_earth_radius * declination.cos * hour_angle.cos - quantity1
    )
  )

  Coordinates::Equatorial.new(
    right_ascension: apparent_right_ascension,
    declination: apparent_declination,
    epoch: @coordinates.epoch
  )
end