Пример #1
0
def get_keplerian_parameters(spacecraft_state, anomaly_type="TRUE"):
    """
	Given a SpaceCraftState object this function computes the keplerian orbit parameters
    Note: parameter values may change but they'll define the same orbit
	Args:
		spacecraft_state (SpaceCraftState): SpaceCraftState orekit object that has an orbit attribute
        anomaly_type (string; "MEAN" or "TRUE"): tells to return true or mean anomaly, defaults to TRUE
	Returns:
		dict: dictionary of parameters containg eccentricity, semimajor_axis, inclination, perigee argument, right
		ascension of ascending node, anomaly, anomaly_type, and orbit_update_date
    """
    parameters = dict()
    new_orbit = KeplerianOrbit(spacecraft_state.getOrbit())

    parameters["semimajor_axis"] = new_orbit.getA()
    parameters["eccentricity"] = new_orbit.getE()
    parameters["inclination"] = new_orbit.getI()
    parameters["perigee_argument"] = new_orbit.getPerigeeArgument()
    parameters[
        "right_ascension_of_ascending_node"] = new_orbit.getRightAscensionOfAscendingNode(
        )
    parameters["orbit_update_date"] = new_orbit.getDate().toString()
    parameters["frame"] = frame_to_string(spacecraft_state.getFrame())
    if (anomaly_type == "MEAN"):
        parameters["anomaly"] = new_orbit.getMeanAnomaly()
        parameters["anomaly_type"] = "MEAN"
    else:
        parameters["anomaly"] = new_orbit.getTrueAnomaly()
        parameters["anomaly_type"] = "TRUE"
    return parameters
Пример #2
0
def validate_rv2coe():
    # Orbit initial state vectors
    rx_0, ry_0, rz_0 = -6045.0e3, -3490.0e3, 2500.0e3
    vx_0, vy_0, vz_0 = -3.457e3, 6.618e3, 2.533e3

    # Build the initial Orekit orbit
    k = C.IAU_2015_NOMINAL_EARTH_GM
    r0_vec = Vector3D(rx_0, ry_0, rz_0)
    v0_vec = Vector3D(vx_0, vy_0, vz_0)
    rv_0 = PVCoordinates(r0_vec, v0_vec)
    epoch_00 = AbsoluteDate.J2000_EPOCH
    gcrf_frame = FramesFactory.getGCRF()
    ss0_orekit = KeplerianOrbit(rv_0, gcrf_frame, epoch_00, k)

    # Build poliastro orbit
    r0_vec = [rx_0, ry_0, rz_0] * u.m
    v0_vec = [vx_0, vy_0, vz_0] * u.m / u.s
    ss0_poliastro = Orbit.from_vectors(Earth, r0_vec, v0_vec)

    # Orekit bounds COE angular magnitudes between [-pi, +pi]. Let us define a
    # converter function to map values between [0, +2pi]
    def unbound_angle(angle):
        """ Bound angle between [0, +2pi] """
        if -np.pi <= angle <= 0.0:
            angle += 2 * np.pi

        return angle

    # Map angles
    orekit_raan = unbound_angle(ss0_orekit.getRightAscensionOfAscendingNode())
    orekit_argp = unbound_angle(ss0_orekit.getPerigeeArgument())
    orekit_nu = unbound_angle(ss0_orekit.getTrueAnomaly())

    # Assert classical orbital elements
    assert_quantity_allclose(ss0_poliastro.a,
                             ss0_orekit.getA() * u.m,
                             rtol=1e-6)
    assert_quantity_allclose(ss0_poliastro.ecc,
                             ss0_orekit.getE() * u.one,
                             rtol=1e-6)
    assert_quantity_allclose(ss0_poliastro.inc,
                             ss0_orekit.getI() * u.rad,
                             rtol=1e-6)
    assert_quantity_allclose(ss0_poliastro.raan,
                             orekit_raan * u.rad,
                             rtol=1e-6)
    assert_quantity_allclose(ss0_poliastro.argp,
                             orekit_argp * u.rad,
                             rtol=1e-6)
    assert_quantity_allclose(ss0_poliastro.nu, orekit_nu * u.rad, rtol=1e-6)
Пример #3
0
    def osc_elems_transformation_ore(self, other, dir):

        self._orekit_lock.acquire()

        self.load_orekit()

        KepOrbElem.vm.attachCurrentThread()

        utc = TimeScalesFactory.getUTC()

        orekit_date = AbsoluteDate(2017, 1, 1, 12, 1, 1.0, utc)
        inertialFrame = FramesFactory.getEME2000()
        a = float(other.a)
        e = float(other.e)
        i = float(other.i)
        w = float(other.w)
        O = float(other.O)
        v = float(other.v)

        initialOrbit = KeplerianOrbit(a * 1000.0, e, i, w, O, v,
                                      PositionAngle.TRUE, inertialFrame,
                                      orekit_date, Constants.mu_earth * 1e9)

        initialState = SpacecraftState(initialOrbit, 1.0)

        #zonal_forces= DSSTZonal(provider,2,1,5)
        zonal_forces = DSSTZonal(KepOrbElem.provider, 6, 4, 6)
        forces = ArrayList()
        forces.add(zonal_forces)
        try:
            equinoctial = None
            if dir:

                equinoctial = DSSTPropagator.computeMeanState(
                    initialState, None, forces)
            else:

                equinoctial = DSSTPropagator.computeOsculatingState(
                    initialState, None, forces)

            newOrbit = KeplerianOrbit(equinoctial.getOrbit())

            self.a = newOrbit.getA() / 1000.0
            self.e = newOrbit.getE()
            self.i = newOrbit.getI()
            self.w = newOrbit.getPerigeeArgument()
            self.O = newOrbit.getRightAscensionOfAscendingNode()
            self.v = newOrbit.getAnomaly(PositionAngle.TRUE)

            # correct ranges

            if self.i < 0:
                self.i += 2 * np.pi

            if self.w < 0:
                self.w += 2 * np.pi

            if self.O < 0:
                self.O += 2 * np.pi

            if self.v < 0:
                self.v += 2 * np.pi

        finally:
            self._orekit_lock.release()