Search in sources :

Example 16 with DirectoryCrawler

use of org.orekit.data.DirectoryCrawler in project Orekit by CS-SI.

the class EphemerisMode method main.

/**
 * Program entry point.
 * @param args program arguments (unused here)
 */
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 orbit parameters
        // semi major axis in meters
        double a = 24396159;
        // eccentricity
        double e = 0.72831215;
        // inclination
        double i = FastMath.toRadians(7);
        // perigee argument
        double omega = FastMath.toRadians(180);
        // right ascension of ascending node
        double raan = FastMath.toRadians(261);
        // mean anomaly
        double lM = 0;
        // Inertial frame
        Frame inertialFrame = FramesFactory.getEME2000();
        // Initial date in UTC time scale
        TimeScale utc = TimeScalesFactory.getUTC();
        AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
        // gravitation coefficient
        double mu = 3.986004415e+14;
        // Orbit construction as Keplerian
        Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu);
        // Initialize state
        SpacecraftState initialState = new SpacecraftState(initialOrbit);
        // Numerical propagation with no perturbation (only Keplerian movement)
        // Using a very simple integrator with a fixed step: classical Runge-Kutta
        // the step is ten seconds
        double stepSize = 10;
        AbstractIntegrator integrator = new ClassicalRungeKuttaIntegrator(stepSize);
        NumericalPropagator propagator = new NumericalPropagator(integrator);
        // Set the propagator to ephemeris mode
        propagator.setEphemerisMode();
        // Initialize propagation
        propagator.setInitialState(initialState);
        // Propagation with storage of the results in an integrated ephemeris
        SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(6000));
        System.out.println(" Numerical propagation :");
        System.out.println("  Final date : " + finalState.getDate());
        System.out.println("  " + finalState.getOrbit());
        // Getting the integrated ephemeris
        BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
        System.out.println(" Ephemeris defined from " + ephemeris.getMinDate() + " to " + ephemeris.getMaxDate());
        System.out.println(" Ephemeris propagation :");
        AbsoluteDate intermediateDate = initialDate.shiftedBy(3000);
        SpacecraftState intermediateState = ephemeris.propagate(intermediateDate);
        System.out.println("  date :  " + intermediateState.getDate());
        System.out.println("  " + intermediateState.getOrbit());
        intermediateDate = finalState.getDate();
        intermediateState = ephemeris.propagate(intermediateDate);
        System.out.println("  date :  " + intermediateState.getDate());
        System.out.println("  " + intermediateState.getOrbit());
        intermediateDate = initialDate.shiftedBy(-1000);
        System.out.println();
        System.out.println("Attempting to propagate to date " + intermediateDate + " which is OUT OF RANGE");
        System.out.println("This propagation attempt should fail, " + "so an error message shoud appear below, " + "this is expected and shows that errors are handled correctly");
        intermediateState = ephemeris.propagate(intermediateDate);
        // these two print should never happen as en exception should have been triggered
        System.out.println("  date :  " + intermediateState.getDate());
        System.out.println("  " + intermediateState.getOrbit());
    } catch (OrekitException oe) {
        System.out.println(oe.getMessage());
    }
}
Also used : Frame(org.orekit.frames.Frame) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) ClassicalRungeKuttaIntegrator(org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) AbstractIntegrator(org.hipparchus.ode.AbstractIntegrator) DirectoryCrawler(org.orekit.data.DirectoryCrawler) DataProvidersManager(org.orekit.data.DataProvidersManager) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) File(java.io.File) BoundedPropagator(org.orekit.propagation.BoundedPropagator)

Example 17 with DirectoryCrawler

use of org.orekit.data.DirectoryCrawler in project Orekit by CS-SI.

the class MasterMode method main.

