Post · 9 min read· pp. 54–59

User defined planets (UDPLAs)

Basic

class pykep.udpla.null_udpla : A moot udpla used as default to construct a planet.

class pykep.udpla.keplerian(when, elem, mu_central_body, name='unknown', added_params=[-1, -1, -1], elem_type=KEP_F) : keplerian udpla

code
Constructs a Keplerian udpla from its orbital elements at epoch.

Args:
:   *when* ([`epoch`](/u/cc87604183a08dd4#pykep-epoch)): the epoch at which the orbital elements are provided.

    *elem* ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) or [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)): the orbital elements. by default.

    *mu\_central\_body* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): the gravitational parameter of the main attracting body.

    *name* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)): the name of the orbiting body.

    *added\_params* ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)): the body gravitational parameter, its radius and its safe radius. (if -1 they are assumed unknown)

    *el\_type* ([`el_type`](/u/1a5d072eab184871#pykep-el-type)): the elements type. Defaults to osculating Keplerian (a ,e ,i, W, w, f) with true anomaly.

Examples:
:   ```default

import pykep as pk elem = [1, 0, 0, 0, 0, 0] when = pk.epoch("2025-03-22") udpla = pk.udpla.keplerian(when = when, elem = elem, mu_central_body =1, name = "my_pla") pla = pk.planet(udpla)

code

    **Alternative Constructor:**
    :   \_\_init\_\_(ep, posvel, mu\_central\_body, name = “unknown”, added\_params = [-1,-1,-1])

    Constructs a Keplerian udpla from its position and velocity at epoch.

    Args:
    :   *ep* ([`epoch`](/u/cc87604183a08dd4#pykep-epoch)): the epoch at which the orbital elements are provided.

        *posvel* ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) [[`list`](https://docs.python.org/3/builtins/stdtypes.html#list), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)]): the body position and velocty.

        *mu\_central\_body* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): the gravitational parameter of the main attracting body.

        *name* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)): the name of the orbiting body.

        *added\_params* ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)): the body gravitational parameter, its radius and its safe radius. (if -1 they are assumed unknown)

    Examples:
    :   ```default
>>> import pykep as pk
>>> r = [1, 0, 0]
>>> v = [0, 1, 0]
>>> ep = pk.epoch("2025-03-22")
>>> udpla = pk.udpla.keplerian(ep = ep, posvel = [r, v], mu_central_body =1, name = "my_pla")
>>> pla = pk.planet(udpla)

class pykep.udpla.jpl_lp(name='earth') : Low precision ephemerides from JPL for the solar system planets

code
Constructs a solar system planet with ephemerides computed using a low-precision (non Keplerian)
model from JPL (<https://ssd.jpl.nasa.gov/planets/approx_pos.html>).

Args:
:   *name* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)): the name of the solar system planet.

Examples:
:   ```default

import pykep as pk udpla = pk.udpla.jpl_lp(name="mercury") pla = pk.planet(udpla)

code

    get\_radius()
    :   The planet’s radius.
        The planet’s radius.

    *property* radius
    :   The planet’s radius.

    *property* safe\_radius
    :   The planet’s safe radius. Mostly used to constraint fly-by distances.

    set\_safe\_radius()
    :   Set the planet’s safe radius. Mostly used to constraint fly-by distances.

# Advanced

*class* pykep.udpla.vsop2013(*body='mercury'*, *thresh=1e-5*)
:   Analytical planetary ephemerides from the VSOP2013 theory

    Constructs a solar system planet with ephemerides computed using the VSOP2013 analytical
    theory (<https://en.wikipedia.org/wiki/VSOP_model>).

    Args:
    :   *body* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)): the name of the solar system planet.

        *thresh* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): the truncation threshold for the theory’s coefficients.

    Examples:
    :   ```default
>>> import pykep as pk
>>> udpla = pk.udpla.vsop2013(body="venus")
>>> pla = pk.planet(udpla)

class pykep.udpla.tle(line1, line2) : This User Defined Planet (UDPLA) represents a satellite orbiting the Earth and defined in the TLE format and propagated using the SGP4 propagator.

code
Args:
:   *line1* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)): The first line of a TLE

    *line2* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)): The second line of a TLE

