Ejemplo n.º 1
0
    def __init__(self, attractor, a, e, inc, raan, argp, theta=None, **kwargs):
        """
        .. py:class:: ClassicalState()
        Two-body problem classical state representation, to be inherited by other state representations. Attractor must
        be defined as the geometry of the state is only transformable to another representation given the constant mu.
        :param attractor:
        :param a:
        :param e:
        :param inc:
        :param raan:
        :param argp:
        :param theta:

        """
        super().__init__(attractor)
        self._a = a
        self._e = e
        self._inc = inc
        self._raan = raan
        self._argp = argp
        if theta is not None:
            self._theta = theta
        else:
            try:
                print(kwargs["M"])
                self._theta = OrbitalExpressions().theta(
                    self._e.value, kwargs["M"].si.value) * u.rad
            except KeyError:
                raise SystemError(
                    "If theta is not defined then M must be for instantiation of ClassicalState."
                )
Ejemplo n.º 2
0
 def E(self):
     """
     :return: <astropy.units.Quantity> Eccentric anomaly (E)
     """
     try:
         E = OrbitalExpressions().E(self.e.value,
                                    theta=self.theta.value) * u.rad
     except AttributeError:
         E = OrbitalExpressions().E(self.e.value, M=self.M.value) * u.rad
     return formatting.positive_angle(E.si.value) * u.rad
Ejemplo n.º 3
0
 def tau(self, time_now=None):
     """
     :return: <astropy.units.Quantity> Time of periapsis passage (τ)
     """
     # TODO: Determine the time system to be used. (consider use of astropy.time.Time(scale=tdb))
     return OrbitalExpressions().tau(time_now, self.e, self.theta,
                                     self._attractor.mu, self.a) * u.s
Ejemplo n.º 4
0
 def r_a(self):
     """
     :return: <astropy.units.Quantity> Radius of apoapsis (r_a)
     """
     return OrbitalExpressions().r_a(
         self.a.to(u.m).value,
         self.e.to(u.dimensionless_unscaled).value) * u.m
Ejemplo n.º 5
0
 def r_p(self):
     """
     :return: <astropy.units.Quantity> Radius of periapsis (r_p)
     """
     # TODO: Add an error exception/catch for Hyperbolic & Parabolic orbits.
     return OrbitalExpressions().r_p(
         self.a.to(u.m).value,
         self.e.to(u.dimensionless_unscaled).value) * u.m
Ejemplo n.º 6
0
 def M(self):
     """
     :return: <astropy.units.Quantity> Mean anomaly (M)
     """
     return OrbitalExpressions().M(self.e.value, self.theta.value) * u.rad
Ejemplo n.º 7
0
class ClassicalState(BaseState):
    def __init__(self, attractor, a, e, inc, raan, argp, theta=None, **kwargs):
        """
        .. py:class:: ClassicalState()
        Two-body problem classical state representation, to be inherited by other state representations. Attractor must
        be defined as the geometry of the state is only transformable to another representation given the constant mu.
        :param attractor:
        :param a:
        :param e:
        :param inc:
        :param raan:
        :param argp:
        :param theta:

        """
        super().__init__(attractor)
        self._a = a
        self._e = e
        self._inc = inc
        self._raan = raan
        self._argp = argp
        if theta is not None:
            self._theta = theta
        else:
            try:
                print(kwargs["M"])
                self._theta = OrbitalExpressions().theta(
                    self._e.value, kwargs["M"].si.value) * u.rad
            except KeyError:
                raise SystemError(
                    "If theta is not defined then M must be for instantiation of ClassicalState."
                )

    # Property overrides ----------------------------------------------------------------------------------------------#
    @property
    def a(self):
        """
        .. py:method:: a
        :return: <astropy.units.Quantity> Semi-major axis (a)
        """
        return self._a

    @property
    def e(self):
        """
        :return: <astropy.units.Quantity> Eccentricity (e)
        """
        return self._e

    @property
    def inc(self):
        """
        :return: <astropy.units.Quantity> Inclination angle (i)
        """
        return self._inc

    @property
    def raan(self):
        """
        :return: <astropy.units.Quantity> Right ascension of ascending node (Ω)
        """
        return self._raan

    @property
    def argp(self):
        """
        :return: <astropy.units.Quantity> Argument of periapsis (ω)
        """
        return self._argp

    @property
    def theta(self):
        """
        :return: <astropy.units.Quantity> True anomaly (θ)
        """
        return self._theta

    # Method updates --------------------------------------------------------------------------------------------------#
    def to_vectors(self):
        r, v = classical2vector(
            self._a.to(u.m).value,
            self._e.to(u.dimensionless_unscaled).value,
            self._inc.to(u.rad).value,
            self._raan.to(u.rad).value,
            self._argp.to(u.rad).value,
            self._theta.to(u.rad).value,
            self._attractor.mu.to(u.m**3 / u.s / u.s).value)
        return vector.VectorState(self._attractor, r * u.m, v * u.m / u.s)

    def to_spherical(self):
        r, ra, de, v, fpa, azi = vector2spherical(*classical2vector(
            self._a.to(u.m).value,
            self._e.to(u.dimensionless_unscaled).value,
            self._inc.to(u.rad).value,
            self._raan.to(u.rad).value,
            self._argp.to(u.rad).value,
            self._theta.to(u.rad).value,
            self._attractor.mu.to(u.m**3 / u.s / u.s).value))
        return spherical.SphericalState(self._attractor, r * u.m, ra * u.rad,
                                        de * u.rad, v * u.m / u.s, fpa * u.rad,
                                        azi * u.rad)

    def to_classical(self):
        return self