layup.orbit_maths

Attributes

logger

ORBIT_FORMAT

REQUIRED_COLUMN_NAMES

PLANET_PERIOD_DAYS

Classes

ClassicalConic

Data class for each object conic section

Functions

convert_cart_to_classical_conic(→ ClassicalConic)

Convert cartesian elements into classical conic elements (L, e, i, Omega, omega)

rv_to_cart(→ numpy.ndarray)

Wrapper function to create structured array of cartesian elements from position+velocity state vectors

to_rv(→ tuple[numpy.ndarray, numpy.ndarray])

Convert orbits into cartesian state vectors regardless of format utilising Sorcha functions.

build_ephem_and_mus(→ tuple[assist.Ephem, float, float])

Create Assist instance utilising Layup functions in order to find standard gravitationl parameters

convert_sun_to_baryecliptic(→ tuple[numpy.ndarray, ...)

Function to create translation vectors to go from barycentric to heliocentric origins

prepopulate_orbit_variants(→ tuple[dict[tuple[str, ...)

Create an output cache of input object class instances, an empty placeholder dict for their

conic_lines_from_classical_conic(→ numpy.ndarray)

Given a set of classical conic elements (L, e, i, Omega, omega), draw the line of the orbit via

build_planet_lines_cache(→ tuple[dict[tuple[str, str], ...)

Module Contents

logger[source]
ORBIT_FORMAT[source]
REQUIRED_COLUMN_NAMES: dict[str, list[str]][source]
PLANET_PERIOD_DAYS[source]
class ClassicalConic[source]

Data class for each object conic section

obj_id: numpy.ndarray[source]

object identifer tag

L: numpy.ndarray[source]

object semilatus rectum (au)

e: numpy.ndarray[source]

object eccentricity

inc: numpy.ndarray[source]

object inclination (radians)

node: numpy.ndarray[source]

object longitude of ascending node (radians)

argp: numpy.ndarray[source]

object argument of perihelion (radians)

epochMJD_TDB: numpy.ndarray[source]

epoch of object observation (MJD TDB)

convert_cart_to_classical_conic(rows: numpy.ndarray, mu: float) ClassicalConic[source]

Convert cartesian elements into classical conic elements (L, e, i, Omega, omega)

Parameters:
  • rows (numpy structured array) – Array with all of the orbits (shape = (N,), i.e. one orbit per row/record)

  • mu (float) – Standard gravitional parameter (au^3 / day^2)

Returns:

ClassicalConic – Object instance containing N orbits and their classical elements

Return type:

object

rv_to_cart(obj_id: numpy.ndarray, r: numpy.ndarray, v: numpy.ndarray, epochMJD_TDB: numpy.ndarray) numpy.ndarray[source]

Wrapper function to create structured array of cartesian elements from position+velocity state vectors

Parameters:
  • obj_id (numpy string array) – Object identifier tags

  • r (numpy float array) – Object position state vector with shape (N, 3) (au)

  • v (numpy float array) – Object velocity state vector with shape (N, 3) (au/day)

  • epochMJD_TDB (numpy float array) – Object epoch with shape (N, 3) (MJD TDB)

Returns:

out – Array containing the cartesian elements (x,y,z,vx,vy,vz) with shape (N,)

Return type:

numpy structured array

to_rv(rows: numpy.ndarray, fmt: ORBIT_FORMAT, mu_sun: float, mu_total: float) tuple[numpy.ndarray, numpy.ndarray][source]

Convert orbits into cartesian state vectors regardless of format utilising Sorcha functions. Cometary/keplerian formats are converted using universal_cartesian()

Parameters:
  • rows (numpy structured array) – Array with all of the orbits (shape = (N,), i.e. one orbit per row/record)

  • fmt (str) – Format of the orbit. Must be one of “BCART”, “BCOM”, “BKEP”, “CART”, “COM”, “KEP”

  • mu_sun (float) – Standard (heliocentric) gravitional parameter (au^3 / day^2)

  • mu_total (float) – Standard (barycentric) gravitional parameter (au^3 / day^2)

Returns:

  • r (numpy float array) – Object position state vector with shape (N, 3) (au)

  • v (numpy float array) – Object velocity state vector with shape (N, 3) (au/day)

build_ephem_and_mus(cache_dir: str | None = None) tuple[assist.Ephem, float, float][source]

Create Assist instance utilising Layup functions in order to find standard gravitationl parameters

Parameters:

cache_dir (str, optional) – Cache directory containing Assist+Rebound files if used

Returns:

  • ephem (Assist object) – Assist instance containing the Sun, planets, and massive perturbers

  • mu_sun (float) – Standard (heliocentric) gravitional parameter (au^3 / day^2)

  • mu_total (float) – Standard (barycentric) gravitional parameter (au^3 / day^2)

convert_sun_to_baryecliptic(ephem: assist.Ephem, epochJD: numpy.ndarray) tuple[numpy.ndarray, numpy.ndarray][source]

Function to create translation vectors to go from barycentric to heliocentric origins

Parameters:
  • ephem (assist Ephem object) – Assist built ephemeris of the Sun, planets, and massive perturbers

  • epochJD (numpy float array) – Array of input object epochs in Julian dates of shape (N,)

Returns:

  • S_r (numpy float array) – Translation barycentric -> heliocentric position vector of shape (N,3)

  • S_v (numpy float array) – Translation barycentric -> heliocentric velocity vector of shape (N,3)

prepopulate_orbit_variants(rows: numpy.ndarray, orbit_format: ORBIT_FORMAT, input_plane: Literal['equatorial', 'ecliptic'], input_origin: Literal['heliocentric', 'barycentric']) tuple[dict[tuple[str, str], ClassicalConic], dict[tuple[str, str], numpy.ndarray], dict[tuple[str, str], numpy.ndarray], dict[tuple[str, str], numpy.ndarray]][source]

Create an output cache of input object class instances, an empty placeholder dict for their associated orbit lines, the Sun’s positions, and the object’s positions in all four combinations of plane+origin

Parameters:
  • rows (numpy structured array) – Array with all of the orbits (shape = (N,), i.e. one orbit per row/record)

  • orbit_format (str) – String detailing the input orbit format. Must be one of “BCART”, “BCOM”, “BKEP”, “CART”, “COM”, “KEP”

  • input_plane (str) – Input reference plane of the orbits. Must be one of “equatorial” or “ecliptic”

  • input_origin (str) – Input origin of the orbits. Must be one of “heliocentric” or “barycentric”

Returns:

  • canon_cache (dict of objects) – Dictionary with the conic section class instances of each object and their properties

  • lines_cache (dict of numpy array) – Dictionary of arrays with the orbit lines for each object in each plane+origin combination

  • sunpos_cache (dict of numpy array) – Dictionary of arrays with the Sun positions in each plane+origin combination

  • pos_cache (dict of numpy array) – Dictionary of arrays with object positions in each plane+origin combination

conic_lines_from_classical_conic(canon: ClassicalConic, n_points: int = 200, r_max: float = 50.0) numpy.ndarray[source]

Given a set of classical conic elements (L, e, i, Omega, omega), draw the line of the orbit via conic section (see page 27 onwards in “Solar System Dynamics” by Murray & Dermott)

Parameters:
  • canon (object) – Object instance containing N orbits and their classical elements

  • n_points (int, optional (default=200)) – Number of points to use to construct the line

  • r_max (float, optional (default=50.0 au)) – Maximum distance to render out to for hyperbolic orbits

Returns:

r – Object position state vector with shape (N, n_points, 3) (au)

Return type:

numpy float array

build_planet_lines_cache(ephem: assist.Ephem, epochJD_center: float, planet_names: list[str], n_points: int = 800) tuple[dict[tuple[str, str], numpy.ndarray], numpy.ndarray][source]
Parameters:
  • ephem (Assist object) – Assist instance containing the Sun, planets, and massive perturbers

  • epochJD_center (float) – Reference epoch to use to sample ellipse symmetrically over one orbtial period (JD)

  • planet_names (list) – List of planet names as strings

  • n_points (int, optional (default=800)) – Number of points to use to construct the line

Returns:

  • planet_lines_cache (dict of arrays) – Dictiionary of arrays containing planet orbit lines for each planet in each plane+origin combination of shape (n_planets, n_points, 3)

  • planet_id (numpy string array) – Array containing ID tags for each planet of shape (n_planets,)