use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class GroundStationTest method testEstimateStationPosition.
@Test
public void testEstimateStationPosition() throws OrekitException, IOException, ClassNotFoundException {
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
final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new RangeMeasurementCreator(context), 1.0, 3.0, 300.0);
// move one station
final RandomGenerator random = new Well19937a(0x4adbecfc743bda60l);
final TopocentricFrame base = context.stations.get(0).getBaseFrame();
final BodyShape parent = base.getParentShape();
final Vector3D baseOrigin = parent.transform(base.getPoint());
final Vector3D deltaTopo = new Vector3D(2 * random.nextDouble() - 1, 2 * random.nextDouble() - 1, 2 * random.nextDouble() - 1);
final Transform topoToParent = base.getTransformTo(parent.getBodyFrame(), (AbsoluteDate) null);
final Vector3D deltaParent = topoToParent.transformVector(deltaTopo);
final String movedSuffix = "-moved";
final GroundStation moved = new GroundStation(new TopocentricFrame(parent, parent.transform(baseOrigin.subtract(deltaParent), parent.getBodyFrame(), null), base.getName() + movedSuffix), context.ut1.getEOPHistory(), context.stations.get(0).getDisplacements());
// create orbit estimator
final BatchLSEstimator estimator = new BatchLSEstimator(new LevenbergMarquardtOptimizer(), propagatorBuilder);
for (final ObservedMeasurement<?> measurement : measurements) {
final Range range = (Range) measurement;
final String name = range.getStation().getBaseFrame().getName() + movedSuffix;
if (moved.getBaseFrame().getName().equals(name)) {
estimator.addMeasurement(new Range(moved, range.getDate(), range.getObservedValue()[0], range.getTheoreticalStandardDeviation()[0], range.getBaseWeight()[0]));
} else {
estimator.addMeasurement(range);
}
}
estimator.setParametersConvergenceThreshold(1.0e-3);
estimator.setMaxIterations(100);
estimator.setMaxEvaluations(200);
// we want to estimate station offsets
moved.getEastOffsetDriver().setSelected(true);
moved.getNorthOffsetDriver().setSelected(true);
moved.getZenithOffsetDriver().setSelected(true);
EstimationTestUtils.checkFit(context, estimator, 2, 3, 0.0, 5.6e-7, 0.0, 1.4e-6, 0.0, 4.8e-7, 0.0, 2.6e-10);
Assert.assertEquals(deltaTopo.getX(), moved.getEastOffsetDriver().getValue(), 4.5e-7);
Assert.assertEquals(deltaTopo.getY(), moved.getNorthOffsetDriver().getValue(), 6.2e-7);
Assert.assertEquals(deltaTopo.getZ(), moved.getZenithOffsetDriver().getValue(), 2.6e-7);
GeodeticPoint result = moved.getOffsetGeodeticPoint(null);
GeodeticPoint reference = context.stations.get(0).getBaseFrame().getPoint();
Assert.assertEquals(reference.getLatitude(), result.getLatitude(), 1.4e-14);
Assert.assertEquals(reference.getLongitude(), result.getLongitude(), 2.9e-14);
Assert.assertEquals(reference.getAltitude(), result.getAltitude(), 2.6e-7);
RealMatrix normalizedCovariances = estimator.getOptimum().getCovariances(1.0e-10);
RealMatrix physicalCovariances = estimator.getPhysicalCovariances(1.0e-10);
Assert.assertEquals(9, normalizedCovariances.getRowDimension());
Assert.assertEquals(9, normalizedCovariances.getColumnDimension());
Assert.assertEquals(9, physicalCovariances.getRowDimension());
Assert.assertEquals(9, physicalCovariances.getColumnDimension());
Assert.assertEquals(0.55431, physicalCovariances.getEntry(6, 6), 1.0e-5);
Assert.assertEquals(0.22694, physicalCovariances.getEntry(7, 7), 1.0e-5);
Assert.assertEquals(0.13106, physicalCovariances.getEntry(8, 8), 1.0e-5);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(moved.getEstimatedEarthFrame().getTransformProvider());
Assert.assertTrue(bos.size() > 155000);
Assert.assertTrue(bos.size() < 160000);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
EstimatedEarthFrameProvider deserialized = (EstimatedEarthFrameProvider) ois.readObject();
Assert.assertEquals(moved.getPrimeMeridianOffsetDriver().getValue(), deserialized.getPrimeMeridianOffsetDriver().getValue(), 1.0e-15);
Assert.assertEquals(moved.getPrimeMeridianDriftDriver().getValue(), deserialized.getPrimeMeridianDriftDriver().getValue(), 1.0e-15);
Assert.assertEquals(moved.getPolarOffsetXDriver().getValue(), deserialized.getPolarOffsetXDriver().getValue(), 1.0e-15);
Assert.assertEquals(moved.getPolarDriftXDriver().getValue(), deserialized.getPolarDriftXDriver().getValue(), 1.0e-15);
Assert.assertEquals(moved.getPolarOffsetYDriver().getValue(), deserialized.getPolarOffsetYDriver().getValue(), 1.0e-15);
Assert.assertEquals(moved.getPolarDriftYDriver().getValue(), deserialized.getPolarDriftYDriver().getValue(), 1.0e-15);
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class TopocentricFrameTest method testIssue145.
@Test
public void testIssue145() throws OrekitException {
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf);
TopocentricFrame staFrame = new TopocentricFrame(earth, new GeodeticPoint(0.0, 0.0, 0.0), "test");
GeodeticPoint gp = staFrame.computeLimitVisibilityPoint(Constants.WGS84_EARTH_EQUATORIAL_RADIUS + 600000, 0.0, FastMath.toRadians(5.0));
Assert.assertEquals(0.0, gp.getLongitude(), 1.0e-15);
Assert.assertTrue(gp.getLatitude() > 0);
Assert.assertEquals(0.0, staFrame.getNorth().distance(Vector3D.PLUS_K), 1.0e-15);
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class GroundStation method getOffsetGeodeticPoint.
/**
* Get the geodetic point at the center of the offset frame.
* @param date current date (may be null if displacements are ignored)
* @return geodetic point at the center of the offset frame
* @exception OrekitException if frames transforms cannot be computed
* @since 9.1
*/
public GeodeticPoint getOffsetGeodeticPoint(final AbsoluteDate date) throws OrekitException {
// take station offset into account
final double x = parametricModel(eastOffsetDriver);
final double y = parametricModel(northOffsetDriver);
final double z = parametricModel(zenithOffsetDriver);
final BodyShape baseShape = baseFrame.getParentShape();
final Transform baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), date);
Vector3D origin = baseToBody.transformPosition(new Vector3D(x, y, z));
if (date != null) {
origin = origin.add(computeDisplacement(date, origin));
}
return baseShape.transform(origin, baseShape.getBodyFrame(), null);
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class GroundStation method getOffsetToInertial.
/**
* Get the transform between offset frame and inertial frame.
* <p>
* The offset frame takes the <em>current</em> position offset,
* polar motion and the meridian shift into account. The frame
* returned is disconnected from later changes in the parameters.
* When the {@link ParameterDriver parameters} managing these
* offsets are changed, the method must be called again to retrieve
* a new offset frame.
* </p>
* @param inertial inertial frame to transform to
* @param date date of the transform
* @return offset frame defining vectors
* @exception OrekitException if offset frame cannot be computed for current offset values
*/
public Transform getOffsetToInertial(final Frame inertial, final AbsoluteDate date) throws OrekitException {
// take Earth offsets into account
final Transform intermediateToBody = estimatedEarthFrameProvider.getTransform(date).getInverse();
// take station offset into account
final double x = parametricModel(eastOffsetDriver);
final double y = parametricModel(northOffsetDriver);
final double z = parametricModel(zenithOffsetDriver);
final BodyShape baseShape = baseFrame.getParentShape();
final Transform baseToBody = baseFrame.getTransformTo(baseShape.getBodyFrame(), date);
Vector3D origin = baseToBody.transformPosition(new Vector3D(x, y, z));
origin = origin.add(computeDisplacement(date, origin));
final GeodeticPoint originGP = baseShape.transform(origin, baseShape.getBodyFrame(), date);
final Transform offsetToIntermediate = new Transform(date, new Transform(date, new Rotation(Vector3D.PLUS_I, Vector3D.PLUS_K, originGP.getEast(), originGP.getZenith()), Vector3D.ZERO), new Transform(date, origin));
// combine all transforms together
final Transform bodyToInert = baseFrame.getParent().getTransformTo(inertial, date);
return new Transform(date, offsetToIntermediate, new Transform(date, intermediateToBody, bodyToInert));
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class FieldKeplerianPropagatorTest method doTestAltitude.
private <T extends RealFieldElement<T>> void doTestAltitude(Field<T> field) throws OrekitException {
T zero = field.getZero();
final FieldKeplerianOrbit<T> orbit = new FieldKeplerianOrbit<>(zero.add(7.8e6), zero.add(0.032), zero.add(0.4), zero.add(0.1), zero.add(0.2), zero.add(0.3), PositionAngle.TRUE, FramesFactory.getEME2000(), new FieldAbsoluteDate<>(field), 3.986004415e14);
FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit);
BodyShape bodyShape = new OneAxisEllipsoid(6378137.0, 1.0 / 298.257222101, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
FieldAltitudeDetector<T> detector = new FieldAltitudeDetector<>(orbit.getKeplerianPeriod().multiply(0.05), zero.add(1500000), bodyShape);
Assert.assertEquals(1500000, detector.getAltitude().getReal(), 1.0e-12);
propagator.addEventDetector(detector);
FieldAbsoluteDate<T> farTarget = new FieldAbsoluteDate<>(field).shiftedBy(10000.0);
FieldSpacecraftState<T> propagated = propagator.propagate(farTarget);
Assert.assertTrue(farTarget.durationFrom(propagated.getDate()).getReal() > 5400.0);
Assert.assertTrue(farTarget.durationFrom(propagated.getDate()).getReal() < 5500.0);
FieldGeodeticPoint<T> gp = bodyShape.transform(propagated.getPVCoordinates().getPosition(), propagated.getFrame(), propagated.getDate());
Assert.assertEquals(1500000, gp.getAltitude().getReal(), 0.1);
}
Aggregations