Search in sources :

Example 61 with CircularOrbit

use of org.orekit.orbits.CircularOrbit in project Orekit by CS-SI.

the class Frames3 method main.

public static void main(String[] args) {
    try {
        // configure Orekit
        File home = new File(System.getProperty("user.home"));
        File orekitData = new File(home, "orekit-data");
        if (!orekitData.exists()) {
            System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
            System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
            System.exit(1);
        }
        DataProvidersManager manager = DataProvidersManager.getInstance();
        manager.addProvider(new DirectoryCrawler(orekitData));
        // Initial state definition :
        // ==========================
        // Date
        // ****
        AbsoluteDate initialDate = new AbsoluteDate(2003, 4, 7, 10, 55, 21.575, TimeScalesFactory.getUTC());
        // Orbit
        // *****
        // The Sun is in the orbital plane for raan ~ 202
        // gravitation coefficient
        double mu = 3.986004415e+14;
        // inertial frame
        Frame eme2000 = FramesFactory.getEME2000();
        Orbit orbit = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(220.), FastMath.toRadians(5.300), PositionAngle.MEAN, eme2000, initialDate, mu);
        // Attitude laws
        // *************
        // Earth
        Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame);
        // Target pointing attitude provider over satellite nadir at date, without yaw compensation
        NadirPointing nadirLaw = new NadirPointing(eme2000, earth);
        // Target pointing attitude provider with yaw compensation
        final PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
        YawSteering yawSteeringLaw = new YawSteering(eme2000, nadirLaw, sun, Vector3D.MINUS_I);
        // Propagator : Eckstein-Hechler analytic propagator
        Propagator propagator = new EcksteinHechlerPropagator(orbit, yawSteeringLaw, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
        // Let's write the results in a file in order to draw some plots.
        propagator.setMasterMode(10, new OrekitFixedStepHandler() {

            PrintStream out = null;

            public void init(SpacecraftState s0, AbsoluteDate t, double step) throws OrekitException {
                try {
                    File file = new File(System.getProperty("user.home"), "XYZ.dat");
                    System.out.println("Results written to file: " + file.getAbsolutePath());
                    out = new PrintStream(file, "UTF-8");
                    out.println("#time X Y Z Wx Wy Wz");
                } catch (IOException ioe) {
                    throw new OrekitException(ioe, LocalizedCoreFormats.SIMPLE_MESSAGE, ioe.getLocalizedMessage());
                }
            }

            public void handleStep(SpacecraftState currentState, boolean isLast) throws OrekitException {
                // get the transform from orbit/attitude reference frame to spacecraft frame
                Transform inertToSpacecraft = currentState.toTransform();
                // get the position of the Sun in orbit/attitude reference frame
                Vector3D sunInert = sun.getPVCoordinates(currentState.getDate(), currentState.getFrame()).getPosition();
                // convert Sun position to spacecraft frame
                Vector3D sunSat = inertToSpacecraft.transformPosition(sunInert);
                // and the spacecraft rotational rate also
                Vector3D spin = inertToSpacecraft.getRotationRate();
                // Lets calculate the reduced coordinates
                double sunX = sunSat.getX() / sunSat.getNorm();
                double sunY = sunSat.getY() / sunSat.getNorm();
                double sunZ = sunSat.getZ() / sunSat.getNorm();
                out.format(Locale.US, "%s %12.3f %12.3f %12.3f %12.7f %12.7f %12.7f%n", currentState.getDate(), sunX, sunY, sunZ, spin.getX(), spin.getY(), spin.getZ());
                if (isLast) {
                    out.close();
                }
            }
        });
        System.out.println("Running...");
        propagator.propagate(initialDate.shiftedBy(6000));
    } catch (OrekitException oe) {
        System.err.println(oe.getMessage());
    }
}
Also used : NadirPointing(org.orekit.attitudes.NadirPointing) PrintStream(java.io.PrintStream) Frame(org.orekit.frames.Frame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) IOException(java.io.IOException) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) DirectoryCrawler(org.orekit.data.DirectoryCrawler) YawSteering(org.orekit.attitudes.YawSteering) DataProvidersManager(org.orekit.data.DataProvidersManager) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) OrekitException(org.orekit.errors.OrekitException) Transform(org.orekit.frames.Transform) File(java.io.File) OrekitFixedStepHandler(org.orekit.propagation.sampling.OrekitFixedStepHandler)

