[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orekit Users] Converting a State Vector to a TLE



Thank you,

I think I have it working properly now, though I might need to tweak some
parameters. Here is what I have at the moment: (sorry, I do not know how to
post it nicely)


            //setup initial osculating orbit, where posVelTeme is the position
and velocity in TEME and epoch is the time of posVelTeme
            KeplerianOrbit initialOrbit = new KeplerianOrbit(posVelTeme,
                    FramesFactory.getTEME(), epoch, Constants.WGS84_EARTH_MU);

            SpacecraftState initialState = new SpacecraftState(initialOrbit);

            Frame teme = FramesFactory.getTEME();
            final double minStep = 0.001;
            final double maxStep = 500;
            final double positionTolerance = 1;
            final OrbitType type = OrbitType.KEPLERIAN;
            final double stepSize = 600; //600 sec == 10 min
            final double duration = 345600; // 345600 sec == 4 days
            final double threshold = 0.0001;
            final boolean positionOnly = false;
            final int maxIterations = 10000;

            //setup numerical propagator
            double[][] tol = NumericalPropagator.tolerances(positionTolerance,
initialOrbit, type);
            AdaptiveStepsizeIntegrator integrator =
                    new DormandPrince853Integrator(minStep, maxStep, tol[0],
tol[1]);
            NumericalPropagator numericalPropagator = new
NumericalPropagator(integrator);
            numericalPropagator.setOrbitType(type);
            numericalPropagator.setInitialState(initialState);

            OneAxisEllipsoid earth = new
OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
                    Constants.WGS84_EARTH_FLATTENING, teme);
            ForceModel gravityField = new
HolmesFeatherstoneAttractionModel(earth.getBodyFrame(),
                    GravityFieldFactory.getNormalizedProvider(8, 8));
            numericalPropagator.addForceModel(gravityField);

            //take samples of propagation
            List<SpacecraftState> sample = new ArrayList<SpacecraftState>();

            for (double dt = 0; dt < duration; dt += stepSize) {

sample.add(numericalPropagator.propagate(epoch.shiftedBy(dt)));
            }

            //fit TLE to the samples.
            PropagatorBuilder builder = new TLEPropagatorBuilder(0, 'U', 0, 0,
"A", 0, 0);

            FiniteDifferencePropagatorConverter fitter = new
FiniteDifferencePropagatorConverter(builder, threshold, maxIterations);
            Collection<String> freeParameters =
fitter.getAvailableParameters();

            fitter.convert(sample, positionOnly, freeParameters);

            TLEPropagator prop = (TLEPropagator)fitter.getAdaptedPropagator();

            //The final TLE
            TLE fitted = prop.getTLE();


From what I have tested so far, it does better with more circular orbits. Let
me know if you see anything wrong, if not then this can serve as an example in
case someone else has the same question later on.

Thanks again,
Matt