Astro. Star
(ex_astro v0.3.0)
View Source
Propagate star-catalog entries and convert them to and from BCRS state vectors.
Catalog data remains caller-owned. Functions accept ICRS right ascension and
declination, proper motion, parallax, and radial velocity in the units used by
ERFA. Epochs are two-part TDB Julian Dates in the same {jd1, jd2} form as
Astro.Time.
ERFA warnings are returned as a third tuple element rather than discarded:
:distance_overriddenmeans ERFA increased the effective parallax because it was too small or the proper motion implied an unsafe transverse speed.:excessive_velocitymeans ERFA replaced an excessive velocity with zero.:no_convergencemeans the relativistic solution did not fully converge.
Example
iex> {:ok, state} =
...> Astro.Star.starpv(4.702817062, 0.081886079, -3.9e-6, 5.02e-5, 0.54831, -110.6)
iex> length(state)
6
Summary
Functions
Propagate a catalog entry between two TDB epochs using ERFA eraPmsafe.
Convert a BCRS position and velocity vector to catalog coordinates using
ERFA eraPvstar.
Convert a catalog entry to a BCRS position and velocity vector using ERFA
eraStarpv.
Types
@type state_vector() :: [float()]
@type warning() :: :distance_overridden | :excessive_velocity | :no_convergence
Functions
@spec pmsafe( float(), float(), float(), float(), float(), float(), julian_date(), julian_date() ) :: result(catalog_entry())
Propagate a catalog entry between two TDB epochs using ERFA eraPmsafe.
Input
raanddec- ICRS right ascension and declination in radians.pmr- rate of change of right ascension in radians per Julian year; this is the coordinate rate and is not multiplied bycos(dec).pmd- rate of change of declination in radians per Julian year.px- parallax in arcseconds.rv- radial velocity in km/s, positive when receding.ep1andep2- source and destination epochs as two-part TDB Julian Dates.
Output
{:ok, {ra2, dec2, pmr2, pmd2, px2, rv2}}on success.{:ok, entry, warnings}when ERFA adjusted input-derived data or the relativistic solution did not fully converge.{:error, reason}on failure.
Example
Propagate Barnard's Star from the Hipparcos epoch to J2000:
iex> result =
...> Astro.Star.pmsafe(
...> 4.702817062,
...> 0.081886079,
...> -3.9e-6,
...> 5.02e-5,
...> 0.54831,
...> -110.6,
...> {2_448_349.0625, 0.0},
...> {2_451_545.0, 0.0}
...> )
iex> match?({:ok, {_, _, _, _, _, _}}, result)
trueMore info at https://github.com/liberfa/erfa/blob/master/src/pmsafe.c
@spec pvstar(state_vector()) :: {:ok, catalog_entry()} | {:error, atom()}
Convert a BCRS position and velocity vector to catalog coordinates using
ERFA eraPvstar.
Input
pv-[x, y, z, vx, vy, vz], with position in au and velocity in au/day.
Output
{:ok, {ra, dec, pmr, pmd, px, rv}}with angles in radians, proper motions in radians per Julian year, parallax in arcseconds, and radial velocity in km/s.{:error, :superluminal_speed}when the supplied speed is at least the speed of light.{:error, :null_position_vector}when the position is zero.
Example
Round-trip Barnard's Star through a BCRS state vector:
iex> {:ok, state} =
...> Astro.Star.starpv(4.702817062, 0.081886079, -3.9e-6, 5.02e-5, 0.54831, -110.6)
iex> {:ok, catalog_entry} = Astro.Star.pvstar(state)
iex> tuple_size(catalog_entry)
6More info at https://github.com/liberfa/erfa/blob/master/src/pvstar.c
Convert a catalog entry to a BCRS position and velocity vector using ERFA
eraStarpv.
Input
raanddec- ICRS right ascension and declination in radians.pmrandpmd- right-ascension and declination proper motions in radians per Julian year.pmris not multiplied bycos(dec).px- parallax in arcseconds.rv- radial velocity in km/s, positive when receding.
Output
{:ok, [x, y, z, vx, vy, vz]}with position in au and velocity in au/day.{:ok, state, warnings}when ERFA adjusted input-derived data or the relativistic solution did not fully converge.{:error, reason}on failure.
Example
Convert Barnard's Star to a BCRS state vector:
iex> {:ok, state} =
...> Astro.Star.starpv(4.702817062, 0.081886079, -3.9e-6, 5.02e-5, 0.54831, -110.6)
iex> Enum.all?(state, &is_float/1)
trueMore info at https://github.com/liberfa/erfa/blob/master/src/starpv.c