Example 62 with CircularOrbit

use of org.orekit.orbits.CircularOrbit in project Orekit by CS-SI.

the class DSSTPropagation method createOrbit.

/**
 * Create an orbit from input parameters
 * @param parser input file parser
 * @param scale  time scale
 * @param mu     central attraction coefficient
 * @throws OrekitException if inertial frame cannot be retrieved
 * @throws NoSuchElementException if input parameters are missing
 * @throws IOException if input parameters are invalid
 */
private Orbit createOrbit(final KeyValueFileParser<ParameterKey> parser, final TimeScale scale, final double mu) throws OrekitException, NoSuchElementException, IOException {
    final Frame frame;
    if (!parser.containsKey(ParameterKey.INERTIAL_FRAME)) {
        frame = FramesFactory.getEME2000();
    } else {
        frame = parser.getInertialFrame(ParameterKey.INERTIAL_FRAME);
    }
    // Orbit definition
    Orbit orbit;
    PositionAngle angleType = PositionAngle.MEAN;
    if (parser.containsKey(ParameterKey.ORBIT_ANGLE_TYPE)) {
        angleType = PositionAngle.valueOf(parser.getString(ParameterKey.ORBIT_ANGLE_TYPE).toUpperCase());
    }
    if (parser.containsKey(ParameterKey.ORBIT_KEPLERIAN_A)) {
        orbit = new KeplerianOrbit(parser.getDouble(ParameterKey.ORBIT_KEPLERIAN_A) * 1000., parser.getDouble(ParameterKey.ORBIT_KEPLERIAN_E), parser.getAngle(ParameterKey.ORBIT_KEPLERIAN_I), parser.getAngle(ParameterKey.ORBIT_KEPLERIAN_PA), parser.getAngle(ParameterKey.ORBIT_KEPLERIAN_RAAN), parser.getAngle(ParameterKey.ORBIT_KEPLERIAN_ANOMALY), angleType, frame, parser.getDate(ParameterKey.ORBIT_DATE, scale), mu);
    } else if (parser.containsKey(ParameterKey.ORBIT_EQUINOCTIAL_A)) {
        orbit = new EquinoctialOrbit(parser.getDouble(ParameterKey.ORBIT_EQUINOCTIAL_A) * 1000., parser.getDouble(ParameterKey.ORBIT_EQUINOCTIAL_EX), parser.getDouble(ParameterKey.ORBIT_EQUINOCTIAL_EY), parser.getDouble(ParameterKey.ORBIT_EQUINOCTIAL_HX), parser.getDouble(ParameterKey.ORBIT_EQUINOCTIAL_HY), parser.getAngle(ParameterKey.ORBIT_EQUINOCTIAL_LAMBDA), angleType, frame, parser.getDate(ParameterKey.ORBIT_DATE, scale), mu);
    } else if (parser.containsKey(ParameterKey.ORBIT_CIRCULAR_A)) {
        orbit = new CircularOrbit(parser.getDouble(ParameterKey.ORBIT_CIRCULAR_A) * 1000., parser.getDouble(ParameterKey.ORBIT_CIRCULAR_EX), parser.getDouble(ParameterKey.ORBIT_CIRCULAR_EY), parser.getAngle(ParameterKey.ORBIT_CIRCULAR_I), parser.getAngle(ParameterKey.ORBIT_CIRCULAR_RAAN), parser.getAngle(ParameterKey.ORBIT_CIRCULAR_ALPHA), angleType, frame, parser.getDate(ParameterKey.ORBIT_DATE, scale), mu);
    } else if (parser.containsKey(ParameterKey.ORBIT_CARTESIAN_PX)) {
        final double[] pos = { parser.getDouble(ParameterKey.ORBIT_CARTESIAN_PX) * 1000., parser.getDouble(ParameterKey.ORBIT_CARTESIAN_PY) * 1000., parser.getDouble(ParameterKey.ORBIT_CARTESIAN_PZ) * 1000. };
        final double[] vel = { parser.getDouble(ParameterKey.ORBIT_CARTESIAN_VX) * 1000., parser.getDouble(ParameterKey.ORBIT_CARTESIAN_VY) * 1000., parser.getDouble(ParameterKey.ORBIT_CARTESIAN_VZ) * 1000. };
        orbit = new CartesianOrbit(new PVCoordinates(new Vector3D(pos), new Vector3D(vel)), frame, parser.getDate(ParameterKey.ORBIT_DATE, scale), mu);
    } else {
        throw new IOException("Orbit definition is incomplete.");
    }
    return orbit;
}
Also used : Frame(org.orekit.frames.Frame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) CircularOrbit(org.orekit.orbits.CircularOrbit) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) PositionAngle(org.orekit.orbits.PositionAngle) PVCoordinates(org.orekit.utils.PVCoordinates) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) IOException(java.io.IOException)

