def from_classical(attractor, p, ecc, inc, raan, argp, nu, epoch=J2000): """Return `State` object from classical orbital elements. Parameters ---------- attractor : Body Main attractor. p : Quantity Semilatus rectum. ecc : Quantity Eccentricity. inc : Quantity Inclination raan : Quantity Right ascension of the ascending node. argp : Quantity Argument of the pericenter. nu : Quantity True anomaly. epoch : Time, optional Epoch, default to J2000. """ if not check_units((p, ecc, inc, raan, argp, nu), (u.m, u.one, u.rad, u.rad, u.rad, u.rad)): raise u.UnitsError("Units must be consistent") return poliastro.twobody.classical.ClassicalState( attractor, p, ecc, inc, raan, argp, nu, epoch)
def from_equinoctial(attractor, p, f, g, h, k, L, epoch=J2000): """Return `State` object from modified equinoctial elements. Parameters ---------- attractor : Body Main attractor. p : Quantity Semilatus rectum. f : Quantity Second modified equinoctial element. g : Quantity Third modified equinoctial element. h : Quantity Fourth modified equinoctial element. k : Quantity Fifth modified equinoctial element. L : Quantity True longitude. epoch : Time, optional Epoch, default to J2000. """ if not check_units((p, f, g, h, k, L), (u.m, u.one, u.rad, u.rad, u.rad, u.rad)): raise u.UnitsError("Units must be consistent") return poliastro.twobody.equinoctial.ModifiedEquinoctialState( attractor, p, f, g, h, k, L, epoch)
def parabolic(cls, attractor, p, inc, raan, argp, nu, epoch=J2000): """Return `State` corresponding to parabolic orbit. Parameters ---------- attractor : Body Main attractor. p : Quantity Semilatus rectum or parameter. inc : Quantity, optional Inclination. raan : Quantity Right ascension of the ascending node. argp : Quantity Argument of the pericenter. nu : Quantity True anomaly. epoch: Time, optional Epoch, default to J2000. """ if not check_units((p, inc, raan, argp, nu), (u.m, u.rad, u.rad, u.rad, u.rad)): raise u.UnitsError("Units must be consistent") ecc = 1.0 * u.one return cls.from_classical(attractor, p, ecc, inc, raan, argp, nu, epoch)
def circular(cls, attractor, alt, inc=0 * u.deg, raan=0 * u.deg, arglat=0 * u.deg, epoch=J2000): """Return `State` corresponding to a circular orbit. Parameters ---------- attractor : Body Main attractor. alt : Quantity Altitude over surface. inc : Quantity, optional Inclination, default to 0 deg (equatorial orbit). raan : Quantity, optional Right ascension of the ascending node, default to 0 deg. arglat : Quantity, optional Argument of latitude, default to 0 deg. epoch: Time, optional Epoch, default to J2000. """ if not check_units((alt, inc, raan, arglat), (u.m, u.rad, u.rad, u.rad)): raise u.UnitsError("Units must be consistent") a = attractor.R + alt ecc = 0 * u.one argp = 0 * u.deg return cls.from_classical(attractor, a, ecc, inc, raan, argp, arglat, epoch)
def __init__(self, *impulses): """Constructor. Parameters ---------- impulses : list List of pairs (delta_time, delta_velocity) Notes ----- TODO: Fix docstring, \*args convention """ self.impulses = impulses self._dts, self._dvs = zip(*impulses) u_times = check_units(self._dts, (u.s,)) u_dvs = check_units(self._dvs, (u.m / u.s,)) if not u_times or not u_dvs: raise u.UnitsError("Units must be consistent") try: if not all(len(dv) == 3 for dv in self._dvs): raise TypeError except TypeError: raise ValueError("Delta-V must be three dimensions vectors")
def from_vectors(attractor, r, v, epoch=J2000): """Return `State` object from position and velocity vectors. Parameters ---------- attractor : Body Main attractor. r : Quantity Position vector wrt attractor center. v : Quantity Velocity vector. epoch : Time, optional Epoch, default to J2000. """ if not check_units((r, v), (u.m, u.m / u.s)): raise u.UnitsError("Units must be consistent") assert np.any(r.value), "Position vector must be non zero" return poliastro.twobody.rv.RVState( attractor, r, v, epoch)
def __init__(self, k, name=None, symbol=None, R=0 * u.km): """Constructor. Parameters ---------- k : Quantity Standard gravitational parameter name : str, optional Name of the body, default to None. symbol : str, optional Symbol for the body, default to None. R : Quantity, optional Radius of the body, default to 0 km. """ if not check_units((k, R), (u.m ** 3 / u.s ** 2, u.m)): raise u.UnitsError("Units must be consistent") self.k = k self.name = name self.symbol = symbol self.R = R