Search in sources :

Example 16 with TopocentricFrame

use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.

the class OrekitEphemerisFileTest method testWritingToOEM.

@Test
public void testWritingToOEM() throws OrekitException, IOException {
    final double muTolerance = 1e-12;
    final double positionTolerance = 1e-8;
    final double velocityTolerance = 1e-8;
    final String satId = "SATELLITE1";
    final double sma = 10000000;
    final double inc = Math.toRadians(45.0);
    final double ecc = 0.001;
    final double raan = 0.0;
    final double pa = 0.0;
    final double ta = 0.0;
    final AbsoluteDate date = new AbsoluteDate();
    final Frame frame = FramesFactory.getGCRF();
    final CelestialBody body = CelestialBodyFactory.getEarth();
    final double mu = body.getGM();
    KeplerianOrbit initialOrbit = new KeplerianOrbit(sma, ecc, inc, pa, raan, ta, PositionAngle.TRUE, frame, date, mu);
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
    final double propagationDurationSeconds = 86400.0;
    final double stepSizeSeconds = 60.0;
    List<SpacecraftState> states = new ArrayList<SpacecraftState>();
    for (double dt = 0.0; dt < propagationDurationSeconds; dt += stepSizeSeconds) {
        states.add(propagator.propagate(date.shiftedBy(dt)));
    }
    OrekitEphemerisFile ephemerisFile = new OrekitEphemerisFile();
    OrekitSatelliteEphemeris satellite = ephemerisFile.addSatellite(satId);
    satellite.addNewSegment(states);
    String tempOemFile = Files.createTempFile("OrekitEphemerisFileTest", ".oem").toString();
    new OEMWriter().write(tempOemFile, ephemerisFile);
    EphemerisFile ephemerisFromFile = new OEMParser().parse(tempOemFile);
    Files.delete(Paths.get(tempOemFile));
    EphemerisSegment segment = ephemerisFromFile.getSatellites().get(satId).getSegments().get(0);
    assertEquals(states.get(0).getDate(), segment.getStart());
    assertEquals(states.get(states.size() - 1).getDate(), segment.getStop());
    assertEquals(states.size(), segment.getCoordinates().size());
    assertEquals(frame, segment.getFrame());
    assertEquals(body.getName().toUpperCase(), segment.getFrameCenterString());
    assertEquals(body.getGM(), segment.getMu(), muTolerance);
    for (int i = 0; i < states.size(); i++) {
        TimeStampedPVCoordinates expected = states.get(i).getPVCoordinates();
        TimeStampedPVCoordinates actual = segment.getCoordinates().get(i);
        assertEquals(expected.getDate(), actual.getDate());
        assertEquals(0.0, Vector3D.distance(expected.getPosition(), actual.getPosition()), positionTolerance);
        assertEquals(0.0, Vector3D.distance(expected.getVelocity(), actual.getVelocity()), velocityTolerance);
    }
    // test ingested ephemeris generates access intervals
    final OneAxisEllipsoid parentShape = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final double latitude = 0.0;
    final double longitude = 0.0;
    final double altitude = 0.0;
    final GeodeticPoint point = new GeodeticPoint(latitude, longitude, altitude);
    final TopocentricFrame topo = new TopocentricFrame(parentShape, point, "testPoint1");
    final ElevationDetector elevationDetector = new ElevationDetector(topo);
    final EphemerisSegmentPropagator ephemerisSegmentPropagator = new EphemerisSegmentPropagator(segment);
    final EventsLogger lookupLogger = new EventsLogger();
    ephemerisSegmentPropagator.addEventDetector(lookupLogger.monitorDetector(elevationDetector));
    final EventsLogger referenceLogger = new EventsLogger();
    propagator.clearEventsDetectors();
    propagator.addEventDetector(referenceLogger.monitorDetector(elevationDetector));
    propagator.propagate(segment.getStart(), segment.getStop());
    ephemerisSegmentPropagator.propagate(segment.getStart(), segment.getStop());
    final double dateEpsilon = 1.0e-9;
    assertTrue(referenceLogger.getLoggedEvents().size() > 0);
    assertEquals(referenceLogger.getLoggedEvents().size(), lookupLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = lookupLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
    final Propagator embeddedPropagator = segment.getPropagator();
    final EventsLogger embeddedPropLogger = new EventsLogger();
    embeddedPropagator.addEventDetector(embeddedPropLogger.monitorDetector(elevationDetector));
    embeddedPropagator.propagate(segment.getStart(), segment.getStop());
    assertEquals(referenceLogger.getLoggedEvents().size(), embeddedPropLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = embeddedPropLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
    final List<SpacecraftState> readInStates = new ArrayList<SpacecraftState>();
    segment.getCoordinates().forEach(c -> {
        try {
            readInStates.add(new SpacecraftState(new CartesianOrbit(c, frame, mu)));
        } catch (IllegalArgumentException | OrekitException e) {
            fail(e.getLocalizedMessage());
        }
    });
    final int interpolationPoints = 5;
    Ephemeris directEphemProp = new Ephemeris(readInStates, interpolationPoints);
    final EventsLogger directEphemPropLogger = new EventsLogger();
    directEphemProp.addEventDetector(directEphemPropLogger.monitorDetector(elevationDetector));
    directEphemProp.propagate(segment.getStart(), segment.getStop());
    assertEquals(referenceLogger.getLoggedEvents().size(), directEphemPropLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = directEphemPropLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) ElevationDetector(org.orekit.propagation.events.ElevationDetector) ArrayList(java.util.ArrayList) TopocentricFrame(org.orekit.frames.TopocentricFrame) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) OrekitSatelliteEphemeris(org.orekit.files.general.OrekitEphemerisFile.OrekitSatelliteEphemeris) EphemerisSegment(org.orekit.files.general.EphemerisFile.EphemerisSegment) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) CelestialBody(org.orekit.bodies.CelestialBody) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) GeodeticPoint(org.orekit.bodies.GeodeticPoint) OEMParser(org.orekit.files.ccsds.OEMParser) GeodeticPoint(org.orekit.bodies.GeodeticPoint) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OEMWriter(org.orekit.files.ccsds.OEMWriter) EventsLogger(org.orekit.propagation.events.EventsLogger) OrekitSatelliteEphemeris(org.orekit.files.general.OrekitEphemerisFile.OrekitSatelliteEphemeris) Ephemeris(org.orekit.propagation.analytical.Ephemeris) Test(org.junit.Test)