Example 63 with CircularOrbit

use of org.orekit.orbits.CircularOrbit in project Orekit by CS-SI.

the class SecularAndHarmonicTest method testSunSynchronization.

@Test
public void testSunSynchronization() throws OrekitException {
    int nbOrbits = 143;
    double mst = 10.5;
    // this test has been extracted from a more complete tutorial
    // on Low Earth Orbit phasing, which can be found in the tutorials
    // folder of the Orekit source distribution
    CircularOrbit initialGuessedOrbit = new CircularOrbit(7169867.824275421, 0.0, 0.0010289683741791197, FastMath.toRadians(98.5680307986701), FastMath.toRadians(-189.6132856166402), FastMath.PI, PositionAngle.TRUE, FramesFactory.getEME2000(), new AbsoluteDate(2003, 4, 5, utc), gravityField.getMu());
    final double[] initialMSTModel = fitGMST(initialGuessedOrbit, nbOrbits, mst);
    // the initial guess is very far from the desired phasing parameters
    Assert.assertTrue(FastMath.abs(mst - initialMSTModel[0]) * 3600.0 > 0.4);
    Assert.assertTrue(FastMath.abs(initialMSTModel[1]) * 3600 > 0.5 / Constants.JULIAN_DAY);
    CircularOrbit finalOrbit = new CircularOrbit(7173353.364197798, -3.908629707615073E-4, 0.0013502004064500472, FastMath.toRadians(98.56430772945006), FastMath.toRadians(-189.61151932993425), FastMath.PI, PositionAngle.TRUE, FramesFactory.getEME2000(), new AbsoluteDate(2003, 4, 5, utc), gravityField.getMu());
    final double[] finalMSTModel = fitGMST(finalOrbit, nbOrbits, mst);
    // the final orbit is much closer to the desired phasing parameters
    Assert.assertTrue(FastMath.abs(mst - finalMSTModel[0]) * 3600.0 < 0.0012);
    Assert.assertTrue(FastMath.abs(finalMSTModel[1]) * 3600 < 0.0004 / Constants.JULIAN_DAY);
}
Also used : CircularOrbit(org.orekit.orbits.CircularOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

CircularOrbit (org.orekit.orbits.CircularOrbit)63 AbsoluteDate (org.orekit.time.AbsoluteDate)47 Test (org.junit.Test)41 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)34 SpacecraftState (org.orekit.propagation.SpacecraftState)26 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)22 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)21 PVCoordinates (org.orekit.utils.PVCoordinates)21 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)20 Orbit (org.orekit.orbits.Orbit)20 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)15 Frame (org.orekit.frames.Frame)15 DateComponents (org.orekit.time.DateComponents)15 GeodeticPoint (org.orekit.bodies.GeodeticPoint)12 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)12 OrekitException (org.orekit.errors.OrekitException)11 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)11 ArrayList (java.util.ArrayList)9 Before (org.junit.Before)9 BoundedPropagator (org.orekit.propagation.BoundedPropagator)9