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 (
stringorlist): 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 (
stringorlist): 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:
intthe NAIF id of the the planet/comet/spacecraft
- pykep.utils.extract_coverage_window(path, naifid, window_n=0)#
Extracts the n-th SPK coverage window for a given NAIF ID and returns it as PyKEP epochs.
The SPK coverage start/end times returned by SPICE are ET (TDB) seconds past J2000. Here we map them to a uniform seconds-from-2000-01-01T00:00:00 (UTC-labeled origin) representation, so that the resulting PyKEP epoch is strictly 1:1 with ET everywhere (this is not “UTC elapsed seconds” with leap seconds).
The offset constant 43135.816087188054 [s] is ET0 = str2et(“2000-01-01 00:00:00 UTC”), i.e. the ET value of the UTC-labeled origin of pykep mjd2000; thus mjd2000_days = (et - ET0) / 86400, implemented as (et + 43135.816087188054) * SEC2DAY.
- pykep.utils.epoch2utc(pykep_epoch)#
Converts a PyKEP epoch (mjd2000) into a SPICE-formatted UTC calendar string.
The input epoch is assumed to be a uniform time variable expressed as days since the UTC-labeled origin 2000-01-01 00:00:00 (i.e. strictly 1:1 with SPICE ET everywhere; it is not “UTC elapsed seconds” with leap seconds).
The constant 43135.816087188054 [s] is ET0 = str2et(“2000-01-01 00:00:00 UTC”). We first reconstruct the ET value via et = mjd2000*86400 - ET0, then use SPICE et2utc to obtain the UTC calendar representation. A leapseconds kernel is loaded to enable correct ET↔UTC conversion.
- Args:
pykep_epoch (
pk.epoch): PyKEP epoch whose .mjd2000 is days since 2000-01-01 00:00:00 (UTC-labeled origin).- Returns:
string: UTC calendar string corresponding to the input epoch.
- 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:
intthe 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.
Encoding Utils#
- pykep.alpha2direct(alphas)#
Converts from alpha encoded to transfer times.
- pykep.direct2alpha(tofs)#
Converts from transfer times to alpha encoded.
- pykep.eta2direct(etas, max_tof)#
Converts from eta encoded to transfer times.
- pykep.direct2eta(tofs, max_tof)#
Converts from transfer times to eta encoded.
Miscellanea#
- pykep.utils.planet_to_keplerian(pla, when: epoch, mu=None)#
Transforms a planet to its Keplerian version
The
planetreturned 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.