Example 17 with TopocentricFrame

use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.

the class BiasTest method testEstimateBias.

@SuppressWarnings("unchecked")
@Test
public void testEstimateBias() 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
    final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
    final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new RangeMeasurementCreator(context), 1.0, 3.0, 300.0);
    // create range biases: one bias for each station
    final RandomGenerator random = new Well19937a(0x0c4b69da5d64b35al);
    final Bias<?>[] stationsRangeBiases = new Bias<?>[context.stations.size()];
    final double[] realStationsBiases = new double[context.stations.size()];
    for (int i = 0; i < context.stations.size(); ++i) {
        final TopocentricFrame base = context.stations.get(i).getBaseFrame();
        stationsRangeBiases[i] = new Bias<Range>(new String[] { base.getName() + " range bias" }, new double[] { 0.0 }, new double[] { 1.0 }, new double[] { Double.NEGATIVE_INFINITY }, new double[] { Double.POSITIVE_INFINITY });
        realStationsBiases[i] = 2 * random.nextDouble() - 1;
    }
    // create orbit estimator
    final BatchLSEstimator estimator = new BatchLSEstimator(new LevenbergMarquardtOptimizer(), propagatorBuilder);
    // add the measurements, with both spacecraft and stations biases
    for (final ObservedMeasurement<?> measurement : measurements) {
        final Range range = (Range) measurement;
        for (int i = 0; i < context.stations.size(); ++i) {
            if (range.getStation() == context.stations.get(i)) {
                double biasedRange = range.getObservedValue()[0] + realStationsBiases[i];
                final Range m = new Range(range.getStation(), range.getDate(), biasedRange, range.getTheoreticalStandardDeviation()[0], range.getBaseWeight()[0]);
                m.addModifier((Bias<Range>) stationsRangeBiases[i]);
                estimator.addMeasurement(m);
            }
        }
    }
    estimator.setParametersConvergenceThreshold(1.0e-3);
    estimator.setMaxIterations(10);
    estimator.setMaxEvaluations(20);
    // we want to estimate the biases
    for (Bias<?> bias : stationsRangeBiases) {
        for (final ParameterDriver driver : bias.getParametersDrivers()) {
            driver.setSelected(true);
        }
    }
    EstimationTestUtils.checkFit(context, estimator, 2, 3, 0.0, 7.2e-7, 0.0, 2.1e-6, 0.0, 3.7e-7, 0.0, 1.7e-10);
    for (int i = 0; i < stationsRangeBiases.length; ++i) {
        Assert.assertEquals(realStationsBiases[i], stationsRangeBiases[i].getParametersDrivers().get(0).getValue(), 3.3e-6);
    }
}
Also used : Context(org.orekit.estimation.Context) Bias(org.orekit.estimation.measurements.modifiers.Bias) TopocentricFrame(org.orekit.frames.TopocentricFrame) Well19937a(org.hipparchus.random.Well19937a) Range(org.orekit.estimation.measurements.Range) ParameterDriver(org.orekit.utils.ParameterDriver) RandomGenerator(org.hipparchus.random.RandomGenerator) BatchLSEstimator(org.orekit.estimation.leastsquares.BatchLSEstimator) LevenbergMarquardtOptimizer(org.hipparchus.optim.nonlinear.vector.leastsquares.LevenbergMarquardtOptimizer) NumericalPropagatorBuilder(org.orekit.propagation.conversion.NumericalPropagatorBuilder) Propagator(org.orekit.propagation.Propagator) RangeMeasurementCreator(org.orekit.estimation.measurements.RangeMeasurementCreator) ObservedMeasurement(org.orekit.estimation.measurements.ObservedMeasurement) Test(org.junit.Test)

