Search in sources :

Example 81 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class NetworkCrawler method feed.

/**
 * {@inheritDoc}
 */
public boolean feed(final Pattern supported, final DataLoader visitor) throws OrekitException {
    try {
        OrekitException delayedException = null;
        boolean loaded = false;
        for (URL url : urls) {
            try {
                if (visitor.stillAcceptsData()) {
                    final String name = url.toURI().toString();
                    final String fileName = new File(url.getPath()).getName();
                    if (ZIP_ARCHIVE_PATTERN.matcher(fileName).matches()) {
                        // browse inside the zip/jar file
                        new ZipJarCrawler(url).feed(supported, visitor);
                        loaded = true;
                    } else {
                        // remove suffix from gzip files
                        final Matcher gzipMatcher = GZIP_FILE_PATTERN.matcher(fileName);
                        final String baseName = gzipMatcher.matches() ? gzipMatcher.group(1) : fileName;
                        if (supported.matcher(baseName).matches()) {
                            final InputStream stream = getStream(url);
                            // visit the current file
                            if (gzipMatcher.matches()) {
                                visitor.loadData(new GZIPInputStream(stream), name);
                            } else {
                                visitor.loadData(stream, name);
                            }
                            stream.close();
                            loaded = true;
                        }
                    }
                }
            } catch (OrekitException oe) {
                // maybe the next path component will be able to provide data
                // wait until all components have been tried
                delayedException = oe;
            }
        }
        if (!loaded && delayedException != null) {
            throw delayedException;
        }
        return loaded;
    } catch (URISyntaxException | IOException | ParseException e) {
        throw new OrekitException(e, new DummyLocalizable(e.getMessage()));
    }
}
Also used : DummyLocalizable(org.hipparchus.exception.DummyLocalizable) Matcher(java.util.regex.Matcher) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) URL(java.net.URL) GZIPInputStream(java.util.zip.GZIPInputStream) OrekitException(org.orekit.errors.OrekitException) ParseException(java.text.ParseException) File(java.io.File)

Example 82 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class Attitude method interpolate.

/**
 * {@inheritDoc}
 * <p>
 * The interpolated instance is created by polynomial Hermite interpolation
 * on Rodrigues vector ensuring rotation rate remains the exact derivative of rotation.
 * </p>
 * <p>
 * As this implementation of interpolation is polynomial, it should be used only
 * with small samples (about 10-20 points) in order to avoid <a
 * href="http://en.wikipedia.org/wiki/Runge%27s_phenomenon">Runge's phenomenon</a>
 * and numerical problems (including NaN appearing).
 * </p>
 * @exception OrekitException if the number of point is too small for interpolating
 */
public Attitude interpolate(final AbsoluteDate interpolationDate, final Stream<Attitude> sample) throws OrekitException {
    final List<TimeStampedAngularCoordinates> datedPV = sample.map(attitude -> attitude.orientation).collect(Collectors.toList());
    final TimeStampedAngularCoordinates interpolated = TimeStampedAngularCoordinates.interpolate(interpolationDate, AngularDerivativesFilter.USE_RR, datedPV);
    return new Attitude(referenceFrame, interpolated);
}
Also used : AngularCoordinates(org.orekit.utils.AngularCoordinates) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) Frame(org.orekit.frames.Frame) TimeInterpolable(org.orekit.time.TimeInterpolable) AngularDerivativesFilter(org.orekit.utils.AngularDerivativesFilter) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) RotationConvention(org.hipparchus.geometry.euclidean.threed.RotationConvention) List(java.util.List) Stream(java.util.stream.Stream) OrekitException(org.orekit.errors.OrekitException) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates) Transform(org.orekit.frames.Transform) TimeShiftable(org.orekit.time.TimeShiftable) AbsoluteDate(org.orekit.time.AbsoluteDate) TimeStamped(org.orekit.time.TimeStamped) TimeStampedAngularCoordinates(org.orekit.utils.TimeStampedAngularCoordinates)

Example 83 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class GRGSFormatReaderTest method testReadLimits.

