use of org.orekit.errors.OrekitIllegalArgumentException in project Orekit by CS-SI.
the class IonoModifierTest method testTurnAroundRangeIonoModifier.
@Test
public void testTurnAroundRangeIonoModifier() 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 turn-around measurements
for (Map.Entry<GroundStation, GroundStation> entry : context.TARstations.entrySet()) {
final GroundStation masterStation = entry.getKey();
final GroundStation slaveStation = entry.getValue();
masterStation.getEastOffsetDriver().setSelected(true);
masterStation.getNorthOffsetDriver().setSelected(true);
masterStation.getZenithOffsetDriver().setSelected(true);
slaveStation.getEastOffsetDriver().setSelected(true);
slaveStation.getNorthOffsetDriver().setSelected(true);
slaveStation.getZenithOffsetDriver().setSelected(true);
}
final Propagator propagator = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
final List<ObservedMeasurement<?>> measurements = EstimationTestUtils.createMeasurements(propagator, new TurnAroundRangeMeasurementCreator(context), 1.0, 3.0, 300.0);
propagator.setSlaveMode();
final TurnAroundRangeIonosphericDelayModifier modifier = new TurnAroundRangeIonosphericDelayModifier(model);
for (final ObservedMeasurement<?> measurement : measurements) {
final AbsoluteDate date = measurement.getDate();
final SpacecraftState refstate = propagator.propagate(date);
TurnAroundRange turnAroundRange = (TurnAroundRange) measurement;
EstimatedMeasurement<TurnAroundRange> evalNoMod = turnAroundRange.estimate(12, 17, new SpacecraftState[] { refstate });
Assert.assertEquals(12, evalNoMod.getIteration());
Assert.assertEquals(17, evalNoMod.getCount());
// Add modifier
turnAroundRange.addModifier(modifier);
boolean found = false;
for (final EstimationModifier<TurnAroundRange> existing : turnAroundRange.getModifiers()) {
found = found || existing == modifier;
}
Assert.assertTrue(found);
//
EstimatedMeasurement<TurnAroundRange> eval = turnAroundRange.estimate(12, 17, new SpacecraftState[] { refstate });
Assert.assertEquals(evalNoMod.getStatus(), eval.getStatus());
eval.setStatus(EstimatedMeasurement.Status.REJECTED);
Assert.assertEquals(EstimatedMeasurement.Status.REJECTED, eval.getStatus());
eval.setStatus(evalNoMod.getStatus());
try {
eval.getParameterDerivatives(new ParameterDriver("extra", 0, 1, -1, +1));
Assert.fail("an exception should have been thrown");
} catch (OrekitIllegalArgumentException oiae) {
Assert.assertEquals(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, oiae.getSpecifier());
}
final double diffMeters = eval.getEstimatedValue()[0] - evalNoMod.getEstimatedValue()[0];
// TODO: check threshold
Assert.assertEquals(0.0, diffMeters, 30.0);
}
}
use of org.orekit.errors.OrekitIllegalArgumentException in project Orekit by CS-SI.
the class OEMWriterTest method testMultisatelliteFile.
@Test
public void testMultisatelliteFile() throws OrekitException, IOException {
final String id1 = "ID1";
final String id2 = "ID2";
StandInEphemerisFile file = new StandInEphemerisFile();
file.getSatellites().put(id1, new StandInSatelliteEphemeris(id1));
file.getSatellites().put(id2, new StandInSatelliteEphemeris(id2));
EphemerisFile ephemerisFile = (EphemerisFile) file;
String tempOEMFilePath = tempFolder.newFile("TestOEMMultisatellite-1.oem").toString();
OEMWriter writer1 = new OEMWriter();
try {
writer1.write(tempOEMFilePath, ephemerisFile);
fail("Should have thrown OrekitIllegalArgumentException due to multiple satellites");
} catch (OrekitIllegalArgumentException e) {
assertEquals(OrekitMessages.EPHEMERIS_FILE_NO_MULTI_SUPPORT, e.getSpecifier());
}
tempOEMFilePath = tempFolder.newFile("TestOEMMultisatellite-2.oem").toString();
OEMWriter writer2 = new OEMWriter(OEMWriter.DEFAULT_INTERPOLATION_METHOD, null, id1, null);
writer2.write(tempOEMFilePath, ephemerisFile);
}
use of org.orekit.errors.OrekitIllegalArgumentException in project Orekit by CS-SI.
the class OEMWriterTest method testNullFile.
@Test
public void testNullFile() throws OrekitException, IOException {
final String ex = "/ccsds/OEMExample.txt";
final InputStream inEntry = getClass().getResourceAsStream(ex);
final OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM()).withConventions(IERSConventions.IERS_2010);
final OEMFile oemFile = parser.parse(inEntry, "OEMExample.txt");
final EphemerisFile ephemerisFile = (EphemerisFile) oemFile;
String originator = oemFile.getOriginator();
String objectName = oemFile.getEphemeridesBlocks().get(0).getMetaData().getObjectName();
String objectID = oemFile.getEphemeridesBlocks().get(0).getMetaData().getObjectID();
String interpolationMethodString = oemFile.getEphemeridesBlocks().get(0).getInterpolationMethod();
InterpolationMethod interpolationMethod = Enum.valueOf(InterpolationMethod.class, interpolationMethodString);
OEMWriter writer = new OEMWriter(interpolationMethod, originator, objectID, objectName);
try {
writer.write((BufferedWriter) null, ephemerisFile);
fail("an exception should have been thrown");
} catch (OrekitIllegalArgumentException oiae) {
assertEquals(OrekitMessages.NULL_ARGUMENT, oiae.getSpecifier());
assertEquals("writer", oiae.getParts()[0]);
}
}
use of org.orekit.errors.OrekitIllegalArgumentException in project Orekit by CS-SI.
the class OPMParserTest method testParseOPM1.
@Test
public void testParseOPM1() throws OrekitException {
// simple test for OPM file, contains p/v entries and other mandatory
// data.
final String ex = "/ccsds/OPMExample.txt";
final OPMParser parser = new OPMParser().withMu(398600e9).withConventions(IERSConventions.IERS_2010).withSimpleEOP(true);
final InputStream inEntry = getClass().getResourceAsStream(ex);
final OPMFile file = parser.parse(inEntry, "OPMExample.txt");
Assert.assertEquals(IERSConventions.IERS_2010, file.getConventions());
// Check Header Block;
Assert.assertEquals(2.0, file.getFormatVersion(), 1.0e-10);
Assert.assertEquals(new AbsoluteDate(1998, 11, 06, 9, 23, 57, TimeScalesFactory.getUTC()), file.getCreationDate());
Assert.assertEquals("JAXA", file.getOriginator());
// Check Metadata Block;
Assert.assertEquals("GODZILLA 5", file.getMetaData().getObjectName());
Assert.assertEquals("1998-057A", file.getMetaData().getObjectID());
Assert.assertEquals(1998, file.getMetaData().getLaunchYear());
Assert.assertEquals(57, file.getMetaData().getLaunchNumber());
Assert.assertEquals("A", file.getMetaData().getLaunchPiece());
Assert.assertEquals("EARTH", file.getMetaData().getCenterName());
Assert.assertTrue(file.getMetaData().getHasCreatableBody());
Assert.assertEquals(CelestialBodyFactory.getEarth(), file.getMetaData().getCenterBody());
Assert.assertEquals(CCSDSFrame.ITRF97.toString(), file.getMetaData().getFrame().getName());
Assert.assertEquals(CcsdsTimeScale.TAI, file.getMetaData().getTimeSystem());
Assert.assertFalse(file.hasCovarianceMatrix());
// Check State Vector data Block;
Assert.assertEquals(new AbsoluteDate(1998, 12, 18, 14, 28, 15.1172, TimeScalesFactory.getTAI()), file.getEpoch());
checkPVEntry(new PVCoordinates(new Vector3D(6503514.000, 1239647.000, -717490.000), new Vector3D(-873.160, 8740.420, -4191.076)), file.getPVCoordinates());
try {
file.generateCartesianOrbit();
Assert.fail("an exception should have been thrown");
} catch (OrekitIllegalArgumentException oiae) {
Assert.assertEquals(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME, oiae.getSpecifier());
Assert.assertEquals("ITRF97", oiae.getParts()[0]);
}
try {
file.generateKeplerianOrbit();
Assert.fail("an exception should have been thrown");
} catch (OrekitIllegalArgumentException oiae) {
Assert.assertEquals(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME, oiae.getSpecifier());
Assert.assertEquals("ITRF97", oiae.getParts()[0]);
}
try {
file.generateSpacecraftState();
Assert.fail("an exception should have been thrown");
} catch (OrekitIllegalArgumentException oiae) {
Assert.assertEquals(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME, oiae.getSpecifier());
Assert.assertEquals("ITRF97", oiae.getParts()[0]);
}
}
use of org.orekit.errors.OrekitIllegalArgumentException in project Orekit by CS-SI.
the class FieldDateDetector method addEventDate.
/**
* Add an event date.
* <p>The date to add must be:</p>
* <ul>
* <li>less than the smallest already registered event date minus the maxCheck</li>
* <li>or more than the largest already registered event date plus the maxCheck</li>
* </ul>
* @param target target date
* @throws IllegalArgumentException if the date is too close from already defined interval
* @see #FieldDateDetector(RealFieldElement, RealFieldElement, FieldTimeStamped...)
*/
public void addEventDate(final FieldAbsoluteDate<T> target) throws IllegalArgumentException {
final boolean increasing;
if (currentIndex < 0) {
increasing = (gDate == null) ? true : target.durationFrom(gDate).getReal() > 0.0;
currentIndex = 0;
eventDateList.add(new FieldEventDate<>(target, increasing));
} else {
final int lastIndex = eventDateList.size() - 1;
if (eventDateList.get(0).getDate().durationFrom(target).getReal() > getMaxCheckInterval().getReal()) {
increasing = !eventDateList.get(0).isgIncrease();
eventDateList.add(0, new FieldEventDate<>(target, increasing));
currentIndex++;
} else if (target.durationFrom(eventDateList.get(lastIndex).getDate()).getReal() > getMaxCheckInterval().getReal()) {
increasing = !eventDateList.get(lastIndex).isgIncrease();
eventDateList.add(new FieldEventDate<>(target, increasing));
} else {
throw new OrekitIllegalArgumentException(OrekitMessages.EVENT_DATE_TOO_CLOSE, target, eventDateList.get(0).getDate(), eventDateList.get(lastIndex).getDate(), getMaxCheckInterval());
}
}
}
Aggregations