Example 18 with TopocentricFrame

use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.

the class ElevationDetectorTest method testPresTemp.

public void testPresTemp() 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");
    EarthStandardAtmosphereRefraction refractionModel = new EarthStandardAtmosphereRefraction();
    ElevationDetector detector = new ElevationDetector(topo).withRefraction(refractionModel).withHandler(new StopOnIncreasing<ElevationDetector>());
    refractionModel.setPressure(101325);
    refractionModel.setTemperature(290);
    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(FastMath.toRadians(1.7026104902251749), elevation, 2.0e-5);
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) PVCoordinates(org.orekit.utils.PVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) TimeScale(org.orekit.time.TimeScale) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) GeodeticPoint(org.orekit.bodies.GeodeticPoint) EarthStandardAtmosphereRefraction(org.orekit.models.earth.EarthStandardAtmosphereRefraction)

Example 19 with TopocentricFrame

use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.

the class ElevationDetectorTest method testIssue203.

@Test
public void testIssue203() throws OrekitException {
    // Initial state definition : date, orbit
    AbsoluteDate initialDate = new AbsoluteDate("2012-01-26T07:00:00.000", TimeScalesFactory.getUTC());
    // inertial frame for orbit definition
    Frame inertialFrame = FramesFactory.getEME2000();
    Orbit initialOrbit = new KeplerianOrbit(6828137.5, 7.322641060181212E-8, 1.7082667003713938, 0.0, 1.658054062748353, 1.2231496082116026E-4, PositionAngle.TRUE, inertialFrame, initialDate, Constants.WGS84_EARTH_MU);
    Propagator propagator = new EcksteinHechlerPropagator(initialOrbit, Constants.EGM96_EARTH_EQUATORIAL_RADIUS, Constants.EGM96_EARTH_MU, Constants.EGM96_EARTH_C20, Constants.EGM96_EARTH_C30, Constants.EGM96_EARTH_C40, Constants.EGM96_EARTH_C50, Constants.EGM96_EARTH_C60);
    // Earth and frame
    Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame);
    // Station
    final double longitude = FastMath.toRadians(21.0);
    final double latitude = FastMath.toRadians(67.9);
    final double altitude = 300.0;
    final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude);
    final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1");
    double[][] maskValues = { { -0.017453292519943098, 0.006981317007977318 }, { 0.0, 0.006981317007977318 }, { 0.017453292519943295, 0.006981317007977318 }, { 0.03490658503988659, 0.010471975511965976 }, { 0.05235987755982989, 0.012217304763960306 }, { 0.06981317007977318, 0.010471975511965976 }, { 0.08726646259971647, 0.010471975511965976 }, { 0.10471975511965978, 0.012217304763960306 }, { 0.12217304763960307, 0.010471975511965976 }, { 0.13962634015954636, 0.008726646259971648 }, { 0.15707963267948966, 0.008726646259971648 }, { 0.17453292519943295, 0.006981317007977318 }, { 0.19198621771937624, 0.006981317007977318 }, { 0.20943951023931956, 0.006981317007977318 }, { 0.22689280275926285, 0.005235987755982988 }, { 0.24434609527920614, 0.005235987755982988 }, { 0.2617993877991494, 0.003490658503988659 }, { 0.2792526803190927, 0.003490658503988659 }, { 0.29670597283903605, 0.0017453292519943296 }, { 0.3141592653589793, 0.003490658503988659 }, { 0.33161255787892263, 0.0017453292519943296 }, { 0.3490658503988659, 0.0 }, { 0.3665191429188092, 0.012217304763960306 }, { 0.3839724354387525, 0.012217304763960306 }, { 0.4014257279586958, 0.0 }, { 0.4188790204786391, 0.010471975511965976 }, { 0.4363323129985824, 0.029670597283903602 }, { 0.4537856055185257, 0.029670597283903602 }, { 0.47123889803846897, 0.017453292519943295 }, { 0.4886921905584123, 0.0 }, { 0.5061454830783556, 0.029670597283903602 }, { 0.5235987755982988, 0.015707963267948967 }, { 0.5410520681182421, 0.005235987755982988 }, { 0.5585053606381855, 0.024434609527920613 }, { 0.5759586531581288, 0.041887902047863905 }, { 0.5934119456780721, 0.06283185307179587 }, { 0.6108652381980153, 0.05235987755982989 }, { 0.6283185307179586, 0.05759586531581287 }, { 0.6457718232379019, 0.061086523819801536 }, { 0.6632251157578453, 0.05759586531581287 }, { 0.6806784082777885, 0.04363323129985824 }, { 0.6981317007977318, 0.059341194567807204 }, { 0.7155849933176751, 0.07504915783575616 }, { 0.7330382858376184, 0.08726646259971647 }, { 0.7504915783575618, 0.08726646259971647 }, { 0.767944870877505, 0.07330382858376185 }, { 0.7853981633974483, 0.07853981633974483 }, { 0.8028514559173916, 0.09075712110370514 }, { 0.8203047484373349, 0.0942477796076938 }, { 0.8377580409572782, 0.11519173063162574 }, { 0.8552113334772214, 0.11519173063162574 }, { 0.8726646259971648, 0.12566370614359174 }, { 0.8901179185171081, 0.12566370614359174 }, { 0.9075712110370514, 0.10122909661567112 }, { 0.9250245035569946, 0.11868238913561441 }, { 0.9424777960769379, 0.11868238913561441 }, { 0.9599310885968813, 0.11868238913561441 }, { 0.9773843811168246, 0.10821041362364843 }, { 0.9948376736367679, 0.12217304763960307 }, { 1.0122909661567112, 0.12740903539558607 }, { 1.0297442586766545, 0.11344640137963143 }, { 1.0471975511965976, 0.11344640137963143 }, { 1.064650843716541, 0.06632251157578452 }, { 1.0821041362364843, 0.12391837689159739 }, { 1.0995574287564276, 0.12391837689159739 }, { 1.117010721276371, 0.10995574287564276 }, { 1.1344640137963142, 0.09250245035569947 }, { 1.1519173063162575, 0.12740903539558607 }, { 1.1693705988362009, 0.1308996938995747 }, { 1.1868238913561442, 0.1117010721276371 }, { 1.2042771838760873, 0.1117010721276371 }, { 1.2217304763960306, 0.0942477796076938 }, { 1.239183768915974, 0.10821041362364843 }, { 1.2566370614359172, 0.09599310885968812 }, { 1.2740903539558606, 0.09948376736367678 }, { 1.2915436464758039, 0.09773843811168245 }, { 1.3089969389957472, 0.08726646259971647 }, { 1.3264502315156905, 0.09250245035569947 }, { 1.3439035240356338, 0.10122909661567112 }, { 1.361356816555577, 0.09250245035569947 }, { 1.3788101090755203, 0.08552113334772216 }, { 1.3962634015954636, 0.08726646259971647 }, { 1.413716694115407, 0.08028514559173916 }, { 1.4311699866353502, 0.05759586531581287 }, { 1.4486232791552935, 0.054105206811824215 }, { 1.4660765716752369, 0.06632251157578452 }, { 1.4835298641951802, 0.08028514559173916 }, { 1.5009831567151235, 0.061086523819801536 }, { 1.5184364492350666, 0.048869219055841226 }, { 1.53588974175501, 0.0715584993317675 }, { 1.5533430342749532, 0.07504915783575616 }, { 1.5707963267948966, 0.05235987755982989 }, { 1.5882496193148399, 0.05235987755982989 }, { 1.6057029118347832, 0.06981317007977318 }, { 1.6231562043547265, 0.054105206811824215 }, { 1.6406094968746698, 0.0645771823237902 }, { 1.6580627893946132, 0.059341194567807204 }, { 1.6755160819145565, 0.029670597283903602 }, { 1.6929693744344996, 0.03316125578789226 }, { 1.710422666954443, 0.059341194567807204 }, { 1.7278759594743862, 0.0645771823237902 }, { 1.7453292519943295, 0.06283185307179587 }, { 1.7627825445142729, 0.061086523819801536 }, { 1.7802358370342162, 0.06806784082777885 }, { 1.7976891295541595, 0.06632251157578452 }, { 1.8151424220741028, 0.059341194567807204 }, { 1.8325957145940461, 0.05759586531581287 }, { 1.8500490071139892, 0.05759586531581287 }, { 1.8675022996339325, 0.0471238898038469 }, { 1.8849555921538759, 0.059341194567807204 }, { 1.9024088846738192, 0.05061454830783556 }, { 1.9198621771937625, 0.05061454830783556 }, { 1.9373154697137058, 0.024434609527920613 }, { 1.9547687622336491, 0.027925268031909273 }, { 1.9722220547535925, 0.041887902047863905 }, { 1.9896753472735358, 0.024434609527920613 }, { 2.007128639793479, 0.029670597283903602 }, { 2.0245819323134224, 0.03316125578789226 }, { 2.0420352248333655, 0.03665191429188092 }, { 2.059488517353309, 0.04537856055185257 }, { 2.076941809873252, 0.041887902047863905 }, { 2.0943951023931953, 0.05759586531581287 }, { 2.111848394913139, 0.06283185307179587 }, { 2.129301687433082, 0.06806784082777885 }, { 2.1467549799530254, 0.05759586531581287 }, { 2.1642082724729685, 0.059341194567807204 }, { 2.181661564992912, 0.06806784082777885 }, { 2.199114857512855, 0.06283185307179587 }, { 2.2165681500327987, 0.054105206811824215 }, { 2.234021442552742, 0.05235987755982989 }, { 2.251474735072685, 0.059341194567807204 }, { 2.2689280275926285, 0.07330382858376185 }, { 2.2863813201125716, 0.06283185307179587 }, { 2.303834612632515, 0.05235987755982989 }, { 2.321287905152458, 0.061086523819801536 }, { 2.3387411976724017, 0.048869219055841226 }, { 2.356194490192345, 0.06632251157578452 }, { 2.3736477827122884, 0.05061454830783556 }, { 2.3911010752322315, 0.07679448708775051 }, { 2.4085543677521746, 0.06283185307179587 }, { 2.426007660272118, 0.05585053606381855 }, { 2.443460952792061, 0.061086523819801536 }, { 2.4609142453120048, 0.06806784082777885 }, { 2.478367537831948, 0.0645771823237902 }, { 2.4958208303518914, 0.06283185307179587 }, { 2.5132741228718345, 0.06283185307179587 }, { 2.530727415391778, 0.0645771823237902 }, { 2.548180707911721, 0.07504915783575616 }, { 2.5656340004316642, 0.0715584993317675 }, { 2.5830872929516078, 0.0645771823237902 }, { 2.600540585471551, 0.059341194567807204 }, { 2.6179938779914944, 0.06283185307179587 }, { 2.6354471705114375, 0.06632251157578452 }, { 2.652900463031381, 0.06283185307179587 }, { 2.670353755551324, 0.06632251157578452 }, { 2.6878070480712677, 0.0645771823237902 } };
    ElevationMask mask = new ElevationMask(maskValues);
    final AbsoluteDate start = new AbsoluteDate("2012-02-10T22:00:00.000", TimeScalesFactory.getUTC());
    final AbsoluteDate end = initialDate.shiftedBy(1000 * Constants.JULIAN_DAY);
    // Event definition
    final double maxcheck = 60.0;
    // 0.001;
    final double threshold = 2.0;
    final EventDetector sta1Visi = new ElevationDetector(maxcheck, threshold, sta1Frame).withElevationMask(mask).withHandler(new EventHandler<ElevationDetector>() {

        private int count = 6;

        @Override
        public Action eventOccurred(SpacecraftState s, ElevationDetector detector, boolean increasing) {
            return (--count > 0) ? Action.CONTINUE : Action.STOP;
        }
    });
    // Add event to be detected
    EventsLogger logger = new EventsLogger();
    propagator.addEventDetector(logger.monitorDetector(sta1Visi));
    // Propagate until the sixth event
    propagator.propagate(start, end);
    List<LoggedEvent> events = logger.getLoggedEvents();
    Assert.assertEquals(6, events.size());
    // despite the events 2 and 3 are closer to each other than the convergence threshold
    // the second one is not merged into the first one
    AbsoluteDate d2 = events.get(2).getState().getDate();
    AbsoluteDate d3 = events.get(3).getState().getDate();
    Assert.assertEquals(1.529, d3.durationFrom(d2), 0.01);
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) TopocentricFrame(org.orekit.frames.TopocentricFrame) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) GeodeticPoint(org.orekit.bodies.GeodeticPoint) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) ElevationMask(org.orekit.utils.ElevationMask) SpacecraftState(org.orekit.propagation.SpacecraftState) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Example 20 with TopocentricFrame

