Utils#

Spice Utils#

pykep.utils.spice_version()#

Retrieves the installed version of the NAIF spice toolkit.

Returns:

string: SPICE toolbox version installed in the system.

pykep.utils.load_spice_kernels(paths)#

Loads one or more kernels for use with the NAIF spice toolkit.

Args:

paths (string or list): The path (or paths) of the kernels to load

pykep.utils.unload_spice_kernels(paths)#

Unloads from memory one or more kernels for use with the NAIF spice toolkit.

Args:

paths (string or list): The path (or paths) of the kernels to load

pykep.utils.inspect_spice_kernel(path)#

Detects the objects contained in a specific kernel. This is useful to understand the possibile queries to make for a certain kernel.

Args:

path (string): The path (or paths) of the kernels to load

Returns:

list: the NAIF ids of the objects found in the kernels.

pykep.utils.name2naifid(name)#

Retreives the NAIF id of some planet/comet/spacecraft

Args:

name (string): The name of the planet/comet/spacecraft to be found

Returns:

int the NAIF id of the the planet/comet/spacecraft

pykep.utils.framename2naifid(name)#

Retreives the NAIF id of some reference frame

Args:

name (string): The name of the reference frame to be found

Returns:

int the NAIF id of the reference frame

pykep.utils.rotation_matrix(origin, destination, ep=2000-01-01T00:00:00.000000)#

Rotation matrix between frames at epoch.

Args:

origin (string): The name of the origin reference frame.

destination (string): The name of the destination reference frame.

ep (epoch): Epoch. Defaults to pk.epoch(0).

Returns:

npumpy.ndarray: The rotation matrix.

pykep.utils.naifid2name(naifid)#

Retreives the planet/comet/spacecraft name from its NAIF id.

Args:

name (int): The NAIF id.

Returns:

string the name of the the planet/comet/spacecraft

Encoding Utils#

pykep.alpha2direct(alphas)#

Converts from alpha encoded to transfer times.

Args:

alphas (list): a sequence of transfer times encoded using the alpha encoding.

T (float): the total transfer time.

Returns:

list:: The encoded transfer times

pykep.direct2alpha(tofs)#

Converts from transfer times to alpha encoded.

Args:

tofs (list): a sequence of transfer times.

Returns:

list:, float: The alpha-encoded transfer times, the total transfer time (for cenvenience)

pykep.eta2direct(etas, max_tof)#

Converts from eta encoded to transfer times.

Args:

etas (list): a sequence of transfer times encoded using the eta encoding.

max_tof (float): maximum time of flight (might actually be less according to the value of the last eta.)

Returns:

list: The encoded transfer times

pykep.direct2eta(tofs, max_tof)#

Converts from transfer times to eta encoded.

Args:

tofs (list): a sequence of transfer times

max_tof (float): maximum time of flight (might actually be less according to the value of the last eta.)

Returns:

list: The eta-encoded transfer times

pykep.utils.uvV2cartesian(uvV)#

This function converts the uvV encoding of a vector to cartesian coordinates

Args:

uvV (array-like): a sequence of 3 floats representing the vector in uvV encoding.

Returns:

list:: The vector in cartesian coordinates

pykep.utils.cartesian2uvV(V)#

This function converts the cartesian coordinates of a vector to uvV encoding

Args:

V (array-like): a sequence of 3 floats representing the vector in cartesian coordinates.

Returns:

list:: The vector in uvV encoding

Miscellanea#

pykep.utils.planet_to_keplerian(pla, when: epoch, mu=None)#

Transforms a planet to its Keplerian version

The planet returned will be Keplerian, with elements identical to the osculating elements at t0 of the input planet. Hence its ephemerides can be computed at any epoch, but will only be matching the original ones at t0.

This utility is useful to extend the validity range of some planet’s ephemerides.

Args:

pla (planet): the input planet.

when (epoch): the epoch to match the osculating elements.

mu (float, optional): the central body parameter. Defaults to the one computed from the input planet.

Returns:

planet: a Keplerian planet.