@Test
public void testReadLimits() throws OrekitException {
    GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim5_C1.dat", true));
    UnnormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getUnnormalizedProvider(3, 2);
    UnnormalizedSphericalHarmonics harmonics = provider.onDate(provider.getReferenceDate());
    try {
        harmonics.getUnnormalizedCnm(3, 3);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
    // expected
    } catch (Exception e) {
        Assert.fail("wrong exception caught: " + e.getLocalizedMessage());
    }
    try {
        harmonics.getUnnormalizedCnm(4, 2);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
    // expected
    } catch (Exception e) {
        Assert.fail("wrong exception caught: " + e.getLocalizedMessage());
    }
    harmonics.getUnnormalizedCnm(3, 2);
    Assert.assertEquals(3, provider.getMaxDegree());
    Assert.assertEquals(2, provider.getMaxOrder());
}
Also used : OrekitException(org.orekit.errors.OrekitException) UnnormalizedSphericalHarmonics(org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Example 84 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class GravityFieldFactoryTest method testDefaultGRGSMissingCoefficients.

@Test
public void testDefaultGRGSMissingCoefficients() throws OrekitException {
    Utils.setDataRoot("potential/grgs-format");
    // to make sure we use only the default readers
    try {
        GravityFieldFactory.getUnnormalizedProvider(5, 3);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.MISSING_GRAVITY_FIELD_COEFFICIENT_IN_FILE, oe.getSpecifier());
        Assert.assertEquals("grim5_C1.dat", new File((String) oe.getParts()[3]).getName());
    }
}
Also used : OrekitException(org.orekit.errors.OrekitException) File(java.io.File) Test(org.junit.Test)

Example 85 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class CartesianOrbitTest method testNonKeplerianDerivatives.

@Test
public void testNonKeplerianDerivatives() throws OrekitException {
    final AbsoluteDate date = new AbsoluteDate("2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
    final Vector3D position = new Vector3D(6896874.444705, 1956581.072644, -147476.245054);
    final Vector3D velocity = new Vector3D(166.816407662, -1106.783301861, -7372.745712770);
    final Vector3D acceleration = new Vector3D(-7.466182457944, -2.118153357345, 0.160004048437);
    final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(date, position, velocity, acceleration);
    final Frame frame = FramesFactory.getEME2000();
    final double mu = Constants.EIGEN5C_EARTH_MU;
    final CartesianOrbit orbit = new CartesianOrbit(pv, frame, mu);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getA()), orbit.getADot(), 4.3e-8);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEx()), orbit.getEquinoctialExDot(), 2.1e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getEquinoctialEy()), orbit.getEquinoctialEyDot(), 5.3e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHx()), orbit.getHxDot(), 4.4e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getHy()), orbit.getHyDot(), 8.0e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLv()), orbit.getLvDot(), 1.2e-15);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLE()), orbit.getLEDot(), 7.8e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getLM()), orbit.getLMDot(), 8.8e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getE()), orbit.getEDot(), 7.0e-16);
    Assert.assertEquals(differentiate(pv, frame, mu, shifted -> shifted.getI()), orbit.getIDot(), 5.7e-16);
}
Also used : TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Frame(org.orekit.frames.Frame) ObjectInputStream(java.io.ObjectInputStream) RealMatrixPreservingVisitor(org.hipparchus.linear.RealMatrixPreservingVisitor) Function(java.util.function.Function) PVCoordinates(org.orekit.utils.PVCoordinates) ArrayList(java.util.ArrayList) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) After(org.junit.After) ObjectOutputStream(java.io.ObjectOutputStream) FastMath(org.hipparchus.util.FastMath) Method(java.lang.reflect.Method) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Utils(org.orekit.Utils) Before(org.junit.Before) Constants(org.orekit.utils.Constants) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) FramesFactory(org.orekit.frames.FramesFactory) IOException(java.io.IOException) Test(org.junit.Test) InvocationTargetException(java.lang.reflect.InvocationTargetException) MathUtils(org.hipparchus.util.MathUtils) List(java.util.List) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) OrekitException(org.orekit.errors.OrekitException) TimeScalesFactory(org.orekit.time.TimeScalesFactory) MatrixUtils(org.hipparchus.linear.MatrixUtils) Transform(org.orekit.frames.Transform) Assert(org.junit.Assert) AbsoluteDate(org.orekit.time.AbsoluteDate) Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

OrekitException (org.orekit.errors.OrekitException)332 AbsoluteDate (org.orekit.time.AbsoluteDate)150 Test (org.junit.Test)135 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)91 SpacecraftState (org.orekit.propagation.SpacecraftState)75 Frame (org.orekit.frames.Frame)62 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)59 ArrayList (java.util.ArrayList)48 Before (org.junit.Before)48 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)42 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)42 DateComponents (org.orekit.time.DateComponents)42 GeodeticPoint (org.orekit.bodies.GeodeticPoint)41 Orbit (org.orekit.orbits.Orbit)40 PVCoordinates (org.orekit.utils.PVCoordinates)37 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)36 IOException (java.io.IOException)32 InputStream (java.io.InputStream)31 Propagator (org.orekit.propagation.Propagator)30 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)28