use of org.orekit.frames.TopocentricFrame in project Orekit by CS-SI.

the class ElevationDetectorTest method testAgata.

@Test
public void testAgata() 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");
    Checking checking = new Checking(topo);
    ElevationDetector detector = new ElevationDetector(topo).withConstantElevation(FastMath.toRadians(5.0)).withHandler(checking);
    Assert.assertNull(detector.getElevationMask());
    Assert.assertNull(detector.getRefractionModel());
    Assert.assertSame(topo, detector.getTopocentricFrame());
    Assert.assertEquals(FastMath.toRadians(5.0), detector.getMinElevation(), 1.0e-15);
    AbsoluteDate startDate = new AbsoluteDate(2003, 9, 15, 12, 0, 0, utc);
    propagator.resetInitialState(propagator.propagate(startDate));
    propagator.addEventDetector(detector);
    propagator.setMasterMode(10.0, checking);
    propagator.propagate(startDate.shiftedBy(Constants.JULIAN_DAY));
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) PVCoordinates(org.orekit.utils.PVCoordinates) TopocentricFrame(org.orekit.frames.TopocentricFrame) TimeScale(org.orekit.time.TimeScale) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Aggregations

TopocentricFrame (org.orekit.frames.TopocentricFrame)37 GeodeticPoint (org.orekit.bodies.GeodeticPoint)35 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)31 Test (org.junit.Test)23 AbsoluteDate (org.orekit.time.AbsoluteDate)23 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)22 Propagator (org.orekit.propagation.Propagator)19 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)19 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)17 SpacecraftState (org.orekit.propagation.SpacecraftState)16 Frame (org.orekit.frames.Frame)15 Orbit (org.orekit.orbits.Orbit)14 PVCoordinates (org.orekit.utils.PVCoordinates)14 BodyShape (org.orekit.bodies.BodyShape)13 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)9 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)8 EcksteinHechlerPropagator (org.orekit.propagation.analytical.EcksteinHechlerPropagator)8 ElevationDetector (org.orekit.propagation.events.ElevationDetector)8 HashMap (java.util.HashMap)6 LoggedEvent (org.orekit.propagation.events.EventsLogger.LoggedEvent)6