/**
 * Program entry point.
 * @param args program arguments (unused here)
 */
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));
        // gravitation coefficient
        double mu = 3.986004415e+14;
        // inertial frame
        Frame inertialFrame = FramesFactory.getEME2000();
        // Initial date
        AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
        // Initial orbit
        // semi major axis in meters
        double a = 24396159;
        // eccentricity
        double e = 0.72831215;
        // inclination
        double i = FastMath.toRadians(7);
        // perigee argument
        double omega = FastMath.toRadians(180);
        // right ascention of ascending node
        double raan = FastMath.toRadians(261);
        // mean anomaly
        double lM = 0;
        Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu);
        // Initial state definition
        SpacecraftState initialState = new SpacecraftState(initialOrbit);
        // Adaptive step integrator with a minimum step of 0.001 and a maximum step of 1000
        final double minStep = 0.001;
        final double maxstep = 1000.0;
        final double positionTolerance = 10.0;
        final OrbitType propagationType = OrbitType.KEPLERIAN;
        final double[][] tolerances = NumericalPropagator.tolerances(positionTolerance, initialOrbit, propagationType);
        AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxstep, tolerances[0], tolerances[1]);
        // Propagator
        NumericalPropagator propagator = new NumericalPropagator(integrator);
        propagator.setOrbitType(propagationType);
        // Force Model (reduced to perturbing gravity field)
        final NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(10, 10);
        ForceModel holmesFeatherstone = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider);
        // Add force model to the propagator
        propagator.addForceModel(holmesFeatherstone);
        // Set up initial state in the propagator
        propagator.setInitialState(initialState);
        // Set up operating mode for the propagator as master mode
        // with fixed step and specialized step handler
        propagator.setMasterMode(60., new TutorialStepHandler());
        // Extrapolate from the initial to the final date
        SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(630.));
        KeplerianOrbit o = (KeplerianOrbit) OrbitType.KEPLERIAN.convertType(finalState.getOrbit());
        System.out.format(Locale.US, "Final state:%n%s %12.3f %10.8f %10.6f %10.6f %10.6f %10.6f%n", finalState.getDate(), o.getA(), o.getE(), FastMath.toDegrees(o.getI()), FastMath.toDegrees(o.getPerigeeArgument()), FastMath.toDegrees(o.getRightAscensionOfAscendingNode()), FastMath.toDegrees(o.getTrueAnomaly()));
    } catch (OrekitException oe) {
        System.err.println(oe.getMessage());
    }
}
Also used : Frame(org.orekit.frames.Frame) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) Orbit(org.orekit.orbits.Orbit) ForceModel(org.orekit.forces.ForceModel) AdaptiveStepsizeIntegrator(org.hipparchus.ode.nonstiff.AdaptiveStepsizeIntegrator) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) DirectoryCrawler(org.orekit.data.DirectoryCrawler) DataProvidersManager(org.orekit.data.DataProvidersManager) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrbitType(org.orekit.orbits.OrbitType) OrekitException(org.orekit.errors.OrekitException) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) HolmesFeatherstoneAttractionModel(org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel) File(java.io.File)

Example 18 with DirectoryCrawler

use of org.orekit.data.DirectoryCrawler in project Orekit by CS-SI.

the class VisibilityCircle method main.

/**
 * Program entry point.
 * @param args program arguments
 */
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));
        // input/out
        File input = new File(VisibilityCircle.class.getResource("/visibility-circle.in").toURI().getPath());
        File output = new File(input.getParentFile(), "visibility-circle.csv");
        new VisibilityCircle().run(input, output, ",");
        System.out.println("visibility circle saved as file " + output);
    } catch (URISyntaxException use) {
        System.err.println(use.getLocalizedMessage());
        System.exit(1);
    } catch (IOException ioe) {
        System.err.println(ioe.getLocalizedMessage());
        System.exit(1);
    } catch (IllegalArgumentException iae) {
        System.err.println(iae.getLocalizedMessage());
        System.exit(1);
    } catch (OrekitException oe) {
        System.err.println(oe.getLocalizedMessage());
        System.exit(1);
    }
}
Also used : DirectoryCrawler(org.orekit.data.DirectoryCrawler) DataProvidersManager(org.orekit.data.DataProvidersManager) OrekitException(org.orekit.errors.OrekitException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) File(java.io.File)

Aggregations

File (java.io.File)18 DataProvidersManager (org.orekit.data.DataProvidersManager)18 DirectoryCrawler (org.orekit.data.DirectoryCrawler)18 OrekitException (org.orekit.errors.OrekitException)17 AbsoluteDate (org.orekit.time.AbsoluteDate)12 IOException (java.io.IOException)9 Frame (org.orekit.frames.Frame)9 Orbit (org.orekit.orbits.Orbit)8 SpacecraftState (org.orekit.propagation.SpacecraftState)7 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)6 URISyntaxException (java.net.URISyntaxException)5 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)5 TimeScale (org.orekit.time.TimeScale)5 ParseException (java.text.ParseException)4 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)4 Propagator (org.orekit.propagation.Propagator)4 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)4 PVCoordinates (org.orekit.utils.PVCoordinates)4 BodyShape (org.orekit.bodies.BodyShape)3 GeodeticPoint (org.orekit.bodies.GeodeticPoint)3