Example #1
0
    def __init__(self,
                 s0,
                 dt,
                 epochs,
                 states,
                 elements=None,
                 interpolate=False,
                 **kwargs):
        default_names = [
            'dt',
            'epoch',
            'rx',
            'ry',
            'rz',
            'vx',
            'vy',
            'vz',
            'semi_major_axis',
            'eccentricity',
            'inclination',
            'ascending_node',
            'argument_of_periapsis',
            'true_anomaly',
        ]
        names = kwargs.get('names', default_names)
        self.interpolate = interpolate
        self.s0 = s0
        self._states = np.array(states)
        self.spline = interp1d(dt, self._states, kind='cubic')
        if interpolate:
            t = np.linspace(0.0, dt[-1], interpolate)
            epochs = s0.t + TimeDelta(t, format='sec')
            y = self.spline(t)
            rx = y[0, :] * s0.r.unit
            ry = y[1, :] * s0.r.unit
            rz = y[2, :] * s0.r.unit
            vx = y[3, :] * s0.v.unit
            vy = y[4, :] * s0.v.unit
            vz = y[5, :] * s0.v.unit
        else:
            rx, ry, rz, vx, vy, vz = self._states
            t = dt

        if not elements:
            elements = kepler.elements(
                s0.body.mu,
                np.array((rx, ry, rz)).T * s0.r.unit,
                np.array((vx, vy, vz)).T * s0.v.unit,
            )

        sma, ecc, inc, node, peri, ano = elements
        columns = [
            t, epochs, rx, ry, rz, vx, vy, vz, sma, ecc, inc, node, peri, ano
        ]
        self.table = Table(columns, names=names)
Example #2
0
    def __init__(
        self, s0, dt, epochs, states,
        elements=None, interpolate=False,
        **kwargs
    ):
        default_names = [
            'dt',
            'epoch',
            'rx',
            'ry',
            'rz',
            'vx',
            'vy',
            'vz',
            'semi_major_axis',
            'eccentricity',
            'inclination',
            'ascending_node',
            'argument_of_periapsis',
            'true_anomaly',
        ]
        names = kwargs.get('names', default_names)
        self.interpolate = interpolate
        self.s0 = s0
        self._states = np.array(states)
        self.spline = interp1d(dt, self._states, kind='cubic')
        if interpolate:
            t = np.linspace(0.0, dt[-1], interpolate)
            epochs = s0.t + TimeDelta(t, format='sec')
            y = self.spline(t)
            rx = y[0,:]*s0.r.unit
            ry = y[1,:]*s0.r.unit
            rz = y[2,:]*s0.r.unit
            vx = y[3,:]*s0.v.unit
            vy = y[4,:]*s0.v.unit
            vz = y[5,:]*s0.v.unit
        else:
            rx, ry, rz, vx, vy, vz = self._states
            t = dt

        if not elements:
            elements = kepler.elements(
                s0.body.mu,
                np.array((rx, ry, rz)).T*s0.r.unit,
                np.array((vx, vy, vz)).T*s0.v.unit,
            )

        sma, ecc, inc, node, peri, ano = elements
        columns = [t, epochs, rx, ry, rz, vx, vy, vz, sma, ecc, inc, node, peri, ano]
        self.table = Table(columns, names=names)
Example #3
0
 def elements(self):
     return kepler.elements(self.body.mu, self.r, self.v)
Example #4
0
 def elements(self):
     return kepler.elements(self.body.mu, self.r, self.v)