Skip to content

DeepSkyObject without an ephemeris applies precession and nutation in the wrong order #313

Closed

Description

@rhannequin

Description

DeepSkyObjectPosition rotates the position by precession * nutation when no ephemeris is given, while Apparent.build_from_astrometric rotates by nutation * precession, which is what its comment says and what the IAU transformation does (N * PB).

The two orders differ by up to about 0.055 arcsecond, so the same star gets a slightly different apparent position depending on whether ephem: is passed. The velocity is rotated in the same wrong order.

The code is in compute_apparent, in lib/astronoby/bodies/deep_sky_object_position.rb:

precession_matrix * nutation_matrix * astrometric.position.map(&:m)

Reproduction Steps

require "astronoby"

instant = Astronoby::Instant.from_time(Time.utc(2026, 9, 24, 22))
sirius = Astronoby::Coordinates::Equatorial.new(
  right_ascension: Astronoby::Angle.from_hours(6.752),
  declination: Astronoby::Angle.from_degrees(-16.716)
)

apparent = Astronoby::DeepSkyObject
  .new(equatorial_coordinates: sirius)
  .at(instant)
  .apparent

direction = Vector[
  sirius.declination.cos * sirius.right_ascension.cos,
  sirius.declination.cos * sirius.right_ascension.sin,
  sirius.declination.sin
]
precession = Astronoby::Precession.matrix_for(instant)
nutation = Astronoby::Nutation.matrix_for(instant)

def separation(vector, other)
  vector = vector.normalize
  other = other.normalize
  Math.acos(vector.inner_product(other).clamp(-1, 1)) * 206_264.806
end

actual = Vector[*apparent.position.map(&:m)]

puts "nutation * precession: #{separation(actual, nutation * precession * direction).round(4)} arcsec"
puts "precession * nutation: #{separation(actual, precession * nutation * direction).round(4)} arcsec"

Expected behavior

The apparent position matches nutation * precession, as it does when an ephemeris is given.

Actual behavior

nutation * precession: 0.0364 arcsec
precession * nutation: 0.0 arcsec

System configuration

astronoby version: 0.10.0 (also on main)
ruby version: 3.4.4

Activity

  1. added
    bug
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions