Orbis.Ephemeris (Orbis v0.7.0)

Copy Markdown View Source

JPL SPK/BSP ephemeris file reader.

Computes positions of solar system bodies (Sun, Moon, planets) using JPL Development Ephemeris files (DE421, DE440, etc.) in SPK/BSP format.

These files contain Chebyshev polynomial coefficients that are evaluated to produce high-precision positions in km.

Example

eph = Orbis.Ephemeris.load("de421.bsp")
{x, y, z} = Orbis.Ephemeris.position(eph, :sun, :earth, ~U[2024-01-01 12:00:00Z])

Body Names

Supported body atoms: :ssb (Solar System Barycenter), :mercury, :venus, :earth_moon_barycenter (or :emb), :mars, :jupiter, :saturn, :uranus, :neptune, :pluto, :sun, :moon, :earth.

Summary

Functions

Load an SPK/BSP ephemeris file.

Compute the position of target relative to observer at the given time.

Types

t()

@type t() :: %Orbis.Ephemeris{path: String.t()}

Functions

load(path)

@spec load(String.t()) :: t()

Load an SPK/BSP ephemeris file.

Returns an ephemeris handle that can be passed to position/4. The file is not held open; it is read on each position/4 call.

Example

eph = Orbis.Ephemeris.load("/path/to/de421.bsp")

position(ephemeris, target, observer, datetime, opts \\ [])

@spec position(
  t(),
  atom() | integer(),
  atom() | integer(),
  DateTime.t() | NaiveDateTime.t() | float(),
  keyword()
) :: {float(), float(), float()}

Compute the position of target relative to observer at the given time.

Returns {x, y, z} in km in the J2000/ICRF reference frame.

The target and observer are body atoms (see module docs) or NAIF integer codes.

The datetime can be a DateTime, a NaiveDateTime, or a Julian Date (TDB) as a float.

Options

  • :skyfield_compat - when true, replicates Skyfield's exact VectorSum accumulation order for bit-identical (0 ULP) parity. Default false uses direct common-ancestor subtraction which is more numerically precise.

Examples

# Default (precise)
{x, y, z} = Orbis.Ephemeris.position(eph, :moon, :earth, datetime)

# Skyfield-compatible (0 ULP oracle test)
{x, y, z} = Orbis.Ephemeris.position(eph, :moon, :earth, datetime, skyfield_compat: true)