I have implemented this function, but the time in the generated TLE is the same as that in the TLE I initialized. Theoretically, the time in the generated TLE should be the satellite epoch time in the Kepler orbital six. I don’t know how to handle it.The following is my code.
final Frame inertialFrame = FramesFactory.getEME2000();
final double mu = 3.986004415e+14;
final TimeScale utc = TimeScalesFactory.getUTC();
final AbsoluteDate initialDate = new AbsoluteDate(2025, 4, 22, 17, 25, 51.000, utc);
final double a = 6897586.00027699; // (m)
final double e = 0.00168422;
final double i = FastMath.toRadians(50.09689978); // (°)
final double argOfPerigee = FastMath.toRadians(63.04929148); // (°)
final double raan = FastMath.toRadians(47.69225896); // (°)
final double meanAnomaly = FastMath.toRadians(69.80204972); // (°)
final Orbit kepOrbit = new KeplerianOrbit(a, e, i, argOfPerigee, raan, meanAnomaly, PositionAngleType.MEAN, inertialFrame, initialDate, mu);
KeplerianPropagator p = new KeplerianPropagator(kepOrbit);
// p.resetInitialState(new SpacecraftState(kepOrbit));
List<SpacecraftState> sample = new ArrayList<>();
double duration = 86400.0; // (s)
double stepSize = 60.0; // (s)
for (double dt = 0; dt < duration; dt += stepSize) {
sample.add(p.propagate(kepOrbit.getDate().shiftedBy(dt)));
}
//TLE
TLE inputTle = new TLE("1 58758U 24009A 25112.76781922 .00021437 00000+0 11120-2 0 9994",
"2 58758 49.9946 47.7572 0007453 35.6899 324.4550 15.16019077 71005");
TLE tleTempalte = new TLE(inputTle.getSatelliteNumber(),
inputTle.getClassification(),
inputTle.getLaunchYear(),
inputTle.getLaunchNumber(),
inputTle.getLaunchPiece(),
inputTle.getEphemerisType(),
inputTle.getElementNumber(),
inputTle.getDate(),
inputTle.getMeanMotion(),
0.0,
0.0,
inputTle.getE(),
inputTle.getI(),
inputTle.getPerigeeArgument(),
inputTle.getRaan(),
inputTle.getMeanAnomaly(),
0,
0); //bBtar
TLEPropagatorBuilder builder = new TLEPropagatorBuilder(tleTempalte, PositionAngleType.TRUE, 1.0,
new FixedPointTleGenerationAlgorithm(1e-10, 100, 1.0, DataContext.getDefault().getTimeScales().getUTC(),
DataContext.getDefault().getFrames().getTEME()));
double threshold = 1.0e-3;
FiniteDifferencePropagatorConverter tleFitter = new FiniteDifferencePropagatorConverter(builder, threshold, 1000);
tleFitter.convert(sample, true, "BSTAR");
TLEPropagator tleProp = (TLEPropagator) tleFitter.getAdaptedPropagator();
TLE outputTLE = tleProp.getTLE();
System.out.println(outputTLE);