Note

The resulting ephemerides will be returned in SI units and in the True Equator Mean Equinox (TEME) reference frame

Examples:
:   ```default

import pykep as pk line1 = "1 33773U 97051L 23290.57931959 .00002095 00000+0 65841-3 0 9991" line2 = "2 33773 86.4068 33.1145 0009956 224.5064 135.5336 14.40043565770064" udpla = pk.udpla.tle(line1, line2) pla = pk.planet(udpla) pla.eph(pk.epoch("2023-10-31"))

code

    eph(*mjd2000*)
    :   Mandatory method of the [`planet`](/u/b8b3c9975f4a752a#pykep-planet) interface.

        Args:
        :   *mjd2000* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): Modified Julian Date 2000.

        Returns:
        :   [`list`](https://docs.python.org/3/builtins/stdtypes.html#list) [[`list`](https://docs.python.org/3/builtins/stdtypes.html#list), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)]: the planet ephemerides.

    eph\_v(*mjd2000s*)
    :   Optional method of the [`planet`](/u/b8b3c9975f4a752a#pykep-planet) interface.

        Args:
        :   *mjd2000s* (array-like (1,)): Modified Julian Dates 2000.

        Returns:
        :   `ndarray`: the planet ephemerides as an array of dimension (-1,6)

    get\_extra\_info()
    :   Optional method of the [`planet`](/u/b8b3c9975f4a752a#pykep-planet) interface.

        Returns:
        :   [`str`](https://docs.python.org/3/builtins/stdtypes.html#str): Extra info on the udpla

    get\_mu\_central\_body()
    :   Optional method of the [`planet`](/u/b8b3c9975f4a752a#pykep-planet) interface.

        Returns:
        :   [`float`](https://docs.python.org/3/builtins/functions.html#float): the graviational parameter of the Earth.

    get\_name()
    :   Optional method of the [`planet`](/u/b8b3c9975f4a752a#pykep-planet) interface.

        Returns:
        :   [`str`](https://docs.python.org/3/builtins/stdtypes.html#str): The body name

*class* pykep.udpla.spice(*body*, *ref\_frame*, *obs*)
:   This User Defined Planet (UDPLA) represents a planet/object/spacecraft as defined by a pre-loaded
    SPICE kernel. The interface to the NAIF SPICE code is provided via the third-party python package called
    spiceypy: <https://spiceypy.readthedocs.io/en/stable/>

    The resulting ephemerides will be returned in SI units and in the selected reference frame (J2000 ECLIPTIC by default).

    Note

    SPICE kernels containing interesting objects can be, for example, found at:
    <https://naif.jpl.nasa.gov/naif/data_archived.html> -> Spacecarft from NAIF
    <https://ssd.jpl.nasa.gov/ftp/eph/planets/bsp/> -> Solar System planets
    <https://www.cosmos.esa.int/web/spice> -> ESA missions

    Warning

    The utility function [`load_spice_kernels()`](/u/8bfab171801f80b3#pykep-utils-load-spice-kernels) must be called to pre-load into
    memory the necessary SPICE kernels. Else, the call to the [`eph()`](#pykep.udpla.spice.eph) method will
    fail rising an exception.

    <a id="pykep.udpla.spice.eph"></a> eph(*mjd2000*)
    :   Mandatory method of the [`planet`](/u/b8b3c9975f4a752a#pykep-planet) interface.

        Args:
        :   *mjd2000* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): Modified Julian Date 2000

        Returns:
        :   [`list`](https://docs.python.org/3/builtins/stdtypes.html#list) [[`list`](https://docs.python.org/3/builtins/stdtypes.html#list), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)]: the planet ephemerides.

    get\_extra\_info()
    :   Optional method of the [`planet`](/u/b8b3c9975f4a752a#pykep-planet) interface.

        Returns:
        :   [`str`](https://docs.python.org/3/builtins/stdtypes.html#str): Extra info on the udpla

    get\_name()
    :   Optional method of the [`planet`](/u/b8b3c9975f4a752a#pykep-planet) interface.

        Returns:
        :   [`str`](https://docs.python.org/3/builtins/stdtypes.html#str): The body name

*class* pykep.udpla.de440s(*body='EARTH BARYCENTER'*, *ref\_frame='ECLIPJ2000'*, *obs='SSB'*)
:   This User Defined Planet (UDPLA) represents a solar system planet as described by JPL 440s ephemerides.
    The correct spice kernel is preloaded upon instantiation of the class as its shipped with the pykep module.

    Args:
    :   *body* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)): NAIF name of the solar system body. Defaults to: “EARTH BARYCENTER”.

        *ref\_frame* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)): NAIF name of the reference frame. For example: “ECLIPJ2000”.

        *obs* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)): NAIF name of the observer. For example: “SSB” (solar system barycenter).

    body\_list()
    :   The list of bodies contained in the de440s ephemerides.
        This is a static method and can be queried before constructing the object.

        Returns:
        :   [`list`](https://docs.python.org/3/builtins/stdtypes.html#list): The list of possible body names.

    get\_name()
    :   Optional method of the [`planet`](/u/b8b3c9975f4a752a#pykep-planet) interface.

        Returns:
        :   [`str`](https://docs.python.org/3/builtins/stdtypes.html#str): The body name

    kernel\_file()
    :   The full path for the kernel file “de440s.bsp” shipped in pykep

        Returns:
        :   [`str`](https://docs.python.org/3/builtins/stdtypes.html#str): The full file name.

*class* pykep.udpla.cr3bp(*when*, *state\_nd*, *mu\_cr3bp*, *TIME*, *L*, *name=None*, *tol=1e-16*)
:   User-defined planet-like interface for a CR3BP reference trajectory.

    This UDPLA exposes a simple planet-like interface backed by a CR3BP
    integrator. It returns ephemerides in SI units consistent with the
    length/time scales supplied at construction, and implements the
    optional `acc` method required by gradient-enabled problems.

    Args:
    :   *when* ([`float`](https://docs.python.org/3/builtins/functions.html#float) or [`pykep.epoch`](/u/cc87604183a08dd4#pykep-epoch)): Reference epoch (MJD2000) for the provided
        :   reference state. If a [`pykep.epoch`](/u/cc87604183a08dd4#pykep-epoch) is provided, its `mjd2000` value is used.

        *state\_nd* ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list) or [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)): Reference 6D state in non-dimensional
        :   CR3BP units used to initialize the internal integrator: `[x,y,z,vx,vy,vz]`.

        *mu\_cr3bp* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): The CR3BP mass parameter (non-dimensional).

        *TIME* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): Time scale (non-dimensional seconds) used to convert between
        :   MJD2000/seconds and the integrator’s internal time units.

        *L* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): Length scale used to map integrator positions to SI units.

        *name* ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), optional): Human-readable name for the UDPLA. If omitted a default
        :   descriptive name containing `mu_cr3bp` is assigned.

        *tol* ([`float`](https://docs.python.org/3/builtins/functions.html#float), optional): Tolerance passed to the internal Taylor adaptive integrator.

    acc(*mjd2000*)
    :   Return acceleration from the CR3BP dynamics at the requested epoch.

        Args:
        :   *mjd2000* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): Epoch in MJD2000 days.

        Returns:
        :   [`list`](https://docs.python.org/3/builtins/stdtypes.html#list) or [`numpy.ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray): Acceleration at the epoch, returned in SI units (meters/second^2).

    eph(*mjd2000*)
    :   Return position and velocity at the requested epoch.

        Args:
        :   *mjd2000* ([`float`](https://docs.python.org/3/builtins/functions.html#float)): Epoch in MJD2000 days.

        Returns:
        :   [`list`](https://docs.python.org/3/builtins/stdtypes.html#list) [[`list`](https://docs.python.org/3/builtins/stdtypes.html#list), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)]: Position and velocity in SI units (meters, meters/second).

    get\_extra\_info()
    :   Return a short string with extra information about the UDPLA.

        Typically includes the reference state and epoch used to initialize the integrator.

    get\_name()
    :   Return the human-readable name for this UDPLA.