States

Contents

States#

A collection of Chex dataclasses for representing the state of a system of particles.

class jorbit.utils.states.CartesianState(x, v, acceleration_func_kwargs, time_reference, relative_time=<factory>, cov=<factory>)[source]#

Bases: collections.abc.Mapping

Contains the barycentric state of a particle in Cartesian coordinates.

Time is represented as a (relative_time, time_reference) pair so the state is self-describing about its absolute epoch. See KeplerianState for the full convention.

Invariant: absolute_jd = relative_time + time_reference.

Parameters:
  • x (jax.Array)

  • v (jax.Array)

  • acceleration_func_kwargs (dict)

  • time_reference (float)

  • relative_time (float)

  • cov (jax.Array)

from_tuple()#
items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
replace(**kwargs)#
to_cartesian()[source]#

Convert to a Cartesian state.

Does nothing- this is already a Cartesian state. Included so that both KeplerianState and CartesianState have the same interface.

Return type:

CartesianState

to_keplerian()[source]#

Converts the Cartesian state to Keplerian elements.

Return type:

KeplerianState

to_system()[source]#

Converts the Cartesian state to a system state.

Both relative_time and time_reference are carried over unchanged, so the resulting SystemState is self-describing about its absolute epoch and acceleration functions can recover the absolute JD directly from relative_time + time_reference.

Return type:

SystemState

to_tuple()#
values() an object providing a view on D's values#
acceleration_func_kwargs: dict = <dataclasses._MISSING_TYPE object>#
cov: jax.Array = <dataclasses._MISSING_TYPE object>#
relative_time: float = <dataclasses._MISSING_TYPE object>#
time_reference: float = <dataclasses._MISSING_TYPE object>#
v: jax.Array = <dataclasses._MISSING_TYPE object>#
x: jax.Array = <dataclasses._MISSING_TYPE object>#
class jorbit.utils.states.IAS15IntegratorState(g, b, e, csx, csv, a0, dt, dt_last_done)[source]#

Bases: collections.abc.Mapping

Contains the state of the IAS15 integrator.

Parameters:
  • g (jax.Array)

  • b (jax.Array)

  • e (jax.Array)

  • csx (jax.Array)

  • csv (jax.Array)

  • a0 (jax.Array)

  • dt (float)

  • dt_last_done (float)

from_tuple()#
items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
replace(**kwargs)#
to_tuple()#
values() an object providing a view on D's values#
a0: jax.Array = <dataclasses._MISSING_TYPE object>#
b: jax.Array = <dataclasses._MISSING_TYPE object>#
csv: jax.Array = <dataclasses._MISSING_TYPE object>#
csx: jax.Array = <dataclasses._MISSING_TYPE object>#
dt: float = <dataclasses._MISSING_TYPE object>#
dt_last_done: float = <dataclasses._MISSING_TYPE object>#
e: jax.Array = <dataclasses._MISSING_TYPE object>#
g: jax.Array = <dataclasses._MISSING_TYPE object>#
class jorbit.utils.states.KeplerianState(semi, ecc, inc, Omega, omega, nu, acceleration_func_kwargs, time_reference, relative_time=<factory>, cov=<factory>)[source]#

Bases: collections.abc.Mapping

Contains the barycentric state of a particle in Keplerian elements.

Angles are in degrees. Elements will not agree with those presented in a heliocentric frame.

Time is represented as a (relative_time, time_reference) pair so the state is self-describing about its absolute epoch:

  • relative_time is the offset (in days) that flows through to SystemState.relative_time and is the quantity the integrator marches forward.

  • time_reference is the absolute JD (TDB) anchor that relative_time is measured against. It flows through to SystemState.time_reference; acceleration functions recover the absolute JD as relative_time + time_reference. Particle.__init__ reads the same sum to set the particle’s reference epoch.

Invariant: absolute_jd = relative_time + time_reference.

Parameters:
  • semi (float)

  • ecc (float)

  • inc (float)

  • Omega (float)

  • omega (float)

  • nu (float)

  • acceleration_func_kwargs (dict)

  • time_reference (float)

  • relative_time (float)

  • cov (jax.Array)

from_tuple()#
items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
replace(**kwargs)#
to_cartesian()[source]#

Converts the Keplerian state to Cartesian coordinates.

Return type:

CartesianState

to_keplerian()[source]#

Convert to a Keplerian state.

Does nothing- this is already a Keplerian state. Included so that both KeplerianState and CartesianState have the same interface.

Return type:

KeplerianState

to_system()[source]#

Converts the Keplerian state to a system state.

Both relative_time and time_reference are carried over unchanged, so the resulting SystemState is self-describing about its absolute epoch and acceleration functions can recover the absolute JD directly from relative_time + time_reference.

Return type:

SystemState

to_tuple()#
values() an object providing a view on D's values#
Omega: float = <dataclasses._MISSING_TYPE object>#
acceleration_func_kwargs: dict = <dataclasses._MISSING_TYPE object>#
cov: jax.Array = <dataclasses._MISSING_TYPE object>#
ecc: float = <dataclasses._MISSING_TYPE object>#
inc: float = <dataclasses._MISSING_TYPE object>#
nu: float = <dataclasses._MISSING_TYPE object>#
omega: float = <dataclasses._MISSING_TYPE object>#
relative_time: float = <dataclasses._MISSING_TYPE object>#
semi: float = <dataclasses._MISSING_TYPE object>#
time_reference: float = <dataclasses._MISSING_TYPE object>#
class jorbit.utils.states.LeapfrogIntegratorState(dt, C, D)[source]#

