How to use the spiceypy.spkez function in spiceypy

To help you get started, we’ve selected a few spiceypy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mkelley / mskpy / mskpy / ephem / state.py View on Github external
mu : float, optional
          `G M` of the primary body, or `None` to use the Sun.
        
        Returns
        -------
        orbit : dict
          Orbital parameters as a dictionary.

        """

        import astropy.units as u
        from mskpy.ephem import GM_sun
        from mskpy.util import jd2time

        et = core.date2et(date)
        state, lt = spice.spkez(self.naifid, et, frame, "NONE", 10)

        if mu is None:
            mu = GM_sun.to('km3 / s2').value

        o = spice.oscelt(state, et, mu)
        orbit = {}
        orbit['q'] = (o[0] * u.km).to(u.au)
        orbit['e'] = o[1]
        orbit['i'] = (o[2] * u.rad).to(u.deg)
        orbit['node'] = (o[3] * u.rad).to(u.deg)
        orbit['peri'] = (o[4] * u.rad).to(u.deg)
        orbit['n'] = (o[5] * u.rad).to(u.deg) / u.s
        orbit['t'] = jd2time(float(core.et2jd(o[6])))

        return orbit
github mkelley / mskpy / mskpy / ephem / state.py View on Github external
Position vector. [km]
        v : ndarray
          Velocity vector. [km/s]
       
        """

        from .. import util

        N = util.date_len(date)
        if N > 0:
            rv = tuple(zip(*(self.rv(d) for d in date)))
            return np.array(rv[0]), np.array(rv[1])

        et = core.date2et(date)
        # no light corrections, sun = 10
        state, lt = spice.spkez(self.naifid, et, frame, corr, observer)
        return np.array(state[:3]), np.array(state[3:])