Commit 7b1d2047 authored by Luc Maisonobe's avatar Luc Maisonobe

Set up modifiers and initialize their parameters reference dates.

parent 9b699c0f
......@@ -24,6 +24,7 @@ import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.orekit.estimation.measurements.EstimatedMeasurement;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.time.AbsoluteDate;
/** Base class for {@link MeasurementBuilder measurements builders}.
......@@ -48,6 +49,12 @@ public abstract class AbstractMeasurementBuilder<T extends ObservedMeasurement<T
/** Indices of the propagators related to this measurement. */
private final int[] propagatorsIndices;
/** Start of the measurements time span. */
private AbsoluteDate spanStart;
/** End of the measurements time span. */
private AbsoluteDate spanEnd;
/** Simple constructor.
* @param noiseSource noise source, may be null for generating perfect measurements
* @param sigma theoretical standard deviation
......@@ -81,6 +88,17 @@ public abstract class AbstractMeasurementBuilder<T extends ObservedMeasurement<T
this.propagatorsIndices = propagatorsIndices.clone();
}
/** {@inheritDoc}
* <p>
* This implementation stores the time span of the measurements generation.
* </p>
*/
@Override
public void init(final AbsoluteDate start, final AbsoluteDate end) {
spanStart = start;
spanEnd = end;
}
/** {@inheritDoc} */
@Override
public void addModifier(final EstimationModifier<T> modifier) {
......@@ -93,6 +111,20 @@ public abstract class AbstractMeasurementBuilder<T extends ObservedMeasurement<T
return Collections.unmodifiableList(modifiers);
}
/** Get the start of the measurements time span.
* @return start of the measurements time span
*/
protected AbsoluteDate getStart() {
return spanStart;
}
/** Get the end of the measurements time span.
* @return end of the measurements time span
*/
protected AbsoluteDate getEnd() {
return spanEnd;
}
/** Generate a noise vector.
* @return noise vector (null if we generate perfect measurements)
*/
......
......@@ -18,8 +18,11 @@ package org.orekit.estimation.measurements.generation;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.orekit.estimation.measurements.AngularAzEl;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Builder for {@link AngularAzEl} measurements.
......@@ -48,7 +51,7 @@ public class AngularAzElBuilder extends AbstractMeasurementBuilder<AngularAzEl>
/** {@inheritDoc} */
@Override
public AngularAzEl build(final SpacecraftState... states) {
public AngularAzEl build(final SpacecraftState[] states) {
final int propagatorIndex = getPropagatorsIndices()[0];
final double[] sigma = getTheoreticalStandardDeviation();
......@@ -60,6 +63,18 @@ public class AngularAzElBuilder extends AbstractMeasurementBuilder<AngularAzEl>
new double[] {
Double.NaN, Double.NaN
}, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<AngularAzEl> modifier : getModifiers()) {
dummy.addModifier(modifier);
}
// set a reference date for parameters missing one
for (final ParameterDriver driver : dummy.getParametersDrivers()) {
if (driver.getReferenceDate() == null) {
final AbsoluteDate start = getStart();
final AbsoluteDate end = getEnd();
driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
}
}
// estimate the perfect value of the measurement
final double[] angular = dummy.estimate(0, 0, states).getEstimatedValue();
......@@ -72,7 +87,12 @@ public class AngularAzElBuilder extends AbstractMeasurementBuilder<AngularAzEl>
}
// generate measurement
return new AngularAzEl(station, state.getDate(), angular, sigma, baseWeight, propagatorIndex);
final AngularAzEl measurement = new AngularAzEl(station, state.getDate(), angular,
sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<AngularAzEl> modifier : getModifiers()) {
measurement.addModifier(modifier);
}
return measurement;
}
......
......@@ -18,9 +18,12 @@ package org.orekit.estimation.measurements.generation;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.orekit.estimation.measurements.AngularRaDec;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.frames.Frame;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Builder for {@link AngularRaDec} measurements.
......@@ -54,7 +57,7 @@ public class AngularRaDecBuilder extends AbstractMeasurementBuilder<AngularRaDec
/** {@inheritDoc} */
@Override
public AngularRaDec build(final SpacecraftState... states) {
public AngularRaDec build(final SpacecraftState[] states) {
final int propagatorIndex = getPropagatorsIndices()[0];
final double[] sigma = getTheoreticalStandardDeviation();
......@@ -66,6 +69,18 @@ public class AngularRaDecBuilder extends AbstractMeasurementBuilder<AngularRaDec
new double[] {
Double.NaN, Double.NaN
}, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<AngularRaDec> modifier : getModifiers()) {
dummy.addModifier(modifier);
}
// set a reference date for parameters missing one
for (final ParameterDriver driver : dummy.getParametersDrivers()) {
if (driver.getReferenceDate() == null) {
final AbsoluteDate start = getStart();
final AbsoluteDate end = getEnd();
driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
}
}
// estimate the perfect value of the measurement
final double[] angular = dummy.estimate(0, 0, states).getEstimatedValue();
......@@ -78,7 +93,12 @@ public class AngularRaDecBuilder extends AbstractMeasurementBuilder<AngularRaDec
}
// generate measurement
return new AngularRaDec(station, referenceFrame, state.getDate(), angular, sigma, baseWeight, propagatorIndex);
final AngularRaDec measurement = new AngularRaDec(station, referenceFrame, state.getDate(),
angular, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<AngularRaDec> modifier : getModifiers()) {
measurement.addModifier(modifier);
}
return measurement;
}
......
......@@ -17,8 +17,11 @@
package org.orekit.estimation.measurements.generation;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.InterSatellitesRange;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Builder for {@link InterSatellitesRange} measurements.
......@@ -51,7 +54,7 @@ public class InterSatellitesRangeBuilder extends AbstractMeasurementBuilder<Inte
/** {@inheritDoc} */
@Override
public InterSatellitesRange build(final SpacecraftState... states) {
public InterSatellitesRange build(final SpacecraftState[] states) {
final int[] indices = getPropagatorsIndices();
final double sigma = getTheoreticalStandardDeviation()[0];
......@@ -61,6 +64,18 @@ public class InterSatellitesRangeBuilder extends AbstractMeasurementBuilder<Inte
// create a dummy measurement
final InterSatellitesRange dummy = new InterSatellitesRange(indices[0], indices[1], twoway, state.getDate(),
Double.NaN, sigma, baseWeight);
for (final EstimationModifier<InterSatellitesRange> modifier : getModifiers()) {
dummy.addModifier(modifier);
}
// set a reference date for parameters missing one
for (final ParameterDriver driver : dummy.getParametersDrivers()) {
if (driver.getReferenceDate() == null) {
final AbsoluteDate start = getStart();
final AbsoluteDate end = getEnd();
driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
}
}
// estimate the perfect value of the measurement
double range = dummy.estimate(0, 0, states).getEstimatedValue()[0];
......@@ -72,8 +87,12 @@ public class InterSatellitesRangeBuilder extends AbstractMeasurementBuilder<Inte
}
// generate measurement
return new InterSatellitesRange(indices[0], indices[1], twoway, state.getDate(),
range, sigma, baseWeight);
final InterSatellitesRange measurement = new InterSatellitesRange(indices[0], indices[1], twoway, state.getDate(),
range, sigma, baseWeight);
for (final EstimationModifier<InterSatellitesRange> modifier : getModifiers()) {
measurement.addModifier(modifier);
}
return measurement;
}
......
......@@ -21,6 +21,7 @@ import java.util.List;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.ObservedMeasurement;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
/** Interface for generating individual {@link ObservedMeasurements measurements}.
......@@ -30,6 +31,17 @@ import org.orekit.propagation.SpacecraftState;
*/
public interface MeasurementBuilder<T extends ObservedMeasurement<T>> {
/** Initialize builder at the start of a measurements generation.
* <p>
* This method is called once at the start of the measurements generation. It
* may be used by the builder to initialize some internal data
* if needed, typically setting up parameters reference dates.
* </p>
* @param start start of the measurements time span
* @param end end of the measurements time span
*/
void init(AbsoluteDate start, AbsoluteDate end);
/** Add a modifier.
* @param modifier modifier to add
*/
......@@ -45,6 +57,6 @@ public interface MeasurementBuilder<T extends ObservedMeasurement<T>> {
* @param states spacecraft states
* @return generated measurement
*/
T build(SpacecraftState... states);
T build(SpacecraftState[] states);
}
......@@ -18,8 +18,11 @@ package org.orekit.estimation.measurements.generation;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.PV;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Builder for {@link PV} measurements.
......@@ -48,7 +51,7 @@ public class PVBuilder extends AbstractMeasurementBuilder<PV> {
/** {@inheritDoc} */
@Override
public PV build(final SpacecraftState... states) {
public PV build(final SpacecraftState[] states) {
final int propagatorIndex = getPropagatorsIndices()[0];
final double[] sigma = getTheoreticalStandardDeviation();
......@@ -58,6 +61,18 @@ public class PVBuilder extends AbstractMeasurementBuilder<PV> {
// create a dummy measurement
final PV dummy = new PV(state.getDate(), Vector3D.NaN, Vector3D.NaN,
sigma[0], sigma[1], baseWeight, propagatorIndex);
for (final EstimationModifier<PV> modifier : getModifiers()) {
dummy.addModifier(modifier);
}
// set a reference date for parameters missing one
for (final ParameterDriver driver : dummy.getParametersDrivers()) {
if (driver.getReferenceDate() == null) {
final AbsoluteDate start = getStart();
final AbsoluteDate end = getEnd();
driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
}
}
// estimate the perfect value of the measurement
final double[] pv = dummy.estimate(0, 0, states).getEstimatedValue();
......@@ -74,9 +89,13 @@ public class PVBuilder extends AbstractMeasurementBuilder<PV> {
}
// generate measurement
return new PV(state.getDate(),
new Vector3D(pv[0], pv[1], pv[2]), new Vector3D(pv[3], pv[4], pv[5]),
sigma[0], sigma[1], baseWeight, propagatorIndex);
final PV measurement = new PV(state.getDate(),
new Vector3D(pv[0], pv[1], pv[2]), new Vector3D(pv[3], pv[4], pv[5]),
sigma[0], sigma[1], baseWeight, propagatorIndex);
for (final EstimationModifier<PV> modifier : getModifiers()) {
measurement.addModifier(modifier);
}
return measurement;
}
......
......@@ -18,8 +18,11 @@ package org.orekit.estimation.measurements.generation;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.Position;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Builder for {@link Position} measurements.
......@@ -42,7 +45,7 @@ public class PositionBuilder extends AbstractMeasurementBuilder<Position> {
/** {@inheritDoc} */
@Override
public Position build(final SpacecraftState... states) {
public Position build(final SpacecraftState[] states) {
final int propagatorIndex = getPropagatorsIndices()[0];
final double sigma = getTheoreticalStandardDeviation()[0];
......@@ -51,6 +54,18 @@ public class PositionBuilder extends AbstractMeasurementBuilder<Position> {
// create a dummy measurement
final Position dummy = new Position(state.getDate(), Vector3D.NaN, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<Position> modifier : getModifiers()) {
dummy.addModifier(modifier);
}
// set a reference date for parameters missing one
for (final ParameterDriver driver : dummy.getParametersDrivers()) {
if (driver.getReferenceDate() == null) {
final AbsoluteDate start = getStart();
final AbsoluteDate end = getEnd();
driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
}
}
// estimate the perfect value of the measurement
final double[] position = dummy.estimate(0, 0, states).getEstimatedValue();
......@@ -64,7 +79,12 @@ public class PositionBuilder extends AbstractMeasurementBuilder<Position> {
}
// generate measurement
return new Position(state.getDate(), new Vector3D(position), sigma, baseWeight, propagatorIndex);
final Position measurement = new Position(state.getDate(), new Vector3D(position),
sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<Position> modifier : getModifiers()) {
measurement.addModifier(modifier);
}
return measurement;
}
......
......@@ -17,9 +17,12 @@
package org.orekit.estimation.measurements.generation;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.estimation.measurements.Range;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Builder for {@link Range} measurements.
......@@ -53,7 +56,7 @@ public class RangeBuilder extends AbstractMeasurementBuilder<Range> {
/** {@inheritDoc} */
@Override
public Range build(final SpacecraftState... states) {
public Range build(final SpacecraftState[] states) {
final int propagatorIndex = getPropagatorsIndices()[0];
final double sigma = getTheoreticalStandardDeviation()[0];
......@@ -62,6 +65,18 @@ public class RangeBuilder extends AbstractMeasurementBuilder<Range> {
// create a dummy measurement
final Range dummy = new Range(station, twoway, state.getDate(), Double.NaN, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<Range> modifier : getModifiers()) {
dummy.addModifier(modifier);
}
// set a reference date for parameters missing one
for (final ParameterDriver driver : dummy.getParametersDrivers()) {
if (driver.getReferenceDate() == null) {
final AbsoluteDate start = getStart();
final AbsoluteDate end = getEnd();
driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
}
}
// estimate the perfect value of the measurement
double range = dummy.estimate(0, 0, states).getEstimatedValue()[0];
......@@ -73,7 +88,11 @@ public class RangeBuilder extends AbstractMeasurementBuilder<Range> {
}
// generate measurement
return new Range(station, twoway, state.getDate(), range, sigma, baseWeight, propagatorIndex);
final Range measurement = new Range(station, twoway, state.getDate(), range, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<Range> modifier : getModifiers()) {
measurement.addModifier(modifier);
}
return measurement;
}
......
......@@ -17,9 +17,12 @@
package org.orekit.estimation.measurements.generation;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.estimation.measurements.RangeRate;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Builder for {@link RangeRate} measurements.
......@@ -53,7 +56,7 @@ public class RangeRateBuilder extends AbstractMeasurementBuilder<RangeRate> {
/** {@inheritDoc} */
@Override
public RangeRate build(final SpacecraftState... states) {
public RangeRate build(final SpacecraftState[] states) {
final int propagatorIndex = getPropagatorsIndices()[0];
final double sigma = getTheoreticalStandardDeviation()[0];
......@@ -62,6 +65,18 @@ public class RangeRateBuilder extends AbstractMeasurementBuilder<RangeRate> {
// create a dummy measurement
final RangeRate dummy = new RangeRate(station, state.getDate(), Double.NaN, sigma, baseWeight, twoway, propagatorIndex);
for (final EstimationModifier<RangeRate> modifier : getModifiers()) {
dummy.addModifier(modifier);
}
// set a reference date for parameters missing one
for (final ParameterDriver driver : dummy.getParametersDrivers()) {
if (driver.getReferenceDate() == null) {
final AbsoluteDate start = getStart();
final AbsoluteDate end = getEnd();
driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
}
}
// estimate the perfect value of the measurement
double rangeRate = dummy.estimate(0, 0, states).getEstimatedValue()[0];
......@@ -73,7 +88,12 @@ public class RangeRateBuilder extends AbstractMeasurementBuilder<RangeRate> {
}
// generate measurement
return new RangeRate(station, state.getDate(), rangeRate, sigma, baseWeight, twoway, propagatorIndex);
final RangeRate measurement = new RangeRate(station, state.getDate(), rangeRate,
sigma, baseWeight, twoway, propagatorIndex);
for (final EstimationModifier<RangeRate> modifier : getModifiers()) {
measurement.addModifier(modifier);
}
return measurement;
}
......
......@@ -17,9 +17,12 @@
package org.orekit.estimation.measurements.generation;
import org.hipparchus.random.CorrelatedRandomVectorGenerator;
import org.orekit.estimation.measurements.EstimationModifier;
import org.orekit.estimation.measurements.GroundStation;
import org.orekit.estimation.measurements.TurnAroundRange;
import org.orekit.propagation.SpacecraftState;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.ParameterDriver;
/** Builder for {@link TurnAroundRange} measurements.
......@@ -53,7 +56,7 @@ public class TurnAroundRangeBuilder extends AbstractMeasurementBuilder<TurnAroun
/** {@inheritDoc} */
@Override
public TurnAroundRange build(final SpacecraftState... states) {
public TurnAroundRange build(final SpacecraftState[] states) {
final int propagatorIndex = getPropagatorsIndices()[0];
final double sigma = getTheoreticalStandardDeviation()[0];
......@@ -62,6 +65,18 @@ public class TurnAroundRangeBuilder extends AbstractMeasurementBuilder<TurnAroun
// create a dummy measurement
final TurnAroundRange dummy = new TurnAroundRange(masterStation, slaveStation, state.getDate(), Double.NaN, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<TurnAroundRange> modifier : getModifiers()) {
dummy.addModifier(modifier);
}
// set a reference date for parameters missing one
for (final ParameterDriver driver : dummy.getParametersDrivers()) {
if (driver.getReferenceDate() == null) {
final AbsoluteDate start = getStart();
final AbsoluteDate end = getEnd();
driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
}
}
// estimate the perfect value of the measurement
double range = dummy.estimate(0, 0, states).getEstimatedValue()[0];
......@@ -73,7 +88,12 @@ public class TurnAroundRangeBuilder extends AbstractMeasurementBuilder<TurnAroun
}
// generate measurement
return new TurnAroundRange(masterStation, slaveStation, state.getDate(), range, sigma, baseWeight, propagatorIndex);
final TurnAroundRange measurement = new TurnAroundRange(masterStation, slaveStation, state.getDate(),
range, sigma, baseWeight, propagatorIndex);
for (final EstimationModifier<TurnAroundRange> modifier : getModifiers()) {
measurement.addModifier(modifier);
}
return measurement;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment