use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class AttitudesSequenceTest method testBackwardPropagation.
@Test
public void testBackwardPropagation() throws OrekitException {
// Initial state definition : date, orbit
final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU);
final AttitudesSequence attitudesSequence = new AttitudesSequence();
final AttitudeProvider past = new InertialProvider(Rotation.IDENTITY);
final AttitudeProvider current = new InertialProvider(Rotation.IDENTITY);
final AttitudeProvider future = new InertialProvider(Rotation.IDENTITY);
final Handler handler = new Handler(current, past);
attitudesSequence.addSwitchingCondition(past, current, new DateDetector(initialDate.shiftedBy(-500.0)), true, false, 10.0, AngularDerivativesFilter.USE_R, handler);
attitudesSequence.addSwitchingCondition(current, future, new DateDetector(initialDate.shiftedBy(+500.0)), true, false, 10.0, AngularDerivativesFilter.USE_R, null);
attitudesSequence.resetActiveProvider(current);
SpacecraftState initialState = new SpacecraftState(initialOrbit);
initialState = initialState.addAdditionalState("fortyTwo", 42.0);
final Propagator propagator = new EcksteinHechlerPropagator(initialOrbit, attitudesSequence, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
propagator.resetInitialState(initialState);
Assert.assertEquals(42.0, propagator.getInitialState().getAdditionalState("fortyTwo")[0], 1.0e-10);
// Register the switching events to the propagator
attitudesSequence.registerSwitchEvents(propagator);
SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(-10000.0));
Assert.assertEquals(42.0, finalState.getAdditionalState("fortyTwo")[0], 1.0e-10);
Assert.assertEquals(1, handler.dates.size());
Assert.assertEquals(-500.0, handler.dates.get(0).durationFrom(initialDate), 1.0e-3);
Assert.assertEquals(-490.0, finalState.getDate().durationFrom(initialDate), 1.0e-3);
}
use of org.orekit.propagation.Propagator in project SpriteOrbits by ProjectPersephone.
the class SpriteProp method run.
/**
* run the application.
* @param out output file
* @param propagationDuration duration of the propagation
* @param step fixed step between output lines
* @param utc UTC time scale
*/
public void run(final PrintStream out, final double propagationDuration, final double step, final TimeScale utc) throws OrekitException {
final AbsoluteDate start = spritesPropagators.get(0).getInitialState().getDate();
final AbsoluteDate end = start.shiftedBy(propagationDuration * Constants.JULIAN_DAY);
/*out.format(Locale.US, "# file generated on %s%n",
new AbsoluteDate(new Date(), utc).toString(utc));
out.format(Locale.US, "# propagating %d sprites from %s to %s%n",
spritesPropagators.size(), start.toString(utc), end.toString(utc));
out.format(Locale.US, "# column 1: date (UTC)%n");
out.format(Locale.US, "# column 2: date offset since start (seconds)%n");
out.format(Locale.US, "# column 3: KickSat geodetic latitude (degrees)%n");
out.format(Locale.US, "# column 4: KickSat geodetic longitude (degrees)%n");
out.format(Locale.US, "# column 5: KickSat geodetic altitude (meters)%n");
out.format(Locale.US, "# column 3i+3: sprite i geodetic latitude (degrees)%n");
out.format(Locale.US, "# column 3i+4: sprite i geodetic longitude (degrees)%n");
out.format(Locale.US, "# column 3i+5: sprite i geodetic altitude (meters)%n");
*/
// in order to speed up computation, we let the numerical propagator choose its
// steps, and create ephemerides, then we will use the ephemerides with fixed
// steps for output
List<Propagator> ephemerides = new ArrayList<Propagator>(spritesPropagators.size());
for (final Propagator spritePropagator : spritesPropagators) {
spritePropagator.setEphemerisMode();
spritePropagator.propagate(end);
ephemerides.add(spritePropagator.getGeneratedEphemeris());
}
boolean firstTime = true;
for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(step)) {
if (!firstTime) {
out.format(Locale.US, ",");
} else {
firstTime = false;
}
/*out.format(Locale.US, "%s %9.1f", date.toString(utc), date.durationFrom(start));
final GeodeticPoint kickSatGP = geodeticPosition(kickSatPropagator, date);
out.format(Locale.US, " %8.3f %8.3f %8.1f",
FastMath.toDegrees(kickSatGP.getLatitude()),
FastMath.toDegrees(kickSatGP.getLongitude()),
kickSatGP.getAltitude());
for (final Propagator ephemeride : ephemerides) {
final GeodeticPoint spriteGP = geodeticPosition(ephemeride, date);
out.format(Locale.US, " %8.3f %8.3f %8.1f",
FastMath.toDegrees(spriteGP.getLatitude()),
FastMath.toDegrees(spriteGP.getLongitude()),
spriteGP.getAltitude());
}
*/
out.format(Locale.US, "{\"date\":\"%s\",\"offset\":%.1f,", date.toString(utc), date.durationFrom(start));
final GeodeticPoint kickSatGP = geodeticPosition(kickSatPropagator, date);
out.format(Locale.US, "\"kicksat\":{\"lat\":%.3f,\"lng\":%.3f,\"alt\":%.1f},", FastMath.toDegrees(kickSatGP.getLatitude()), FastMath.toDegrees(kickSatGP.getLongitude()), kickSatGP.getAltitude());
out.format(Locale.US, "\"sprites\":[");
boolean firstSprite = true;
for (final Propagator ephemeride : ephemerides) {
final GeodeticPoint spriteGP = geodeticPosition(ephemeride, date);
if (!firstSprite) {
out.format(Locale.US, ",");
} else {
firstSprite = false;
}
out.format(Locale.US, "{\"lat\":%.3f,\"lng\":%.3f,\"alt\":%.1f}", FastMath.toDegrees(spriteGP.getLatitude()), FastMath.toDegrees(spriteGP.getLongitude()), spriteGP.getAltitude());
}
out.format(Locale.US, "]}");
out.println();
}
}
use of org.orekit.propagation.Propagator in project SpriteOrbits by ProjectPersephone.
the class SpritePropOrig method run.
/**
* run the application.
* @param out output file
* @param propagationDuration duration of the propagation
* @param step fixed step between output lines
* @param utc UTC time scale
*/
public void run(final PrintStream out, final double propagationDuration, final double step, final TimeScale utc) throws OrekitException {
final AbsoluteDate start = spritesPropagators.get(0).getInitialState().getDate();
final AbsoluteDate end = start.shiftedBy(propagationDuration * Constants.JULIAN_DAY);
out.format(Locale.US, "# file generated on %s%n", new AbsoluteDate(new Date(), utc).toString(utc));
out.format(Locale.US, "# propagating %d sprites from %s to %s%n", spritesPropagators.size(), start.toString(utc), end.toString(utc));
out.format(Locale.US, "# column 1: date (UTC)%n");
out.format(Locale.US, "# column 2: date offset since start (seconds)%n");
out.format(Locale.US, "# column 3: KickSat geodetic latitude (degrees)%n");
out.format(Locale.US, "# column 4: KickSat geodetic longitude (degrees)%n");
out.format(Locale.US, "# column 5: KickSat geodetic altitude (meters)%n");
out.format(Locale.US, "# column 3i+3: sprite i geodetic latitude (degrees)%n");
out.format(Locale.US, "# column 3i+4: sprite i geodetic longitude (degrees)%n");
out.format(Locale.US, "# column 3i+5: sprite i geodetic altitude (meters)%n");
// in order to speed up computation, we let the numerical propagator choose its
// steps, and create ephemerides, then we will use the ephemerides with fixed
// steps for output
List<Propagator> ephemerides = new ArrayList<Propagator>(spritesPropagators.size());
for (final Propagator spritePropagator : spritesPropagators) {
spritePropagator.setEphemerisMode();
spritePropagator.propagate(end);
ephemerides.add(spritePropagator.getGeneratedEphemeris());
}
for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(step)) {
out.format(Locale.US, "%s %9.1f", date.toString(utc), date.durationFrom(start));
final GeodeticPoint kickSatGP = geodeticPosition(kickSatPropagator, date);
out.format(Locale.US, " %8.3f %8.3f %8.1f", FastMath.toDegrees(kickSatGP.getLatitude()), FastMath.toDegrees(kickSatGP.getLongitude()), kickSatGP.getAltitude());
for (final Propagator ephemeride : ephemerides) {
final GeodeticPoint spriteGP = geodeticPosition(ephemeride, date);
out.format(Locale.US, " %8.3f %8.3f %8.1f", FastMath.toDegrees(spriteGP.getLatitude()), FastMath.toDegrees(spriteGP.getLongitude()), spriteGP.getAltitude());
}
out.println();
}
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class DOPComputer method compute.
/**
* Compute the {@link DOP} at a given date for a set of GNSS spacecrafts.
* <p>Four GNSS spacecraft at least are needed to compute the DOP.
* If less than 4 propagators are provided, an exception will be thrown.
* If less than 4 spacecrafts are visible at the date, all DOP values will be
* set to {@link java.lang.Double#NaN NaN}.</p>
*
* @param date the computation date
* @param gnss the propagators for GNSS spacecraft involved in the DOP computation
* @return the {@link DOP} at the location
* @throws OrekitException if something wrong occurs
*/
public DOP compute(final AbsoluteDate date, final List<Propagator> gnss) throws OrekitException {
// Checks the number of provided propagators
if (gnss.size() < DOP_MIN_PROPAGATORS) {
throw new OrekitException(OrekitMessages.NOT_ENOUGH_GNSS_FOR_DOP, gnss.size(), DOP_MIN_PROPAGATORS);
}
// Initializes DOP values
double gdop = Double.NaN;
double pdop = Double.NaN;
double hdop = Double.NaN;
double vdop = Double.NaN;
double tdop = Double.NaN;
// Loop over the propagators of GNSS orbits
final double[][] satDir = new double[gnss.size()][4];
int satNb = 0;
for (Propagator prop : gnss) {
final Vector3D pos = prop.getPVCoordinates(date, frame).getPosition();
final double elev = frame.getElevation(pos, frame, date);
final double elMin = (elevationMask != null) ? elevationMask.getElevation(frame.getAzimuth(pos, frame, date)) : minElevation;
// Only visible satellites are considered
if (elev > elMin) {
// Create the rows of the H matrix
final Vector3D r = pos.normalize();
satDir[satNb][0] = r.getX();
satDir[satNb][1] = r.getY();
satDir[satNb][2] = r.getZ();
satDir[satNb][3] = -1.;
satNb++;
}
}
// DOP values are computed only if at least 4 SV are visible from the location
if (satNb > 3) {
// Construct matrix H
final RealMatrix h = MatrixUtils.createRealMatrix(satNb, 4);
for (int k = 0; k < satNb; k++) {
h.setRow(k, satDir[k]);
}
// Compute the pseudo-inverse of H
final RealMatrix hInv = MatrixUtils.inverse(h.transpose().multiply(h));
final double sx2 = hInv.getEntry(0, 0);
final double sy2 = hInv.getEntry(1, 1);
final double sz2 = hInv.getEntry(2, 2);
final double st2 = hInv.getEntry(3, 3);
// Extract various DOP : GDOP, PDOP, HDOP, VDOP, TDOP
gdop = FastMath.sqrt(hInv.getTrace());
pdop = FastMath.sqrt(sx2 + sy2 + sz2);
hdop = FastMath.sqrt(sx2 + sy2);
vdop = FastMath.sqrt(sz2);
tdop = FastMath.sqrt(st2);
}
// Return all the DOP values
return new DOP(frame.getPoint(), date, satNb, gdop, pdop, hdop, vdop, tdop);
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class OsculatingToMeanElementsConverter method convert.
/**
* Convert an osculating orbit into a mean orbit, in DSST sense.
* @return mean orbit state, in DSST sense
* @throws OrekitException if state cannot be propagated throughout range
*/
public final SpacecraftState convert() throws OrekitException {
final double timeSpan = state.getKeplerianPeriod() * satelliteRevolution;
propagator.resetInitialState(state);
final FiniteDifferencePropagatorConverter converter = new FiniteDifferencePropagatorConverter(new KeplerianPropagatorBuilder(state.getOrbit(), PositionAngle.MEAN, positionScale), 1.e-6, MAX_EVALUATION);
final Propagator prop = converter.convert(propagator, timeSpan, satelliteRevolution * 36);
return prop.getInitialState();
}
Aggregations