Search in sources :

Example 11 with DummyLocalizable

use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.

the class SolarInputs97to05 method findClosestLine.

private void findClosestLine(AbsoluteDate date) throws OrekitException {
    if ((date.durationFrom(firstDate) < 0) || (date.durationFrom(lastDate) > Constants.JULIAN_DAY)) {
        throw new OrekitException(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, date, firstDate, lastDate);
    }
    // don't search if the cached selection is fine
    if ((currentParam != null) && (date.durationFrom(currentParam.date) >= 0) && (date.durationFrom(currentParam.date) < Constants.JULIAN_DAY)) {
        return;
    }
    LineParameters before = new LineParameters(date.shiftedBy(-Constants.JULIAN_DAY), null, 0, 0, 0, 0, 0, 0);
    // search starting from entries a few steps before the target date
    SortedSet<TimeStamped> tailSet = data.tailSet(before);
    if (tailSet != null) {
        currentParam = (LineParameters) tailSet.first();
        if (currentParam.date.durationFrom(date) == -Constants.JULIAN_DAY) {
            currentParam = (LineParameters) data.tailSet(date).first();
        }
    } else {
        throw new OrekitException(new DummyLocalizable("unable to find data for date {0}"), date);
    }
}
Also used : TimeStamped(org.orekit.time.TimeStamped) DummyLocalizable(org.hipparchus.exception.DummyLocalizable) OrekitException(org.orekit.errors.OrekitException)

Example 12 with DummyLocalizable

use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.

the class DataProvidersManagerTest method testListModification.

@Test
public void testListModification() throws OrekitException {
    System.setProperty(DataProvidersManager.OREKIT_DATA_PATH, getPath("regular-data"));
    CountingLoader crawler = new CountingLoader(false);
    DataProvidersManager manager = DataProvidersManager.getInstance();
    manager.clearProviders();
    Assert.assertFalse(manager.isSupported(new DirectoryCrawler(new File(getPath("regular-data")))));
    Assert.assertTrue(manager.feed(".*", crawler));
    Assert.assertTrue(crawler.getCount() > 0);
    List<DataProvider> providers = manager.getProviders();
    Assert.assertEquals(1, providers.size());
    for (DataProvider provider : providers) {
        Assert.assertTrue(manager.isSupported(provider));
    }
    Assert.assertNotNull(manager.removeProvider(providers.get(0)));
    Assert.assertEquals(0, manager.getProviders().size());
    DataProvider provider = new DataProvider() {

        public boolean feed(Pattern supported, DataLoader visitor) throws OrekitException {
            return true;
        }
    };
    manager.addProvider(provider);
    Assert.assertEquals(1, manager.getProviders().size());
    manager.addProvider(provider);
    Assert.assertEquals(2, manager.getProviders().size());
    Assert.assertNotNull(manager.removeProvider(provider));
    Assert.assertEquals(1, manager.getProviders().size());
    Assert.assertNull(manager.removeProvider(new DataProvider() {

        public boolean feed(Pattern supported, DataLoader visitor) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("oops!"));
        }
    }));
    Assert.assertEquals(1, manager.getProviders().size());
    Assert.assertNotNull(manager.removeProvider(manager.getProviders().get(0)));
    Assert.assertEquals(0, manager.getProviders().size());
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Pattern(java.util.regex.Pattern) OrekitException(org.orekit.errors.OrekitException) File(java.io.File) Test(org.junit.Test)

Example 13 with DummyLocalizable

use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.

the class KeplerianPropagatorTest method tesWrapedAttitudeException.

@Test(expected = OrekitException.class)
public void tesWrapedAttitudeException() throws OrekitException {
    final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    KeplerianPropagator propagator = new KeplerianPropagator(orbit, new AttitudeProvider() {

        private static final long serialVersionUID = 1L;

        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
        }

        public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
            throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
        }
    });
    propagator.propagate(orbit.getDate().shiftedBy(10.09));
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) FieldAttitude(org.orekit.attitudes.FieldAttitude) Attitude(org.orekit.attitudes.Attitude) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldAttitude(org.orekit.attitudes.FieldAttitude) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Example 14 with DummyLocalizable

use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.

the class KeplerianPropagatorTest method wrongAttitude.

@Test(expected = OrekitException.class)
public void wrongAttitude() throws OrekitException {
    KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    AttitudeProvider wrongLaw = new AttitudeProvider() {

        private static final long serialVersionUID = 5918362126173997016L;

        public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }

        public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv, FieldAbsoluteDate<T> date, Frame frame) throws OrekitException {
            throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException());
        }
    };
    KeplerianPropagator propagator = new KeplerianPropagator(orbit, wrongLaw);
    propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0));
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) RealFieldElement(org.hipparchus.RealFieldElement) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) PVCoordinatesProvider(org.orekit.utils.PVCoordinatesProvider) FieldPVCoordinatesProvider(org.orekit.utils.FieldPVCoordinatesProvider) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

Example 15 with DummyLocalizable

use of org.hipparchus.exception.DummyLocalizable in project Orekit by CS-SI.

the class KeplerianPropagatorTest method testStepException.

@Test(expected = OrekitException.class)
public void testStepException() throws OrekitException {
    final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14);
    KeplerianPropagator propagator = new KeplerianPropagator(orbit);
    OrekitStepHandlerMultiplexer multiplexer = new OrekitStepHandlerMultiplexer();
    propagator.setMasterMode(multiplexer);
    multiplexer.add(new OrekitStepHandler() {

        public void init(SpacecraftState s0, AbsoluteDate t) {
        }

        public void handleStep(OrekitStepInterpolator interpolator, boolean isLast) throws OrekitException {
            if (isLast) {
                throw new OrekitException((Throwable) null, new DummyLocalizable("dummy error"));
            }
        }
    });
    propagator.propagate(orbit.getDate().shiftedBy(-3600));
}
Also used : OrekitStepHandlerMultiplexer(org.orekit.propagation.sampling.OrekitStepHandlerMultiplexer) DummyLocalizable(org.hipparchus.exception.DummyLocalizable) SpacecraftState(org.orekit.propagation.SpacecraftState) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) OrekitStepHandler(org.orekit.propagation.sampling.OrekitStepHandler) OrekitStepInterpolator(org.orekit.propagation.sampling.OrekitStepInterpolator) Test(org.junit.Test)

Aggregations

DummyLocalizable (org.hipparchus.exception.DummyLocalizable)22 OrekitException (org.orekit.errors.OrekitException)21 IOException (java.io.IOException)10 AbsoluteDate (org.orekit.time.AbsoluteDate)8 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)7 BufferedReader (java.io.BufferedReader)6 InputStreamReader (java.io.InputStreamReader)6 Test (org.junit.Test)6 AttitudeProvider (org.orekit.attitudes.AttitudeProvider)6 Frame (org.orekit.frames.Frame)6 TopocentricFrame (org.orekit.frames.TopocentricFrame)6 FieldPVCoordinatesProvider (org.orekit.utils.FieldPVCoordinatesProvider)6 PVCoordinatesProvider (org.orekit.utils.PVCoordinatesProvider)6 Matcher (java.util.regex.Matcher)4 RealFieldElement (org.hipparchus.RealFieldElement)4 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)4 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)4 InputStream (java.io.InputStream)3 Pattern (java.util.regex.Pattern)3 File (java.io.File)2