use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class ElevationDetectorTest method testIssue136.
@Test
public void testIssue136() throws OrekitException {
// Initial state definition : date, orbit
AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
// inertial frame for orbit definition
Frame inertialFrame = FramesFactory.getEME2000();
Orbit initialOrbit = new KeplerianOrbit(6828137.005, 7.322641382145889e-10, 1.6967079057368113, 0.0, 1.658054062748353, 0.0001223149429077902, PositionAngle.MEAN, inertialFrame, initialDate, Constants.EIGEN5C_EARTH_MU);
// Propagator : consider a simple Keplerian motion (could be more elaborate)
Propagator kepler = new EcksteinHechlerPropagator(initialOrbit, Constants.EGM96_EARTH_EQUATORIAL_RADIUS, Constants.EGM96_EARTH_MU, Constants.EGM96_EARTH_C20, 0.0, 0.0, 0.0, 0.0);
// 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);
// Station
final double longitude = FastMath.toRadians(-147.5);
final double latitude = FastMath.toRadians(64);
final double altitude = 160;
final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude);
final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1");
// Event definition
final double maxcheck = 120.0;
final double elevation = FastMath.toRadians(5.);
final double threshold = 10.0;
final EventDetector rawEvent = new ElevationDetector(maxcheck, threshold, sta1Frame).withConstantElevation(elevation).withHandler(new ContinueOnEvent<ElevationDetector>());
final EventsLogger logger = new EventsLogger();
kepler.addEventDetector(logger.monitorDetector(rawEvent));
// Propagate from the initial date to the first raising or for the fixed duration
kepler.propagate(initialDate.shiftedBy(60 * 60 * 24.0 * 40));
int countIncreasing = 0;
int countDecreasing = 0;
for (LoggedEvent le : logger.getLoggedEvents()) {
if (le.isIncreasing()) {
++countIncreasing;
} else {
++countDecreasing;
}
}
Assert.assertEquals(314, countIncreasing);
Assert.assertEquals(314, countDecreasing);
}
use of org.orekit.bodies.BodyShape 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);
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class GeographicZoneDetectorTest method testSerialization.
@Test
public void testSerialization() throws IOException, ClassNotFoundException, OrekitException {
final double r = Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
final BodyShape earth = new OneAxisEllipsoid(r, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
GeographicZoneDetector d = new GeographicZoneDetector(20.0, 1.e-3, earth, buildFrance(), FastMath.toRadians(0.5)).withMargin(FastMath.toRadians(0.75)).withHandler(new ContinueOnEvent<GeographicZoneDetector>());
Assert.assertEquals(r, ((OneAxisEllipsoid) d.getBody()).getEquatorialRadius(), 1.0e-12);
Assert.assertEquals(0.75, FastMath.toDegrees(d.getMargin()), 1.0e-12);
Assert.assertEquals(5.6807e11, d.getZone().getSize() * r * r, 1.0e9);
Assert.assertEquals(4.0289e6, d.getZone().getBoundarySize() * r, 1.0e3);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(d);
Assert.assertTrue(bos.size() > 2100);
Assert.assertTrue(bos.size() < 2200);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
GeographicZoneDetector deserialized = (GeographicZoneDetector) ois.readObject();
Assert.assertEquals(d.getZone().getSize(), deserialized.getZone().getSize(), 1.0e-3);
Assert.assertEquals(d.getZone().getBoundarySize(), deserialized.getZone().getBoundarySize(), 1.0e-3);
Assert.assertEquals(d.getZone().getTolerance(), deserialized.getZone().getTolerance(), 1.0e-15);
Assert.assertEquals(d.getMaxCheckInterval(), deserialized.getMaxCheckInterval(), 1.0e-15);
Assert.assertEquals(d.getThreshold(), deserialized.getThreshold(), 1.0e-15);
Assert.assertEquals(d.getMaxIterationCount(), deserialized.getMaxIterationCount());
Assert.assertTrue(new RegionFactory<Sphere2D>().difference(d.getZone(), deserialized.getZone()).isEmpty());
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class BackAndForthDetectorTest method testBackAndForth.
@Test
public void testBackAndForth() throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
final AbsoluteDate date0 = new AbsoluteDate(2006, 12, 27, 12, 0, 0.0, utc);
final AbsoluteDate date1 = new AbsoluteDate(2006, 12, 27, 22, 50, 0.0, utc);
final AbsoluteDate date2 = new AbsoluteDate(2006, 12, 27, 22, 58, 0.0, utc);
// Orbit
final double a = 7274000.;
final double e = 0.00127;
final double i = FastMath.toRadians(90.);
final double w = FastMath.toRadians(0.);
final double raan = FastMath.toRadians(12.5);
final double lM = FastMath.toRadians(60.);
Orbit iniOrb = new KeplerianOrbit(a, e, i, w, raan, lM, PositionAngle.MEAN, FramesFactory.getEME2000(), date0, Constants.WGS84_EARTH_MU);
// Propagator
KeplerianPropagator propagator = new KeplerianPropagator(iniOrb);
// Station
final GeodeticPoint stationPosition = new GeodeticPoint(FastMath.toRadians(0.), FastMath.toRadians(100.), 110.);
final BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
final TopocentricFrame stationFrame = new TopocentricFrame(earth, stationPosition, "");
// Detector
final Visibility visi = new Visibility();
propagator.addEventDetector(new ElevationDetector(stationFrame).withConstantElevation(FastMath.toRadians(10.)).withHandler(visi));
// Forward propagation (AOS + LOS)
propagator.propagate(date1);
propagator.propagate(date2);
// Backward propagation (AOS + LOS)
propagator.propagate(date1);
propagator.propagate(date0);
Assert.assertEquals(4, visi.getVisiNb());
}
use of org.orekit.bodies.BodyShape in project Orekit by CS-SI.
the class DragForceTest method testIssue229.
@Test
public void testIssue229() throws OrekitException {
AbsoluteDate initialDate = new AbsoluteDate(2004, 1, 1, 0, 0, 0., TimeScalesFactory.getUTC());
Frame frame = FramesFactory.getEME2000();
double rpe = 160.e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
double rap = 2000.e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
double inc = FastMath.toRadians(0.);
double aop = FastMath.toRadians(0.);
double raan = FastMath.toRadians(0.);
double mean = FastMath.toRadians(180.);
double mass = 100.;
KeplerianOrbit orbit = new KeplerianOrbit(0.5 * (rpe + rap), (rap - rpe) / (rpe + rap), inc, aop, raan, mean, PositionAngle.MEAN, frame, initialDate, Constants.EIGEN5C_EARTH_MU);
IsotropicDrag shape = new IsotropicDrag(10., 2.2);
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earthShape = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf);
Atmosphere atmosphere = new SimpleExponentialAtmosphere(earthShape, 2.6e-10, 200000, 26000);
double[][] tolerance = NumericalPropagator.tolerances(0.1, orbit, OrbitType.CARTESIAN);
AbstractIntegrator integrator = new DormandPrince853Integrator(1.0e-3, 300, tolerance[0], tolerance[1]);
NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setOrbitType(OrbitType.CARTESIAN);
propagator.setMu(orbit.getMu());
propagator.addForceModel(new DragForce(atmosphere, shape));
PartialDerivativesEquations partials = new PartialDerivativesEquations("partials", propagator);
propagator.setInitialState(partials.setInitialJacobians(new SpacecraftState(orbit, mass)));
SpacecraftState state = propagator.propagate(new AbsoluteDate(2004, 1, 1, 1, 30, 0., TimeScalesFactory.getUTC()));
double delta = 0.1;
Orbit shifted = new CartesianOrbit(new TimeStampedPVCoordinates(orbit.getDate(), orbit.getPVCoordinates().getPosition().add(new Vector3D(delta, 0, 0)), orbit.getPVCoordinates().getVelocity()), orbit.getFrame(), orbit.getMu());
propagator.setInitialState(partials.setInitialJacobians(new SpacecraftState(shifted, mass)));
SpacecraftState newState = propagator.propagate(new AbsoluteDate(2004, 1, 1, 1, 30, 0., TimeScalesFactory.getUTC()));
double[] dPVdX = new double[] { (newState.getPVCoordinates().getPosition().getX() - state.getPVCoordinates().getPosition().getX()) / delta, (newState.getPVCoordinates().getPosition().getY() - state.getPVCoordinates().getPosition().getY()) / delta, (newState.getPVCoordinates().getPosition().getZ() - state.getPVCoordinates().getPosition().getZ()) / delta, (newState.getPVCoordinates().getVelocity().getX() - state.getPVCoordinates().getVelocity().getX()) / delta, (newState.getPVCoordinates().getVelocity().getY() - state.getPVCoordinates().getVelocity().getY()) / delta, (newState.getPVCoordinates().getVelocity().getZ() - state.getPVCoordinates().getVelocity().getZ()) / delta };
double[][] dYdY0 = new double[6][6];
partials.getMapper().getStateJacobian(state, dYdY0);
for (int i = 0; i < 6; ++i) {
Assert.assertEquals(dPVdX[i], dYdY0[i][0], 6.2e-6 * FastMath.abs(dPVdX[i]));
}
}
Aggregations