Bases: collections.abc.Mapping

Contains the state of a leapfrog integrator.

Parameters:
  • dt (float)

  • C (jax.Array)

  • D (jax.Array)

from_tuple()#
items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
replace(**kwargs)#
to_tuple()#
values() an object providing a view on D's values#
C: jax.Array = <dataclasses._MISSING_TYPE object>#
D: jax.Array = <dataclasses._MISSING_TYPE object>#
dt: float = <dataclasses._MISSING_TYPE object>#
class jorbit.utils.states.SystemState(tracer_positions, tracer_velocities, massive_positions, massive_velocities, log_gms, time_reference, relative_time, fixed_perturber_positions, fixed_perturber_velocities, fixed_perturber_log_gms, acceleration_func_kwargs)[source]#

Bases: collections.abc.Mapping

Contains the state of a system of particles.

Time is represented as the same (relative_time, time_reference) pair used by CartesianState and KeplerianState, so the state is self-describing about its absolute epoch:

  • time_reference is the absolute JD (TDB) anchor.

  • relative_time is the offset in days from time_reference. This is the quantity the integrator marches forward (keeping step/interpolation arithmetic well-conditioned at decadal timescales); time_reference is carried along unchanged.

Invariant: absolute_jd = relative_time + time_reference. Acceleration functions that query an ephemeris recover the absolute JD from this sum, so no external t_ref_jd offset is needed.

Parameters:
  • tracer_positions (jax.Array)

  • tracer_velocities (jax.Array)

  • massive_positions (jax.Array)

  • massive_velocities (jax.Array)

  • log_gms (jax.Array)

  • time_reference (float)

  • relative_time (float)

  • fixed_perturber_positions (jax.Array)

  • fixed_perturber_velocities (jax.Array)

  • fixed_perturber_log_gms (jax.Array)

  • acceleration_func_kwargs (dict)

from_tuple()#
items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
replace(**kwargs)#
to_tuple()#
values() an object providing a view on D's values#
acceleration_func_kwargs: dict = <dataclasses._MISSING_TYPE object>#
fixed_perturber_log_gms: jax.Array = <dataclasses._MISSING_TYPE object>#
fixed_perturber_positions: jax.Array = <dataclasses._MISSING_TYPE object>#
fixed_perturber_velocities: jax.Array = <dataclasses._MISSING_TYPE object>#
log_gms: jax.Array = <dataclasses._MISSING_TYPE object>#
massive_positions: jax.Array = <dataclasses._MISSING_TYPE object>#
massive_velocities: jax.Array = <dataclasses._MISSING_TYPE object>#
relative_time: float = <dataclasses._MISSING_TYPE object>#
time_reference: float = <dataclasses._MISSING_TYPE object>#
tracer_positions: jax.Array = <dataclasses._MISSING_TYPE object>#
tracer_velocities: jax.Array = <dataclasses._MISSING_TYPE object>#
jorbit.utils.states.barycentric_to_heliocentric(state, time, de_ephemeris_version='440')[source]#

Helper to compute heliocentric quantities from barycentric states.

Use the local copy of JPL DE440 to query the state vector of the Sun at the given time.

Parameters:
  • state (CartesianState | KeplerianState) – CartesianState or KeplerianState The barycentric state to convert.

  • time (Time) – astropy.time.Time The time at which to compute the heliocentric elements.

  • de_ephemeris_version (str) – str The version of the JPL DE ephemeris to use. Defaults to “440”, accepts “430”.

Returns:

A dictionary containing heliocentric quantities. If the input state is Cartesian, returns ‘x_helio’ and ‘v_helio’. If Keplerian, returns ‘a_helio’, ‘ecc_helio’, ‘inc_helio’, ‘Omega_helio’, ‘omega_helio’, and ‘nu_helio’.

Return type:

dict

jorbit.utils.states.heliocentric_to_barycentric(heliocentric_dict, time, de_ephemeris_version='440', acceleration_func_kwargs={'c2': 29979.063823897617})[source]#

Helper to compute barycentric quantities from heliocentric states.

Use the local copy of JPL DE440 to query the state vector of the Sun at the given time.

Parameters:
  • heliocentric_dict (dict) – dict A dictionary containing heliocentric quantities. If the input state is Cartesian, must contain ‘x_helio’ and ‘v_helio’. If Keplerian, must contain ‘a_helio’, ‘ecc_helio’, ‘inc_helio’, ‘Omega_helio’, ‘omega_helio’, and ‘nu_helio’.

  • time (Time) – astropy.time.Time The time at which to compute the barycentric elements.

  • de_ephemeris_version (str) – str The version of the JPL DE ephemeris to use. Defaults to “440”, accepts “430”.

  • acceleration_func_kwargs (dict) – dict Additional arguments to associate with the final CartesianState or KeplerianState. Defaults to {“c2”: SPEED_OF_LIGHT**2}.

Returns:

The barycentric state. If the input dict had Cartesian quantities, returns a CartesianState. If the inputs were Keplerian, returns a KeplerianState.

Return type:

CartesianState | KeplerianState