use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class OceanTidesTest method testDefaultInterpolation.
@Test
public void testDefaultInterpolation() throws OrekitException {
IERSConventions conventions = IERSConventions.IERS_2010;
Frame eme2000 = FramesFactory.getEME2000();
Frame itrf = FramesFactory.getITRF(conventions, true);
TimeScale utc = TimeScalesFactory.getUTC();
UT1Scale ut1 = TimeScalesFactory.getUT1(conventions, true);
AstronomicalAmplitudeReader aaReader = new AstronomicalAmplitudeReader("hf-fes2004.dat", 5, 2, 3, 1.0);
DataProvidersManager.getInstance().feed(aaReader.getSupportedNames(), aaReader);
Map<Integer, Double> map = aaReader.getAstronomicalAmplitudesMap();
GravityFieldFactory.addOceanTidesReader(new FESCHatEpsilonReader("fes2004-7x7.dat", 0.01, FastMath.toRadians(1.0), OceanLoadDeformationCoefficients.IERS_2010, map));
NormalizedSphericalHarmonicsProvider gravityField = GravityFieldFactory.getConstantNormalizedProvider(5, 5);
// initialization
AbsoluteDate date = new AbsoluteDate(1970, 07, 01, 13, 59, 27.816, utc);
Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, FastMath.toRadians(98.7), FastMath.toRadians(93.0), FastMath.toRadians(15.0 * 22.5), 0, PositionAngle.MEAN, eme2000, date, gravityField.getMu());
AbsoluteDate target = date.shiftedBy(7 * Constants.JULIAN_DAY);
ForceModel hf = new HolmesFeatherstoneAttractionModel(itrf, gravityField);
SpacecraftState raw = propagate(orbit, target, hf, new OceanTides(itrf, gravityField.getAe(), gravityField.getMu(), true, Double.NaN, -1, 6, 6, conventions, ut1));
SpacecraftState interpolated = propagate(orbit, target, hf, new OceanTides(itrf, gravityField.getAe(), gravityField.getMu(), 6, 6, IERSConventions.IERS_2010, ut1));
Assert.assertEquals(0.0, Vector3D.distance(raw.getPVCoordinates().getPosition(), interpolated.getPVCoordinates().getPosition()), // threshold would be 3.4e-5 for 30 days propagation
9.9e-6);
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class StreamingOemWriterTest method testWriteOemStepHandler.
/**
* Check reading and writing an OEM both with and without using the step handler
* methods.
*
* @throws Exception on error.
*/
@Test
public void testWriteOemStepHandler() throws Exception {
// setup
TimeScale utc = TimeScalesFactory.getUTC();
List<String> files = Arrays.asList("/ccsds/OEMExample5.txt", "/ccsds/OEMExample4.txt");
for (String ex : files) {
InputStream inEntry = getClass().getResourceAsStream(ex);
OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM()).withConventions(IERSConventions.IERS_2010);
OEMFile oemFile = parser.parse(inEntry, "OEMExample.txt");
OemSatelliteEphemeris satellite = oemFile.getSatellites().values().iterator().next();
EphemeridesBlock ephemerisBlock = satellite.getSegments().get(0);
Frame frame = ephemerisBlock.getFrame();
double step = ephemerisBlock.getStopTime().durationFrom(ephemerisBlock.getStartTime()) / (ephemerisBlock.getCoordinates().size() - 1);
String originator = oemFile.getOriginator();
EphemeridesBlock block = oemFile.getEphemeridesBlocks().get(0);
String objectName = block.getMetaData().getObjectName();
String objectID = block.getMetaData().getObjectID();
Map<Keyword, String> metadata = new LinkedHashMap<>();
metadata.put(Keyword.ORIGINATOR, originator);
metadata.put(Keyword.OBJECT_NAME, "will be overwritten");
metadata.put(Keyword.OBJECT_ID, objectID);
Map<Keyword, String> segmentData = new LinkedHashMap<>();
segmentData.put(Keyword.OBJECT_NAME, objectName);
// check using the Propagator / StepHandler interface
StringBuilder buffer = new StringBuilder();
StreamingOemWriter writer = new StreamingOemWriter(buffer, utc, metadata);
writer.writeHeader();
Segment segment = writer.newSegment(frame, segmentData);
BoundedPropagator propagator = satellite.getPropagator();
propagator.setMasterMode(step, segment);
propagator.propagate(propagator.getMinDate(), propagator.getMaxDate());
// verify
BufferedReader reader = new BufferedReader(new StringReader(buffer.toString()));
OEMFile generatedOemFile = parser.parse(reader, "buffer");
compareOemFiles(oemFile, generatedOemFile, 1e-7, 1e-7);
// check calling the methods directly
buffer = new StringBuilder();
writer = new StreamingOemWriter(buffer, utc, metadata);
writer.writeHeader();
// set start and stop date manually
segmentData.put(Keyword.START_TIME, StreamingOemWriter.dateToString(block.getStart().getComponents(utc)));
segmentData.put(Keyword.STOP_TIME, StreamingOemWriter.dateToString(block.getStop().getComponents(utc)));
segment = writer.newSegment(frame, segmentData);
segment.writeMetadata();
for (TimeStampedPVCoordinates coordinate : block.getCoordinates()) {
segment.writeEphemerisLine(coordinate);
}
// verify
reader = new BufferedReader(new StringReader(buffer.toString()));
generatedOemFile = parser.parse(reader, "buffer");
compareOemFiles(oemFile, generatedOemFile, 1e-7, 1e-7);
}
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class TDMParserTest method validateTDMExample6.
/**
* Validation function for example 6.
* @param file Parsed TDMFile to validate
* @throws OrekitException if UTC time scale cannot be retrieved
*/
public static void validateTDMExample6(TDMFile file) throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
// Header
Assert.assertEquals(1.0, file.getFormatVersion(), 0.0);
Assert.assertEquals(new AbsoluteDate("1998-06-10T01:00:00", utc).durationFrom(file.getCreationDate()), 0.0, 0.0);
Assert.assertEquals("JAXA", file.getOriginator());
final List<String> headerComment = new ArrayList<String>();
headerComment.add("TDM example created by yyyyy-nnnA Nav Team (JAXA)");
Assert.assertEquals(headerComment, file.getHeaderComment());
// Meta-Data
final TDMFile.TDMMetaData metaData = file.getObservationsBlocks().get(0).getMetaData();
Assert.assertEquals(CcsdsTimeScale.UTC, metaData.getTimeSystem());
Assert.assertEquals(new AbsoluteDate("1998-06-10T00:57:37", utc).durationFrom(metaData.getStartTime()), 0.0, 0.0);
Assert.assertEquals(new AbsoluteDate("1998-06-10T00:57:44", utc).durationFrom(metaData.getStopTime()), 0.0, 0.0);
Assert.assertEquals("NORTH", metaData.getParticipants().get(1));
Assert.assertEquals("F07R07", metaData.getParticipants().get(2));
Assert.assertEquals("E7", metaData.getParticipants().get(3));
Assert.assertEquals("SEQUENTIAL", metaData.getMode());
Assert.assertEquals("1,2,3,2,1", metaData.getPath());
Assert.assertEquals(1.0, metaData.getIntegrationInterval(), 0.0);
Assert.assertEquals("MIDDLE", metaData.getIntegrationRef());
Assert.assertEquals("CONSTANT", metaData.getRangeMode());
Assert.assertEquals(0.0, metaData.getRangeModulus(), 0.0);
Assert.assertEquals("KM", metaData.getRangeUnits());
Assert.assertEquals("AZEL", metaData.getAngleType());
// Data
final List<TDMFile.Observation> observations = file.getObservationsBlocks().get(0).getObservations();
// Reference data
final String[] keywords = { "RANGE", "ANGLE_1", "ANGLE_2", "TRANSMIT_FREQ_1", "RECEIVE_FREQ", "RANGE", "ANGLE_1", "ANGLE_2", "TRANSMIT_FREQ_1", "RECEIVE_FREQ", "RANGE", "ANGLE_1", "ANGLE_2", "TRANSMIT_FREQ_1", "RECEIVE_FREQ", "RANGE", "ANGLE_1", "ANGLE_2", "TRANSMIT_FREQ_1", "RECEIVE_FREQ" };
final String[] epochs = { "1998-06-10T00:57:37", "1998-06-10T00:57:37", "1998-06-10T00:57:37", "1998-06-10T00:57:37", "1998-06-10T00:57:37", "1998-06-10T00:57:38", "1998-06-10T00:57:38", "1998-06-10T00:57:38", "1998-06-10T00:57:38", "1998-06-10T00:57:38", "1998-06-10T00:57:39", "1998-06-10T00:57:39", "1998-06-10T00:57:39", "1998-06-10T00:57:39", "1998-06-10T00:57:39", "1998-06-10T00:57:44", "1998-06-10T00:57:44", "1998-06-10T00:57:44", "1998-06-10T00:57:44", "1998-06-10T00:57:44" };
final double[] values = { 80452.7542, 256.64002393, 13.38100016, 2106395199.07917, 2287487999.0, 80452.7368, 256.64002393, 13.38100016, 2106395199.07917, 2287487999.0, 80452.7197, 256.64002393, 13.38100016, 2106395199.07917, 2287487999.0, 80452.6331, 256.64002393, 13.38100016, 2106395199.07917, 2287487999.0 };
// Check consistency
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], observations.get(i).getKeyword());
Assert.assertEquals(new AbsoluteDate(epochs[i], utc).durationFrom(observations.get(i).getEpoch()), 0.0, 0.0);
Assert.assertEquals(values[i], observations.get(i).getMeasurement(), 0.0);
}
// Comment
final List<String> dataComment = new ArrayList<String>();
dataComment.add("This is a data comment");
Assert.assertEquals(dataComment, file.getObservationsBlocks().get(0).getObservationsComment());
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class TDMParserTest method validateTDMExample15.
/**
* Validation function for example 15.
* @param file Parsed TDMFile to validate
* @throws OrekitException if UTC time scale cannot be retrieved
*/
public static void validateTDMExample15(TDMFile file) throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
// Header
Assert.assertEquals(1.0, file.getFormatVersion(), 0.0);
Assert.assertEquals(new AbsoluteDate("2005-161T15:45:00", utc).durationFrom(file.getCreationDate()), 0.0, 0.0);
Assert.assertEquals("NASA/JPL", file.getOriginator());
final List<String> headerComment = new ArrayList<String>();
headerComment.add("TDM example created by yyyyy-nnnA Nav Team (NASA/JPL)");
headerComment.add("The following are clock offsets, in seconds between the");
headerComment.add("clocks at each DSN complex relative to UTC(NIST). The offset");
headerComment.add("is a mean of readings using several GPS space vehicles in");
headerComment.add("common view. Value is \"station clock minus UTC”.");
Assert.assertEquals(headerComment, file.getHeaderComment());
// Meta-Data 1
final TDMFile.TDMMetaData metaData = file.getObservationsBlocks().get(0).getMetaData();
Assert.assertEquals(CcsdsTimeScale.UTC, metaData.getTimeSystem());
Assert.assertEquals(new AbsoluteDate("2005-142T12:00:00", utc).durationFrom(metaData.getStartTime()), 0.0, 0.0);
Assert.assertEquals(new AbsoluteDate("2005-145T12:00:00", utc).durationFrom(metaData.getStopTime()), 0.0, 0.0);
Assert.assertEquals("DSS-10", metaData.getParticipants().get(1));
Assert.assertEquals("UTC-NIST", metaData.getParticipants().get(2));
final List<String> metaDataComment = new ArrayList<String>();
metaDataComment.add("Note: SPC10 switched back to Maser1 from Maser2 on 2005-142");
Assert.assertEquals(metaDataComment, metaData.getComment());
// Data 1
final List<TDMFile.Observation> observations = file.getObservationsBlocks().get(0).getObservations();
// Reference data 1
final String[] keywords = { "CLOCK_BIAS", "CLOCK_DRIFT", "CLOCK_BIAS", "CLOCK_DRIFT", "CLOCK_BIAS", "CLOCK_DRIFT", "CLOCK_BIAS" };
final String[] epochs = { "2005-142T12:00:00", "2005-142T12:00:00", "2005-143T12:00:00", "2005-143T12:00:00", "2005-144T12:00:00", "2005-144T12:00:00", "2005-145T12:00:00" };
final double[] values = { 9.56e-7, 6.944e-14, 9.62e-7, -2.083e-13, 9.44e-7, -2.778e-13, 9.20e-7 };
// Check consistency
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], observations.get(i).getKeyword());
Assert.assertEquals(new AbsoluteDate(epochs[i], utc).durationFrom(observations.get(i).getEpoch()), 0.0, 0.0);
Assert.assertEquals(values[i], observations.get(i).getMeasurement(), 0.0);
}
// Comment
final List<String> dataComment = new ArrayList<String>();
dataComment.add("This is a data comment");
Assert.assertEquals(dataComment, file.getObservationsBlocks().get(0).getObservationsComment());
// Meta-Data 2
final TDMFile.TDMMetaData metaData2 = file.getObservationsBlocks().get(1).getMetaData();
Assert.assertEquals(CcsdsTimeScale.UTC, metaData2.getTimeSystem());
Assert.assertEquals(new AbsoluteDate("2005-142T12:00:00", utc).durationFrom(metaData2.getStartTime()), 0.0, 0.0);
Assert.assertEquals(new AbsoluteDate("2005-145T12:00:00", utc).durationFrom(metaData2.getStopTime()), 0.0, 0.0);
Assert.assertEquals("DSS-40", metaData2.getParticipants().get(1));
Assert.assertEquals("UTC-NIST", metaData2.getParticipants().get(2));
final List<String> metaDataComment2 = new ArrayList<String>();
metaDataComment2.add("This is a meta-data comment");
Assert.assertEquals(metaDataComment2, metaData2.getComment());
// Data 2
final List<TDMFile.Observation> observations2 = file.getObservationsBlocks().get(1).getObservations();
// Reference data 2
// Same keywords and dates than 1
final double[] values2 = { -7.40e-7, -3.125e-13, -7.67e-7, -1.620e-13, -7.81e-7, -4.745e-13, -8.22e-7 };
// Check consistency
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], observations2.get(i).getKeyword());
Assert.assertEquals(new AbsoluteDate(epochs[i], utc).durationFrom(observations2.get(i).getEpoch()), 0.0, 0.0);
Assert.assertEquals(values2[i], observations2.get(i).getMeasurement(), 0.0);
}
// Comment
final List<String> dataComment2 = new ArrayList<String>();
dataComment2.add("This is a data comment");
Assert.assertEquals(dataComment2, file.getObservationsBlocks().get(1).getObservationsComment());
// Meta-Data 3
final TDMFile.TDMMetaData metaData3 = file.getObservationsBlocks().get(2).getMetaData();
Assert.assertEquals(CcsdsTimeScale.UTC, metaData3.getTimeSystem());
Assert.assertEquals(new AbsoluteDate("2005-142T12:00:00", utc).durationFrom(metaData3.getStartTime()), 0.0, 0.0);
Assert.assertEquals(new AbsoluteDate("2005-145T12:00:00", utc).durationFrom(metaData3.getStopTime()), 0.0, 0.0);
Assert.assertEquals("DSS-60", metaData3.getParticipants().get(1));
Assert.assertEquals("UTC-NIST", metaData3.getParticipants().get(2));
final List<String> metaDataComment3 = new ArrayList<String>();
metaDataComment3.add("This is a meta-data comment");
Assert.assertEquals(metaDataComment3, metaData3.getComment());
// Data 3
final List<TDMFile.Observation> observations3 = file.getObservationsBlocks().get(2).getObservations();
// Reference data 2
// Same keywords and dates than 1
final double[] values3 = { -1.782e-6, 1.736e-13, -1.767e-6, 1.157e-14, -1.766e-6, 8.102e-14, -1.759e-6 };
// Check consistency
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], observations3.get(i).getKeyword());
Assert.assertEquals(new AbsoluteDate(epochs[i], utc).durationFrom(observations3.get(i).getEpoch()), 0.0, 0.0);
Assert.assertEquals(values3[i], observations3.get(i).getMeasurement(), 0.0);
}
// Comment
final List<String> dataComment3 = new ArrayList<String>();
dataComment3.add("This is a data comment");
Assert.assertEquals(dataComment3, file.getObservationsBlocks().get(2).getObservationsComment());
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class TDMParserTest method validateTDMExample2.
/**
* Validation function for example 2.
* @param file Parsed TDMFile to validate
* @throws OrekitException if UTC time scale cannot be retrieved
*/
public static void validateTDMExample2(TDMFile file) throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
// Header
Assert.assertEquals(1.0, file.getFormatVersion(), 0.0);
Assert.assertEquals(new AbsoluteDate("2005-160T20:15:00", utc).durationFrom(file.getCreationDate()), 0.0, 0.0);
Assert.assertEquals("NASA/JPL", file.getOriginator());
final List<String> headerComment = new ArrayList<String>();
headerComment.add("TDM example created by yyyyy-nnnA Nav Team (NASA/JPL)");
headerComment.add("StarTrek 1-way data, Ka band down");
Assert.assertEquals(headerComment, file.getHeaderComment());
// Meta-Data
final TDMFile.TDMMetaData metaData = file.getObservationsBlocks().get(0).getMetaData();
Assert.assertEquals(CcsdsTimeScale.UTC, metaData.getTimeSystem());
Assert.assertEquals(new AbsoluteDate("2005-159T17:41:00", utc).durationFrom(metaData.getStartTime()), 0.0, 0.0);
Assert.assertEquals(new AbsoluteDate("2005-159T17:41:40", utc).durationFrom(metaData.getStopTime()), 0.0, 0.0);
Assert.assertEquals("DSS-25", metaData.getParticipants().get(1));
Assert.assertEquals("YYYY-NNNA", metaData.getParticipants().get(2));
Assert.assertEquals("SEQUENTIAL", metaData.getMode());
Assert.assertEquals("2,1", metaData.getPath());
Assert.assertEquals(1.0, metaData.getIntegrationInterval(), 0.0);
Assert.assertEquals("MIDDLE", metaData.getIntegrationRef());
Assert.assertEquals(32021035200.0, metaData.getFreqOffset(), 0.0);
Assert.assertEquals(0.000077, metaData.getTransmitDelays().get(1), 0.0);
Assert.assertEquals(0.000077, metaData.getReceiveDelays().get(1), 0.0);
Assert.assertEquals("RAW", metaData.getDataQuality());
final List<String> metaDataComment = new ArrayList<String>();
metaDataComment.add("This is a meta-data comment");
Assert.assertEquals(metaDataComment, metaData.getComment());
// Data
final List<TDMFile.Observation> observations = file.getObservationsBlocks().get(0).getObservations();
// Reference data
final String[] keywords = { "TRANSMIT_FREQ_2", "RECEIVE_FREQ_1", "RECEIVE_FREQ_1", "RECEIVE_FREQ_1", "RECEIVE_FREQ_1", "RECEIVE_FREQ_1", "RECEIVE_FREQ_1" };
final String[] epochs = { "2005-159T17:41:00", "2005-159T17:41:00", "2005-159T17:41:01", "2005-159T17:41:02", "2005-159T17:41:03", "2005-159T17:41:04", "2005-159T17:41:05" };
final double[] values = { 32023442781.733, -409.2735, -371.1568, -333.0551, -294.9673, -256.9054, -218.7951 };
// Check consistency
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], observations.get(i).getKeyword());
Assert.assertEquals(new AbsoluteDate(epochs[i], utc).durationFrom(observations.get(i).getEpoch()), 0.0, 0.0);
Assert.assertEquals(values[i], observations.get(i).getMeasurement(), 0.0);
}
// Comment
final List<String> dataComment = new ArrayList<String>();
dataComment.add("This is a data comment");
Assert.assertEquals(dataComment, file.getObservationsBlocks().get(0).getObservationsComment());
}
Aggregations