use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class KeplerianPropagatorTest method testIssue107.
@Test
public void testIssue107() throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
final Orbit orbit = new CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, mu);
Propagator propagator = new KeplerianPropagator(orbit) {
private static final long serialVersionUID = 1L;
AbsoluteDate lastDate = AbsoluteDate.PAST_INFINITY;
protected SpacecraftState basicPropagate(final AbsoluteDate date) throws OrekitException {
if (date.compareTo(lastDate) < 0) {
throw new OrekitException(LocalizedCoreFormats.SIMPLE_MESSAGE, "no backward propagation allowed");
}
lastDate = date;
return super.basicPropagate(date);
}
};
SpacecraftState finalState = propagator.propagate(date.shiftedBy(3600.0));
Assert.assertEquals(3600.0, finalState.getDate().durationFrom(date), 1.0e-15);
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class KeplerianPropagatorTest method testIssue224.
@Test
public void testIssue224() throws OrekitException, IOException, ClassNotFoundException {
// Inertial frame
Frame inertialFrame = FramesFactory.getEME2000();
// Initial date
TimeScale utc = TimeScalesFactory.getUTC();
AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
// Central attraction coefficient
double mu = 3.986004415e+14;
// Initial orbit
// semi major axis in meters
double a = 42100;
// eccentricity
double e = 0.01;
// inclination
double i = FastMath.toRadians(6);
// 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);
// Propagator
KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit, new LofOffset(inertialFrame, LOFType.VVLH));
propagator.addAdditionalStateProvider(new SevenProvider());
propagator.setEphemerisMode();
// Impulsive burn 1
final AbsoluteDate burn1Date = initialState.getDate().shiftedBy(200);
ImpulseManeuver<DateDetector> impulsiveBurn1 = new ImpulseManeuver<DateDetector>(new DateDetector(burn1Date), new Vector3D(1000, 0, 0), 320);
propagator.addEventDetector(impulsiveBurn1);
// Impulsive burn 2
final AbsoluteDate burn2Date = initialState.getDate().shiftedBy(300);
ImpulseManeuver<DateDetector> impulsiveBurn2 = new ImpulseManeuver<DateDetector>(new DateDetector(burn2Date), new Vector3D(1000, 0, 0), 320);
propagator.addEventDetector(impulsiveBurn2);
propagator.propagate(initialState.getDate().shiftedBy(400));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(propagator.getGeneratedEphemeris());
Assert.assertTrue(bos.size() > 2400);
Assert.assertTrue(bos.size() < 2500);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
BoundedPropagator ephemeris = (BoundedPropagator) ois.readObject();
ephemeris.setMasterMode(10, new OrekitFixedStepHandler() {
public void handleStep(SpacecraftState currentState, boolean isLast) {
if (currentState.getDate().durationFrom(burn1Date) < -0.001) {
Assert.assertEquals(42100.0, currentState.getA(), 1.0e-3);
} else if (currentState.getDate().durationFrom(burn1Date) > 0.001 && currentState.getDate().durationFrom(burn2Date) < -0.001) {
Assert.assertEquals(42979.962, currentState.getA(), 1.0e-3);
} else if (currentState.getDate().durationFrom(burn2Date) > 0.001) {
Assert.assertEquals(43887.339, currentState.getA(), 1.0e-3);
}
}
});
ephemeris.propagate(ephemeris.getMaxDate());
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class KeplerianPropagatorTest method testIssue223.
@Test
public void testIssue223() throws OrekitException, IOException, ClassNotFoundException {
// Inertial frame
Frame inertialFrame = FramesFactory.getEME2000();
// Initial date
TimeScale utc = TimeScalesFactory.getUTC();
AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
// Central attraction coefficient
double mu = 3.986004415e+14;
// Initial orbit
// semi major axis in meters
double a = 42100;
// eccentricity
double e = 0.01;
// inclination
double i = FastMath.toRadians(6);
// 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);
// Propagator
KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
propagator.addAdditionalStateProvider(new SevenProvider());
propagator.setEphemerisMode();
propagator.propagate(initialState.getDate().shiftedBy(40000));
BoundedPropagator ephemeris = propagator.getGeneratedEphemeris();
Assert.assertSame(inertialFrame, ephemeris.getFrame());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(ephemeris);
Assert.assertTrue(bos.size() > 2250);
Assert.assertTrue(bos.size() < 2350);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
BoundedPropagator deserialized = (BoundedPropagator) ois.readObject();
Assert.assertEquals(initialOrbit.getA(), deserialized.getInitialState().getA(), 1.0e-10);
Assert.assertEquals(initialOrbit.getEquinoctialEx(), deserialized.getInitialState().getEquinoctialEx(), 1.0e-10);
SpacecraftState s = deserialized.propagate(initialState.getDate().shiftedBy(20000));
Map<String, double[]> additional = s.getAdditionalStates();
Assert.assertEquals(1, additional.size());
Assert.assertEquals(1, additional.get("seven").length);
Assert.assertEquals(7, additional.get("seven")[0], 1.0e-15);
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class TabulatedEphemerisTest method testPiWraping.
@Test
public void testPiWraping() throws OrekitException {
TimeScale utc = TimeScalesFactory.getUTC();
Frame frame = FramesFactory.getEME2000();
double mu = CelestialBodyFactory.getEarth().getGM();
AbsoluteDate t0 = new AbsoluteDate(2009, 10, 29, 0, 0, 0, utc);
AbsoluteDate t1 = new AbsoluteDate(t0, 1320.0);
Vector3D p1 = new Vector3D(-0.17831296727974E+08, 0.67919502669856E+06, -0.16591008368477E+07);
Vector3D v1 = new Vector3D(-0.38699705630724E+04, -0.36209408682762E+04, -0.16255053872347E+03);
SpacecraftState s1 = new SpacecraftState(new EquinoctialOrbit(new PVCoordinates(p1, v1), frame, t1, mu));
AbsoluteDate t2 = new AbsoluteDate(t0, 1440.0);
Vector3D p2 = new Vector3D(-0.18286942572033E+08, 0.24442124296930E+06, -0.16777961761695E+07);
Vector3D v2 = new Vector3D(-0.37252897467918E+04, -0.36246628128896E+04, -0.14917724596280E+03);
SpacecraftState s2 = new SpacecraftState(new EquinoctialOrbit(new PVCoordinates(p2, v2), frame, t2, mu));
AbsoluteDate t3 = new AbsoluteDate(t0, 1560.0);
Vector3D p3 = new Vector3D(-0.18725635245837E+08, -0.19058407701834E+06, -0.16949352249614E+07);
Vector3D v3 = new Vector3D(-0.35873348682393E+04, -0.36248828501784E+04, -0.13660045394149E+03);
SpacecraftState s3 = new SpacecraftState(new EquinoctialOrbit(new PVCoordinates(p3, v3), frame, t3, mu));
Ephemeris ephem = new Ephemeris(Arrays.asList(s1, s2, s3), 2);
AbsoluteDate tA = new AbsoluteDate(t0, 24 * 60);
Vector3D pA = ephem.propagate(tA).getPVCoordinates(frame).getPosition();
Assert.assertEquals(1.766, Vector3D.distance(pA, s1.shiftedBy(tA.durationFrom(s1.getDate())).getPVCoordinates(frame).getPosition()), 1.0e-3);
Assert.assertEquals(0.000, Vector3D.distance(pA, s2.shiftedBy(tA.durationFrom(s2.getDate())).getPVCoordinates(frame).getPosition()), 1.0e-3);
Assert.assertEquals(1.556, Vector3D.distance(pA, s3.shiftedBy(tA.durationFrom(s3.getDate())).getPVCoordinates(frame).getPosition()), 1.0e-3);
AbsoluteDate tB = new AbsoluteDate(t0, 25 * 60);
Vector3D pB = ephem.propagate(tB).getPVCoordinates(frame).getPosition();
Assert.assertEquals(2.646, Vector3D.distance(pB, s1.shiftedBy(tB.durationFrom(s1.getDate())).getPVCoordinates(frame).getPosition()), 1.0e-3);
Assert.assertEquals(2.619, Vector3D.distance(pB, s2.shiftedBy(tB.durationFrom(s2.getDate())).getPVCoordinates(frame).getPosition()), 1.0e-3);
Assert.assertEquals(2.632, Vector3D.distance(pB, s3.shiftedBy(tB.durationFrom(s3.getDate())).getPVCoordinates(frame).getPosition()), 1.0e-3);
AbsoluteDate tC = new AbsoluteDate(t0, 26 * 60);
Vector3D pC = ephem.propagate(tC).getPVCoordinates(frame).getPosition();
Assert.assertEquals(6.851, Vector3D.distance(pC, s1.shiftedBy(tC.durationFrom(s1.getDate())).getPVCoordinates(frame).getPosition()), 1.0e-3);
Assert.assertEquals(1.605, Vector3D.distance(pC, s2.shiftedBy(tC.durationFrom(s2.getDate())).getPVCoordinates(frame).getPosition()), 1.0e-3);
Assert.assertEquals(0.000, Vector3D.distance(pC, s3.shiftedBy(tC.durationFrom(s3.getDate())).getPVCoordinates(frame).getPosition()), 1.0e-3);
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class ElevationDetectorTest method testEventForMask.
@Test
public void testEventForMask() throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
final Orbit orbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, mu);
Propagator propagator = new EcksteinHechlerPropagator(orbit, ae, mu, c20, c30, c40, c50, c60);
// Earth and frame
// equatorial radius in meter
double ae = 6378137.0;
// flattening
double f = 1.0 / 298.257223563;
// terrestrial frame at an arbitrary date
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earth = new OneAxisEllipsoid(ae, f, itrf);
GeodeticPoint point = new GeodeticPoint(FastMath.toRadians(48.833), FastMath.toRadians(2.333), 0.0);
TopocentricFrame topo = new TopocentricFrame(earth, point, "Gstation");
double[][] maskValues = { { FastMath.toRadians(0), FastMath.toRadians(5) }, { FastMath.toRadians(30), FastMath.toRadians(4) }, { FastMath.toRadians(60), FastMath.toRadians(3) }, { FastMath.toRadians(90), FastMath.toRadians(2) }, { FastMath.toRadians(120), FastMath.toRadians(3) }, { FastMath.toRadians(150), FastMath.toRadians(4) }, { FastMath.toRadians(180), FastMath.toRadians(5) }, { FastMath.toRadians(210), FastMath.toRadians(6) }, { FastMath.toRadians(240), FastMath.toRadians(5) }, { FastMath.toRadians(270), FastMath.toRadians(4) }, { FastMath.toRadians(300), FastMath.toRadians(3) }, { FastMath.toRadians(330), FastMath.toRadians(4) } };
ElevationMask mask = new ElevationMask(maskValues);
ElevationDetector detector = new ElevationDetector(topo).withElevationMask(mask).withHandler(new StopOnIncreasing<ElevationDetector>());
Assert.assertSame(mask, detector.getElevationMask());
AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 20, 0, 0, utc);
propagator.resetInitialState(propagator.propagate(startDate));
propagator.addEventDetector(detector);
final SpacecraftState fs = propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
double elevation = topo.getElevation(fs.getPVCoordinates().getPosition(), fs.getFrame(), fs.getDate());
Assert.assertEquals(0.065, elevation, 2.0e-5);
}
Aggregations