use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class RangeTest method genericTestParameterDerivatives.
void genericTestParameterDerivatives(final boolean isModifier, final boolean printResults, final double refErrorsMedian, final double refErrorsMean, final double refErrorsMax) throws OrekitException {
Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
final NumericalPropagatorBuilder propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true, 1.0e-6, 60.0, 0.001);
// Create perfect range measurements
for (final GroundStation station : context.stations) {
station.getEastOffsetDriver().setSelected(true);
station.getNorthOffsetDriver().setSelected(true);
station.getZenithOffsetDriver().setSelected(true);
}
final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new RangeMeasurementCreator(context), 1.0, 3.0, 300.0);
// List to store the results
final List<Double> relErrorList = new ArrayList<Double>();
// Set master mode
// Use a lambda function to implement "handleStep" function
propagator.setMasterMode((OrekitStepInterpolator interpolator, boolean isLast) -> {
for (final ObservedMeasurement<?> measurement : measurements) {
// Play test if the measurement date is between interpolator previous and current date
if ((measurement.getDate().durationFrom(interpolator.getPreviousState().getDate()) > 0.) && (measurement.getDate().durationFrom(interpolator.getCurrentState().getDate()) <= 0.)) {
// Add modifiers if test implies it
final RangeTroposphericDelayModifier modifier = new RangeTroposphericDelayModifier(SaastamoinenModel.getStandardModel());
if (isModifier) {
((Range) measurement).addModifier(modifier);
}
// Parameter corresponding to station position offset
final GroundStation stationParameter = ((Range) measurement).getStation();
// We intentionally propagate to a date which is close to the
// real spacecraft state but is *not* the accurate date, by
// compensating only part of the downlink delay. This is done
// in order to validate the partial derivatives with respect
// to velocity. If we had chosen the proper state date, the
// range would have depended only on the current position but
// not on the current velocity.
final double meanDelay = measurement.getObservedValue()[0] / Constants.SPEED_OF_LIGHT;
final AbsoluteDate date = measurement.getDate().shiftedBy(-0.75 * meanDelay);
final SpacecraftState state = interpolator.getInterpolatedState(date);
final ParameterDriver[] drivers = new ParameterDriver[] { stationParameter.getEastOffsetDriver(), stationParameter.getNorthOffsetDriver(), stationParameter.getZenithOffsetDriver() };
if (printResults) {
String stationName = ((Range) measurement).getStation().getBaseFrame().getName();
System.out.format(Locale.US, "%-15s %-23s %-23s ", stationName, measurement.getDate(), date);
}
for (int i = 0; i < 3; ++i) {
final double[] gradient = measurement.estimate(0, 0, new SpacecraftState[] { state }).getParameterDerivatives(drivers[i]);
Assert.assertEquals(1, measurement.getDimension());
Assert.assertEquals(1, gradient.length);
// Compute a reference value using finite differences
final ParameterFunction dMkdP = Differentiation.differentiate(new ParameterFunction() {
/**
* {@inheritDoc}
*/
@Override
public double value(final ParameterDriver parameterDriver) throws OrekitException {
return measurement.estimate(0, 0, new SpacecraftState[] { state }).getEstimatedValue()[0];
}
}, drivers[i], 3, 20.0);
final double ref = dMkdP.value(drivers[i]);
if (printResults) {
System.out.format(Locale.US, "%10.3e %10.3e ", gradient[0] - ref, FastMath.abs((gradient[0] - ref) / ref));
}
final double relError = FastMath.abs((ref - gradient[0]) / ref);
relErrorList.add(relError);
// Assert.assertEquals(ref, gradient[0], 6.1e-5 * FastMath.abs(ref));
}
if (printResults) {
System.out.format(Locale.US, "%n");
}
}
// End if measurement date between previous and current interpolator step
}
// End for loop on the measurements
});
// Rewind the propagator to initial date
propagator.propagate(context.initialOrbit.getDate());
// Sort measurements chronologically
measurements.sort(new ChronologicalComparator());
// Print results ? Header
if (printResults) {
System.out.format(Locale.US, "%-15s %-23s %-23s " + "%10s %10s %10s " + "%10s %10s %10s%n", "Station", "Measurement Date", "State Date", "ΔdQx", "rel ΔdQx", "ΔdQy", "rel ΔdQy", "ΔdQz", "rel ΔdQz");
}
// Propagate to final measurement's date
propagator.propagate(measurements.get(measurements.size() - 1).getDate());
// Convert error list to double[]
final double[] relErrors = relErrorList.stream().mapToDouble(Double::doubleValue).toArray();
// Compute statistics
final double relErrorsMedian = new Median().evaluate(relErrors);
final double relErrorsMean = new Mean().evaluate(relErrors);
final double relErrorsMax = new Max().evaluate(relErrors);
// Print the results on console ?
if (printResults) {
System.out.println();
System.out.format(Locale.US, "Relative errors dR/dQ -> Median: %6.3e / Mean: %6.3e / Max: %6.3e%n", relErrorsMedian, relErrorsMean, relErrorsMax);
}
Assert.assertEquals(0.0, relErrorsMedian, refErrorsMedian);
Assert.assertEquals(0.0, relErrorsMean, refErrorsMean);
Assert.assertEquals(0.0, relErrorsMax, refErrorsMax);
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class DSSTPropagatorTest method testEphemerisDates.
@Test
public void testEphemerisDates() throws OrekitException {
// setup
TimeScale tai = TimeScalesFactory.getTAI();
AbsoluteDate initialDate = new AbsoluteDate("2015-07-01", tai);
AbsoluteDate startDate = new AbsoluteDate("2015-07-03", tai).shiftedBy(-0.1);
AbsoluteDate endDate = new AbsoluteDate("2015-07-04", tai);
Frame eci = FramesFactory.getGCRF();
KeplerianOrbit orbit = new KeplerianOrbit(600e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS, 0, 0, 0, 0, 0, PositionAngle.TRUE, eci, initialDate, Constants.EIGEN5C_EARTH_MU);
double[][] tol = DSSTPropagator.tolerances(1, orbit);
Propagator prop = new DSSTPropagator(new DormandPrince853Integrator(0.1, 500, tol[0], tol[1]));
prop.resetInitialState(new SpacecraftState(new CartesianOrbit(orbit)));
// action
prop.setEphemerisMode();
prop.propagate(startDate, endDate);
BoundedPropagator ephemeris = prop.getGeneratedEphemeris();
// verify
TimeStampedPVCoordinates actualPV = ephemeris.getPVCoordinates(startDate, eci);
TimeStampedPVCoordinates expectedPV = orbit.getPVCoordinates(startDate, eci);
MatcherAssert.assertThat(actualPV.getPosition(), OrekitMatchers.vectorCloseTo(expectedPV.getPosition(), 1.0));
MatcherAssert.assertThat(actualPV.getVelocity(), OrekitMatchers.vectorCloseTo(expectedPV.getVelocity(), 1.0));
MatcherAssert.assertThat(ephemeris.getMinDate().durationFrom(startDate), OrekitMatchers.closeTo(0, 0));
MatcherAssert.assertThat(ephemeris.getMaxDate().durationFrom(endDate), OrekitMatchers.closeTo(0, 0));
// test date
AbsoluteDate date = endDate.shiftedBy(-0.11);
Assert.assertEquals(ephemeris.propagate(date).getDate().durationFrom(date), 0, 0);
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class DOPComputation method run.
private void run(final OneAxisEllipsoid shape, final List<GeodeticPoint> zone, final double meshSize, final double minElevation, final AbsoluteDate tStart, final AbsoluteDate tStop, final double tStep) throws IOException, OrekitException, ParseException {
// Gets the GPS almanacs from the SEM file
final SEMParser reader = new SEMParser(null);
reader.loadData();
final List<GPSAlmanac> almanacs = reader.getAlmanacs();
// Creates the GPS propagators from the almanacs
final List<Propagator> propagators = new ArrayList<Propagator>();
for (GPSAlmanac almanac : almanacs) {
// Only keeps almanac with health status ok
if (almanac.getHealth() == 0) {
propagators.add(new GPSPropagator.Builder(almanac).build());
} else {
System.out.println("GPS PRN " + almanac.getPRN() + " is not OK (Health status = " + almanac.getHealth() + ").");
}
}
// Meshes the area of interest into a grid of geodetic points.
final List<List<GeodeticPoint>> points = sample(shape, zone, meshSize);
// Creates the DOP computers for all the locations of the sampled geographic zone
final List<DOPComputer> computers = new ArrayList<DOPComputer>();
for (List<GeodeticPoint> row : points) {
for (GeodeticPoint point : row) {
computers.add(DOPComputer.create(shape, point).withMinElevation(minElevation));
}
}
// Computes the DOP for each point over the period
final List<List<DOP>> allDop = new ArrayList<List<DOP>>();
// Loops on the period
AbsoluteDate tc = tStart;
while (tc.compareTo(tStop) != 1) {
// Loops on the grid points
final List<DOP> dopAtDate = new ArrayList<DOP>();
for (DOPComputer computer : computers) {
try {
final DOP dop = computer.compute(tc, propagators);
dopAtDate.add(dop);
} catch (OrekitException oe) {
System.out.println(oe.getLocalizedMessage());
}
}
allDop.add(dopAtDate);
tc = tc.shiftedBy(tStep);
}
// Post-processing: gets the statistics of PDOP over the zone at each time
System.out.println(" PDOP");
System.out.println(" Date min max");
for (List<DOP> dopAtDate : allDop) {
final StreamingStatistics pDoP = new StreamingStatistics();
for (DOP dopAtLoc : dopAtDate) {
pDoP.addValue(dopAtLoc.getPdop());
}
final AbsoluteDate date = dopAtDate.get(0).getDate();
System.out.format(Locale.ENGLISH, "%s %.2f %.2f%n", date.toString(), pDoP.getMin(), pDoP.getMax());
}
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class TrackCorridor method createPropagator.
/**
* Create an orbit propagator for a TLE orbit
* @param line1 firs line of the TLE
* @param line2 second line of the TLE
* @return an orbit propagator
* @exception OrekitException if the TLE lines are corrupted (wrong checksums ...)
*/
private Propagator createPropagator(final String line1, final String line2) throws OrekitException {
// create pseudo-orbit
TLE tle = new TLE(line1, line2);
// create propagator
Propagator propagator = TLEPropagator.selectExtrapolator(tle);
return propagator;
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class TrackCorridor method run.
private void run(final File input, final File output, final String separator) throws IOException, IllegalArgumentException, OrekitException {
// read input parameters
KeyValueFileParser<ParameterKey> parser = new KeyValueFileParser<ParameterKey>(ParameterKey.class);
try (final FileInputStream fis = new FileInputStream(input)) {
parser.parseInput(input.getAbsolutePath(), fis);
}
TimeScale utc = TimeScalesFactory.getUTC();
Propagator propagator;
if (parser.containsKey(ParameterKey.TLE_LINE1)) {
propagator = createPropagator(parser.getString(ParameterKey.TLE_LINE1), parser.getString(ParameterKey.TLE_LINE2));
} else {
propagator = createPropagator(parser.getDate(ParameterKey.ORBIT_CIRCULAR_DATE, utc), parser.getDouble(ParameterKey.ORBIT_CIRCULAR_A), parser.getDouble(ParameterKey.ORBIT_CIRCULAR_EX), parser.getDouble(ParameterKey.ORBIT_CIRCULAR_EY), parser.getAngle(ParameterKey.ORBIT_CIRCULAR_I), parser.getAngle(ParameterKey.ORBIT_CIRCULAR_RAAN), parser.getAngle(ParameterKey.ORBIT_CIRCULAR_ALPHA));
}
// simulation properties
AbsoluteDate start = parser.getDate(ParameterKey.START_DATE, utc);
double duration = parser.getDouble(ParameterKey.DURATION);
double step = parser.getDouble(ParameterKey.STEP);
double angle = parser.getAngle(ParameterKey.ANGULAR_OFFSET);
// set up a handler to gather all corridor points
CorridorHandler handler = new CorridorHandler(angle);
propagator.setMasterMode(step, handler);
// perform propagation, letting the step handler populate the corridor
propagator.propagate(start, start.shiftedBy(duration));
// retrieve the built corridor
List<CorridorPoint> corridor = handler.getCorridor();
// create a 7 columns csv file representing the corridor in the user home directory, with
// date in column 1 (in ISO-8601 format)
// left limit latitude in column 2 and left limit longitude in column 3
// center track latitude in column 4 and center track longitude in column 5
// right limit latitude in column 6 and right limit longitude in column 7
DecimalFormat format = new DecimalFormat("#00.00000", new DecimalFormatSymbols(Locale.US));
try (final PrintStream stream = new PrintStream(output, "UTF-8")) {
for (CorridorPoint p : corridor) {
stream.println(p.getDate() + separator + format.format(FastMath.toDegrees(p.getLeft().getLatitude())) + separator + format.format(FastMath.toDegrees(p.getLeft().getLongitude())) + separator + format.format(FastMath.toDegrees(p.getCenter().getLatitude())) + separator + format.format(FastMath.toDegrees(p.getCenter().getLongitude())) + separator + format.format(FastMath.toDegrees(p.getRight().getLatitude())) + separator + format.format(FastMath.toDegrees(p.getRight().getLongitude())));
}
}
}
Aggregations