星历是指在GPS测量中,天体运行随时间而变的精确位置或轨迹表,它是时间的函数。Orekit提供的教程中提供了计算星历的方法。
注意,在使用Orekit库之前,我们需要读取Orekit文件,详细的读取步骤请移步下面的文章观看:
下面是使用Orekit进行卫星星历计算的具体步骤:
(1)定义卫星的轨道六根数
// Initial orbit parameters
final double a = 24396159; // semi major axis in meters
final double e = 0.72831215; // eccentricity
final double i = FastMath.toRadians(7); // inclination
final double omega = FastMath.toRadians(180); // perigee argument
final double raan = FastMath.toRadians(261); // right ascension of ascending node
final double lM = 0; // mean anomaly
(2)定义坐标系类型
// Inertial frame
final Frame inertialFrame = FramesFactory.getEME2000();
(3)定义初始时间
卫星星历的时间按世界标准时间(UTC)计算。
// Initial date in UTC time scale
final TimeScale utc = TimeScalesFactory.getUTC();
final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
(4)定义地球引力系数
// gravitation coefficient
final double mu = 3.986004415e+14;
(5)定义卫星轨道类型
// Orbit construction as Keplerian
final Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN,inertialFrame, initialDate, mu);
(6)定义卫星的初始状态
// Initialize state
final SpacecraftState initialState = new SpacecraftState(initialOrbit);
(7)定义propagator并插入到卫星上
final double stepSize = 10;
final AbstractIntegrator integrator = new ClassicalRungeKuttaIntegrator(stepSize);
final NumericalPropagator propagator = new NumericalPropagator(integrator);
// Set the propagator to ephemeris mode
final EphemerisGenerator generator = propagator.getEphemerisGenerator();
// Initialize propagation
propagator.setInitialState(initialState);
(8)计算并输出星历
// Propagation with storage of the results in an integrated ephemeris
final SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(6000));
System.out.format(Locale.US, "Numerical propagation:%n Final date: %s%n %s%n",finalState.getDate(), finalState.getOrbit());
// Getting the integrated ephemeris
final BoundedPropagator ephemeris = generator.getGeneratedEphemeris();
System.out.format(Locale.US, "%nEphemeris defined from %s to %s%n",ephemeris.getMinDate(),ephemeris.getMaxDate());
System.out.format(Locale.US, "%nEphemeris propagation:%n");
final String format = " %s %s%n";
AbsoluteDate intermediateDate = initialDate.shiftedBy(3000);
SpacecraftState intermediateState = ephemeris.propagate(intermediateDate);
System.out.format(Locale.US, format, intermediateState.getDate(), intermediateState.getOrbit());
intermediateDate = finalState.getDate();
intermediateState = ephemeris.propagate(intermediateDate);
System.out.format(Locale.US, format, intermediateState.getDate(), intermediateState.getOrbit());
intermediateDate = initialDate.shiftedBy(-1000);
System.out.format(Locale.US, "%nAttempting to propagate to date %s which is OUT OF RANGE%n",intermediateDate);
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 an exception should have been triggered
System.out.println(" date : " + intermediateState.getDate());
System.out.println(" " + intermediateState.getOrbit());
输出结果: