-
-
Save jmontemayorm/7605d086fdc09acaa756e79c8c850bd3 to your computer and use it in GitHub Desktop.
TLE Generator from Ephemeris Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Orekit Libraries | |
import org.orekit.files.ccsds.*; | |
import org.orekit.propagation.analytical.tle.TLE; | |
import org.orekit.propagation.analytical.tle.TLEPropagator; | |
import org.orekit.propagation.conversion.FiniteDifferencePropagatorConverter; | |
import org.orekit.propagation.conversion.TLEPropagatorBuilder; | |
import org.orekit.time.*; | |
import org.orekit.data.*; | |
import org.orekit.orbits.*; | |
import org.orekit.propagation.*; | |
// Java Libraries | |
import java.io.*; | |
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
try { | |
// CONFIGURATION | |
File orekitData = new File("Libraries/orekit-data"); | |
DataProvidersManager manager = DataProvidersManager.getInstance(); | |
manager.addProvider(new DirectoryCrawler(orekitData)); | |
int launchNum = 12, launchYear = 2018; // Made up | |
OEMParser parser = new OEMParser(); | |
parser = parser.withInternationalDesignator(launchYear,launchNum,"UUU"); | |
OEMFile file = parser.parse("EphemerisData.oem"); | |
List<OEMFile.EphemeridesBlock> ephemeridesBlockList = file.getEphemeridesBlocks(); | |
OEMFile.EphemeridesBlock block = ephemeridesBlockList.get(0); | |
BoundedPropagator boundedPropagator = block.getPropagator(); | |
List<SpacecraftState> spacecraftStateList = new ArrayList<>(); | |
for (AbsoluteDate date = block.getStart(); date.compareTo(block.getStop()) <= 0; date = date.shiftedBy(60)) { | |
spacecraftStateList.add(boundedPropagator.propagate(date)); | |
} | |
// Data for the template TLE | |
KeplerianOrbit kOrbit = new KeplerianOrbit(spacecraftStateList.get(0).getOrbit()); | |
double pa = kOrbit.getPerigeeArgument(); | |
System.out.println("Perigee Argument: " + pa); | |
double raan = kOrbit.getRightAscensionOfAscendingNode(); | |
//double raan = Math.toRadians(10.0); | |
System.out.println("RAAN: " + Math.toDegrees(raan)); | |
double inc = spacecraftStateList.get(0).getI();//Math.toRadians(98.17); | |
System.out.println("Inc: " + Math.toDegrees(inc)); | |
double meanMotion = spacecraftStateList.get(0).getKeplerianMeanMotion(); | |
System.out.println("Mean motion: " + meanMotion); | |
AbsoluteDate epoch = spacecraftStateList.get(0).getDate(); | |
System.out.println("Epoch: " + epoch); | |
double eccentricity = spacecraftStateList.get(0).getOrbit().getE(); | |
double meanMotFirstDeriv = (spacecraftStateList.get(1).getKeplerianMeanMotion() - meanMotion) / 60; | |
System.out.println("Mean Motion 1st derivative: " + meanMotFirstDeriv); | |
double meanMotSecondDeriv = ((spacecraftStateList.get(2).getKeplerianMeanMotion() - | |
spacecraftStateList.get(1).getKeplerianMeanMotion()) / 60 - meanMotFirstDeriv) / 60; | |
System.out.println("Mean Motion 2nd derivative: " + meanMotSecondDeriv); | |
double meanAnomaly = kOrbit.getMeanAnomaly(); | |
System.out.println("Mean Anomaly: " + meanAnomaly); | |
System.out.println("Launch number: " + launchNum); | |
System.out.println("Launch year: " + launchYear); | |
FiniteDifferencePropagatorConverter converter = | |
new FiniteDifferencePropagatorConverter(new TLEPropagatorBuilder( | |
new TLE(99998,'U',launchYear,launchNum,"UUU", | |
2,1, epoch, meanMotion, | |
meanMotFirstDeriv,meanMotSecondDeriv,eccentricity,inc,pa, | |
raan,meanAnomaly,0,0), | |
PositionAngle.MEAN,1.0),0.01,6000000); | |
System.out.println("Calculating TLE..."); | |
TLEPropagator tlePropagator = (TLEPropagator) converter.convert(spacecraftStateList,false,"BSTAR"); | |
System.out.println(tlePropagator.getTLE()); | |
} catch (Exception e) { | |
System.out.println("Error: " + e); | |
} | |
} | |
} |
Hey,
Didi you find a solution for your problem? Is the code above runnable?
Hey,
Didi you find a solution for your problem? Is the code above runnable?
I think I did find a solution but I don't even remember the details of the problem I was having, this was 5 years ago... You can try to run it, but I wouldn't bet on it being correct.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This might help, this guy did exactly that (OEM -> TLE):
http://pictures.ed-morana.com/ISSTransits/predictions/ISSTransitPredictionDetails.html#OptionalData