use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class OEMParser method parseEphemeridesDataLines.
/**
* Parse an ephemeris data line and add its content to the ephemerides
* block.
*
* @param reader the reader
* @param pi the parser info
* @exception IOException if an error occurs while reading from the stream
* @exception OrekitException if a date cannot be parsed
*/
private void parseEphemeridesDataLines(final BufferedReader reader, final ParseInfo pi) throws OrekitException, IOException {
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
++pi.lineNumber;
if (line.trim().length() > 0) {
pi.keyValue = new KeyValue(line, pi.lineNumber, pi.fileName);
if (pi.keyValue.getKeyword() == null) {
Scanner sc = null;
try {
sc = new Scanner(line);
final AbsoluteDate date = parseDate(sc.next(), pi.lastEphemeridesBlock.getMetaData().getTimeSystem());
final Vector3D position = new Vector3D(Double.parseDouble(sc.next()) * 1000, Double.parseDouble(sc.next()) * 1000, Double.parseDouble(sc.next()) * 1000);
final Vector3D velocity = new Vector3D(Double.parseDouble(sc.next()) * 1000, Double.parseDouble(sc.next()) * 1000, Double.parseDouble(sc.next()) * 1000);
Vector3D acceleration = Vector3D.NaN;
boolean hasAcceleration = false;
if (sc.hasNext()) {
acceleration = new Vector3D(Double.parseDouble(sc.next()) * 1000, Double.parseDouble(sc.next()) * 1000, Double.parseDouble(sc.next()) * 1000);
hasAcceleration = true;
}
final TimeStampedPVCoordinates epDataLine;
if (hasAcceleration) {
epDataLine = new TimeStampedPVCoordinates(date, position, velocity, acceleration);
} else {
epDataLine = new TimeStampedPVCoordinates(date, position, velocity);
}
pi.lastEphemeridesBlock.getEphemeridesDataLines().add(epDataLine);
pi.lastEphemeridesBlock.updateHasAcceleration(hasAcceleration);
} catch (NumberFormatException nfe) {
throw new OrekitException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, pi.lineNumber, pi.fileName, line);
} finally {
if (sc != null) {
sc.close();
}
}
} else {
switch(pi.keyValue.getKeyword()) {
case META_START:
pi.lastEphemeridesBlock.setEphemeridesDataLinesComment(pi.commentTmp);
pi.commentTmp.clear();
pi.lineNumber--;
reader.reset();
return;
case COVARIANCE_START:
pi.lastEphemeridesBlock.setEphemeridesDataLinesComment(pi.commentTmp);
pi.commentTmp.clear();
pi.lineNumber--;
reader.reset();
return;
case COMMENT:
pi.commentTmp.add(pi.keyValue.getValue());
break;
default:
throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber, pi.fileName, line);
}
}
}
reader.mark(300);
}
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class OnBoardAntennaRangeModifier method modify.
/**
* {@inheritDoc}
*/
@Override
public void modify(final EstimatedMeasurement<Range> estimated) {
// the participants are ground station at emission, spacecraft, ground station at reception
final TimeStampedPVCoordinates[] participants = estimated.getParticipants();
final Vector3D pEmission = participants[0].getPosition();
final AbsoluteDate transitDate = participants[1].getDate();
final Vector3D pReception = participants[2].getPosition();
// transform from spacecraft to inertial frame at transit date
final SpacecraftState refState = estimated.getStates()[0];
final SpacecraftState transitState = refState.shiftedBy(transitDate.durationFrom(refState.getDate()));
final Transform spacecraftToInert = transitState.toTransform().getInverse();
// compute the geometrical value of the range directly from participants positions.
// Note that this may be different from the value returned by estimated.getEstimatedValue(),
// because other modifiers may already have been taken into account
final Vector3D pSpacecraft = spacecraftToInert.transformPosition(Vector3D.ZERO);
final double rangeUsingSpacecraftCenter = 0.5 * (Vector3D.distance(pEmission, pSpacecraft) + Vector3D.distance(pSpacecraft, pReception));
// compute the geometrical value of the range replacing
// the spacecraft position with antenna phase center position
final Vector3D pAPC = spacecraftToInert.transformPosition(antennaPhaseCenter);
final double rangeUsingAntennaPhaseCenter = 0.5 * (Vector3D.distance(pEmission, pAPC) + Vector3D.distance(pAPC, pReception));
// get the estimated value before this modifier is applied
final double[] value = estimated.getEstimatedValue();
// modify the value
value[0] += rangeUsingAntennaPhaseCenter - rangeUsingSpacecraftCenter;
estimated.setEstimatedValue(value);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class OEMWriter method write.
/**
* {@inheritDoc}
*/
@Override
public void write(final Appendable writer, final EphemerisFile ephemerisFile) throws OrekitException, IOException {
if (writer == null) {
throw new OrekitIllegalArgumentException(OrekitMessages.NULL_ARGUMENT, "writer");
}
if (ephemerisFile == null) {
return;
}
final String idToProcess;
if (spaceObjectId != null) {
if (ephemerisFile.getSatellites().containsKey(spaceObjectId)) {
idToProcess = spaceObjectId;
} else {
throw new OrekitIllegalArgumentException(OrekitMessages.VALUE_NOT_FOUND, spaceObjectId, "ephemerisFile");
}
} else if (ephemerisFile.getSatellites().keySet().size() == 1) {
idToProcess = ephemerisFile.getSatellites().keySet().iterator().next();
} else {
throw new OrekitIllegalArgumentException(OrekitMessages.EPHEMERIS_FILE_NO_MULTI_SUPPORT);
}
// Get satellite and ephemeris segments to output.
final EphemerisFile.SatelliteEphemeris satEphem = ephemerisFile.getSatellites().get(idToProcess);
final List<? extends EphemerisSegment> segments = satEphem.getSegments();
if (segments.isEmpty()) {
// no data -> no output
return;
}
final EphemerisSegment firstSegment = segments.get(0);
final String objectName = this.spaceObjectName == null ? idToProcess : this.spaceObjectName;
// Only one time scale per OEM file, see Section 5.2.4.5
final TimeScale timeScale = firstSegment.getTimeScale();
// metadata that is constant for the whole OEM file
final Map<Keyword, String> metadata = new LinkedHashMap<>();
metadata.put(Keyword.TIME_SYSTEM, firstSegment.getTimeScaleString());
metadata.put(Keyword.ORIGINATOR, this.originator);
// Only one object in an OEM file, see Section 2.1
metadata.put(Keyword.OBJECT_ID, idToProcess);
metadata.put(Keyword.OBJECT_NAME, objectName);
metadata.put(Keyword.INTERPOLATION, this.interpolationMethod.toString());
final StreamingOemWriter oemWriter = new StreamingOemWriter(writer, timeScale, metadata);
oemWriter.writeHeader();
for (final EphemerisSegment segment : segments) {
// segment specific metadata
metadata.clear();
metadata.put(Keyword.CENTER_NAME, segment.getFrameCenterString());
metadata.put(Keyword.REF_FRAME, segment.getFrameString());
metadata.put(Keyword.START_TIME, segment.getStart().toString(timeScale));
metadata.put(Keyword.STOP_TIME, segment.getStop().toString(timeScale));
metadata.put(Keyword.INTERPOLATION_DEGREE, String.valueOf(segment.getInterpolationSamples() - 1));
final Segment segmentWriter = oemWriter.newSegment(null, metadata);
segmentWriter.writeMetadata();
for (final TimeStampedPVCoordinates coordinates : segment.getCoordinates()) {
segmentWriter.writeEphemerisLine(coordinates);
}
}
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class EphemerisSegmentPropagator method getPVCoordinates.
@Override
public TimeStampedPVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame) throws OrekitException {
final Stream<TimeStampedPVCoordinates> neighbors = this.cache.getNeighbors(date);
final TimeStampedPVCoordinates point = TimeStampedPVCoordinates.interpolate(date, ephemeris.getAvailableDerivatives(), neighbors);
return ephemerisFrame.getTransformTo(frame, date).transformPVCoordinates(point);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class KeplerianOrbitTest method testPositionAngleDerivatives.
@Test
public void testPositionAngleDerivatives() 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 KeplerianOrbit orbit = new KeplerianOrbit(pv, frame, mu);
for (PositionAngle type : PositionAngle.values()) {
final KeplerianOrbit rebuilt = new KeplerianOrbit(orbit.getA(), orbit.getE(), orbit.getI(), orbit.getPerigeeArgument(), orbit.getRightAscensionOfAscendingNode(), orbit.getAnomaly(type), orbit.getADot(), orbit.getEDot(), orbit.getIDot(), orbit.getPerigeeArgumentDot(), orbit.getRightAscensionOfAscendingNodeDot(), orbit.getAnomalyDot(type), type, orbit.getFrame(), orbit.getDate(), orbit.getMu());
Assert.assertThat(rebuilt.getA(), relativelyCloseTo(orbit.getA(), 1));
Assert.assertThat(rebuilt.getE(), relativelyCloseTo(orbit.getE(), 1));
Assert.assertThat(rebuilt.getI(), relativelyCloseTo(orbit.getI(), 1));
Assert.assertThat(rebuilt.getPerigeeArgument(), relativelyCloseTo(orbit.getPerigeeArgument(), 1));
Assert.assertThat(rebuilt.getRightAscensionOfAscendingNode(), relativelyCloseTo(orbit.getRightAscensionOfAscendingNode(), 1));
Assert.assertThat(rebuilt.getADot(), relativelyCloseTo(orbit.getADot(), 1));
Assert.assertThat(rebuilt.getEDot(), relativelyCloseTo(orbit.getEDot(), 1));
Assert.assertThat(rebuilt.getIDot(), relativelyCloseTo(orbit.getIDot(), 1));
Assert.assertThat(rebuilt.getPerigeeArgumentDot(), relativelyCloseTo(orbit.getPerigeeArgumentDot(), 1));
Assert.assertThat(rebuilt.getRightAscensionOfAscendingNodeDot(), relativelyCloseTo(orbit.getRightAscensionOfAscendingNodeDot(), 1));
for (PositionAngle type2 : PositionAngle.values()) {
Assert.assertThat(rebuilt.getAnomaly(type2), relativelyCloseTo(orbit.getAnomaly(type2), 1));
Assert.assertThat(rebuilt.getAnomalyDot(type2), relativelyCloseTo(orbit.getAnomalyDot(type2), 1));
}
}
}
Aggregations