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()));
}
}
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);
}
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());
}
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());
}
}
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);
}
Aggregations