Class: Astronoby::Orientation

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

Overview

Wraps a binary PCK lunar orientation kernel (for example moon_pa_de440_200625.bpc) and exposes the rotation from the inertial frame (J2000/ICRF) to the Moon’s mean-Earth (ME) body-fixed frame at a given instant.

A binary kernel only provides the principal-axis (PA) orientation, and which PA frame it describes is read from the kernel itself. JPL Horizons and IMCCE report selenographic positions in the mean-Earth frame, whose small fixed offset from the principal axes is published in the NAIF lunar frame kernels (the moon_*.tf files) rather than in the binary kernel. That alignment is essentially constant across ephemeris versions (below 0.15 arcsecond), so the DE440 values are applied here.

Constant Summary collapse

MEAN_EARTH_ALIGNMENT =

Principal-axis to mean-Earth alignment from the NAIF DE440 lunar frame kernel (moon_de440_250416.tf): the rotation angles about the z, y and x axes that align the principal-axis frame with the mean-Earth frame.

[
  Angle.from_degree_arcseconds(67.8526),
  Angle.from_degree_arcseconds(78.6944),
  Angle.from_degree_arcseconds(0.2785)
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pck) ⇒ Orientation

Returns a new instance of Orientation.

Parameters:

  • pck (::Ephem::PCK)

    an opened binary PCK



48
49
50
51
52
53
54
# File 'lib/astronoby/orientation.rb', line 48

def initialize(pck)
  @pck = pck
  @source = orientation_source
  @mean_earth_rotation = mean_earth_rotation
  @start_jd = @pck.segments.map(&:start_jd).min
  @end_jd = @pck.segments.map(&:end_jd).max
end

Class Method Details

.download(name:, target:) ⇒ Boolean

Download a binary PCK orientation kernel.

Parameters:

  • name (String)

    kernel name supported by the Ephem gem

  • target (String)

    destination path

Returns:

  • (Boolean)

    true if the download was successful



34
35
36
# File 'lib/astronoby/orientation.rb', line 34

def self.download(name:, target:)
  ::Ephem::Download.call(name: name, target: target)
end

.load(target) ⇒ Astronoby::Orientation

Load a binary PCK orientation kernel.

Parameters:

  • target (String)

    path to the .bpc file

Returns:

Raises:



43
44
45
# File 'lib/astronoby/orientation.rb', line 43

def self.load(target)
  new(::Ephem::PCK.open(target))
end

Instance Method Details

#closevoid

This method returns an undefined value.



68
69
70
# File 'lib/astronoby/orientation.rb', line 68

def close
  @pck.close
end

#rotation_for(instant) ⇒ Matrix

Rotation from the inertial frame (J2000/ICRF) to the Moon’s mean-Earth body-fixed frame.

Parameters:

Returns:

  • (Matrix)

    a 3x3 rotation matrix

Raises:



63
64
65
# File 'lib/astronoby/orientation.rb', line 63

def rotation_for(instant)
  @mean_earth_rotation * principal_axis_rotation(instant)
end