use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class TideTest method doTestSort.
private void doTestSort(int tauMultiplier, Tide... tides) throws OrekitException {
// this test checks that tides sort order is date-independent for a large time range
// (almost 180000 years long)
// tides sort-order is based on rate, but the rates varies slightly with dates
// (because Delaunay nutation arguments are polynomials)
// The variations are however small and we want to make sure
// that if rate(tideA) < rate(tideB) at time t0, this order remains
// the same for t1 a few millenia around t0
TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
FundamentalNutationArguments fna = IERSConventions.IERS_2010.getNutationArguments(ut1);
for (double dt = -122000; dt < 54000; dt += 100) {
final AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt * Constants.JULIAN_YEAR);
final BodiesElements el = fna.evaluateAll(date);
for (int i = 1; i < tides.length; ++i) {
Assert.assertTrue(tides[i - 1].getRate(el) < tides[i].getRate(el));
}
}
// check we are in the expected species
for (final Tide tide : tides) {
Assert.assertEquals(tauMultiplier, tide.getTauMultiplier());
}
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class EclipticProviderTest method testAgreementWith406Ephemerides.
/**
* Check the Ecliptic frame defined from IERS mean obliquity equations against the
* position of Sun and Earth from the JPL 406 ephemerides.
*
* @throws Exception on error
*/
@Test
public void testAgreementWith406Ephemerides() throws Exception {
TimeScale utc = TimeScalesFactory.getUTC();
// time spans we have test data sets for.
checkAlignment(new AbsoluteDate(1969, 5, 27, utc), new AbsoluteDate(1969, 9, 20, utc));
checkAlignment(new AbsoluteDate(1969, 12, 5, utc), new AbsoluteDate(1970, 4, 1, utc));
checkAlignment(new AbsoluteDate(1970, 6, 15, utc), new AbsoluteDate(1970, 8, 1, utc));
checkAlignment(new AbsoluteDate(2002, 12, 16, utc), new AbsoluteDate(2004, 2, 3, utc));
checkAlignment(new AbsoluteDate(1999, 11, 22, utc), new AbsoluteDate(2000, 5, 21, utc));
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class TidalDisplacementTest method doTestDehant.
private void doTestDehant(final IERSConventions conventions, final boolean removePermanentDeformation, final boolean replaceModels, final double expectedDx, final double expectedDy, final double expectedDz, final double tolerance) throws OrekitException {
Frame itrf = FramesFactory.getITRF(conventions, false);
TimeScale ut1 = TimeScalesFactory.getUT1(conventions, false);
final double re;
final double sunEarthSystemMassRatio;
final double earthMoonMassRatio;
if (replaceModels) {
// constants consistent with DEHANTTIDEINEL.F reference program
// available at <ftp://tai.bipm.org/iers/conv2010/chapter7/dehanttideinel/>
// and Copyright (C) 2008 IERS Conventions Center
re = 6378136.6;
final double massRatioSun = 332946.0482;
final double massRatioMoon = 0.0123000371;
sunEarthSystemMassRatio = massRatioSun * (1.0 / (1.0 + massRatioMoon));
earthMoonMassRatio = 1.0 / massRatioMoon;
} else {
// constants consistent with IERS and JPL
re = Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS;
sunEarthSystemMassRatio = Constants.JPL_SSD_SUN_EARTH_PLUS_MOON_MASS_RATIO;
earthMoonMassRatio = Constants.JPL_SSD_EARTH_MOON_MASS_RATIO;
}
// fake providers generating only the positions from the reference program test
PVCoordinatesProvider fakeSun = (date, frame) -> new TimeStampedPVCoordinates(date, new Vector3D(137859926952.015, 54228127881.435, 23509422341.6960), Vector3D.ZERO, Vector3D.ZERO);
PVCoordinatesProvider fakeMoon = (date, frame) -> new TimeStampedPVCoordinates(date, new Vector3D(-179996231.920342, -312468450.131567, -169288918.592160), Vector3D.ZERO, Vector3D.ZERO);
TidalDisplacement td = new TidalDisplacement(re, sunEarthSystemMassRatio, earthMoonMassRatio, fakeSun, fakeMoon, conventions, removePermanentDeformation);
FundamentalNutationArguments arguments = null;
if (replaceModels) {
try {
// we override the official IERS conventions 2010 arguments with fake arguments matching DEHANTTIDEINEL.F code
String regularArguments = "/assets/org/orekit/IERS-conventions/2010/nutation-arguments.txt";
arguments = new FundamentalNutationArguments(conventions, ut1, IERSConventions.class.getResourceAsStream(regularArguments), regularArguments) {
private static final long serialVersionUID = 20170913L;
@Override
public BodiesElements evaluateAll(final AbsoluteDate date) {
BodiesElements base = super.evaluateAll(date);
double fhr = date.getComponents(ut1).getTime().getSecondsInUTCDay() / 3600.0;
double t = base.getTC();
// Doodson fundamental arguments as per DEHANTTIDEINEL.F code
double s = 218.31664563 + (481267.88194 + (-0.0014663889 + (0.00000185139) * t) * t) * t;
double tau = fhr * 15 + 280.4606184 + (36000.7700536 + (0.00038793 + (-0.0000000258) * t) * t) * t - s;
double pr = (1.396971278 + (0.000308889 + (0.000000021 + (0.000000007) * t) * t) * t) * t;
double h = 280.46645 + (36000.7697489 + (0.00030322222 + (0.000000020 + (-0.00000000654) * t) * t) * t) * t;
double p = 83.35324312 + (4069.01363525 + (-0.01032172222 + (-0.0000124991 + (0.00000005263) * t) * t) * t) * t;
double zns = 234.95544499 + (1934.13626197 + (-0.00207561111 + (-0.00000213944 + (0.00000001650) * t) * t) * t) * t;
double ps = 282.93734098 + (1.71945766667 + (0.00045688889 + (-0.00000001778 + (-0.00000000334) * t) * t) * t) * t;
s += pr;
// rebuild Delaunay arguments from Doodson arguments, ignoring derivatives
return new BodiesElements(date, base.getTC(), FastMath.toRadians(s + tau), 0.0, FastMath.toRadians(s - p), 0.0, FastMath.toRadians(h - ps), 0.0, FastMath.toRadians(s + zns), 0.0, FastMath.toRadians(s - h), 0.0, FastMath.toRadians(-zns), 0.0, base.getLMe(), 0.0, base.getLVe(), 0.0, base.getLE(), 0.0, base.getLMa(), 0.0, base.getLJu(), 0.0, base.getLSa(), 0.0, base.getLUr(), 0.0, base.getLNe(), 0.0, base.getPa(), 0.0);
}
};
// we override the official IERS conventions 2010 tides displacements with tides displacements matching DEHANTTIDEINEL.F code
String table73a = "/tides/tab7.3a-Dehant.txt";
Field diurnalCorrectionField = td.getClass().getDeclaredField("frequencyCorrectionDiurnal");
diurnalCorrectionField.setAccessible(true);
Method diurnalCorrectionGetter = IERSConventions.class.getDeclaredMethod("getTidalDisplacementFrequencyCorrectionDiurnal", String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE);
diurnalCorrectionGetter.setAccessible(true);
diurnalCorrectionField.set(td, diurnalCorrectionGetter.invoke(null, table73a, 18, 15, 16, 17, 18));
} catch (SecurityException | NoSuchMethodException | NoSuchFieldException | InvocationTargetException | IllegalArgumentException | IllegalAccessException e) {
Assert.fail(e.getLocalizedMessage());
}
} else {
arguments = conventions.getNutationArguments(ut1);
}
Vector3D fundamentalStationWettzell = new Vector3D(4075578.385, 931852.890, 4801570.154);
AbsoluteDate date = new AbsoluteDate(2009, 4, 13, 0, 0, 0.0, ut1);
Vector3D displacement = td.displacement(arguments.evaluateAll(date), itrf, fundamentalStationWettzell);
Assert.assertEquals(expectedDx, displacement.getX(), tolerance);
Assert.assertEquals(expectedDy, displacement.getY(), tolerance);
Assert.assertEquals(expectedDz, displacement.getZ(), tolerance);
}
use of org.orekit.time.TimeScale 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.time.TimeScale in project Orekit by CS-SI.
the class FieldKeplerianPropagatorTest method doTestIssue107.
private <T extends RealFieldElement<T>> void doTestIssue107(Field<T> field) throws OrekitException {
T zero = field.getZero();
final TimeScale utc = TimeScalesFactory.getUTC();
final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.56), zero.add(-25767.257));
final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.848), zero.add(942.781), zero.add(7435.922));
final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2003, 9, 16, utc);
final FieldOrbit<T> orbit = new FieldCircularOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, mu);
FieldPropagator<T> propagator = new FieldKeplerianPropagator<T>(orbit) {
FieldAbsoluteDate<T> lastDate = FieldAbsoluteDate.getPastInfinity(field);
protected FieldSpacecraftState<T> basicPropagate(final FieldAbsoluteDate<T> date) throws OrekitException {
if (date.compareTo(lastDate) < 0) {
throw new OrekitException(LocalizedCoreFormats.SIMPLE_MESSAGE, "no backward propagation allowed");
}
lastDate = date;
return super.basicPropagate(date);
}
};
FieldSpacecraftState<T> finalState = propagator.propagate(date.shiftedBy(3600.0));
Assert.assertEquals(3600.0, finalState.getDate().durationFrom(date).getReal(), 1.0e-15);
}
Aggregations