use of org.orekit.time.TimeScalarFunction in project Orekit by CS-SI.
the class SolidTidesFieldTest method testK1Example.
@Test
public void testK1Example() throws OrekitException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
// the reference for this test is the example at the bottom of page 86, IERS conventions 2010 section 6.2.1
final PoissonSeriesParser k21Parser = new PoissonSeriesParser(18).withOptionalColumn(1).withDoodson(4, 3).withFirstDelaunay(10);
final String name = "/tides/tab6.5a-only-K1.txt";
final double pico = 1.0e-12;
final PoissonSeries c21Series = k21Parser.withSinCos(0, 17, pico, 18, pico).parse(getClass().getResourceAsStream(name), name);
final PoissonSeries s21Series = k21Parser.withSinCos(0, 18, -pico, 17, pico).parse(getClass().getResourceAsStream(name), name);
final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, false);
final TimeScalarFunction gmstFunction = IERSConventions.IERS_2010.getGMSTFunction(ut1);
Method getNA = IERSConventions.class.getDeclaredMethod("getNutationArguments", TimeScale.class);
getNA.setAccessible(true);
final FundamentalNutationArguments arguments = (FundamentalNutationArguments) getNA.invoke(IERSConventions.IERS_2010, ut1);
TimeVectorFunction deltaCSFunction = new TimeVectorFunction() {
public double[] value(final AbsoluteDate date) {
final BodiesElements elements = arguments.evaluateAll(date);
return new double[] { 0.0, c21Series.value(elements), s21Series.value(elements), 0.0, 0.0 };
}
public <T extends RealFieldElement<T>> T[] value(final FieldAbsoluteDate<T> date) {
// never called in this test
throw new OrekitInternalError(null);
}
};
SolidTidesField tf = new SolidTidesField(IERSConventions.IERS_2010.getLoveNumbers(), deltaCSFunction, IERSConventions.IERS_2010.getPermanentTide(), IERSConventions.IERS_2010.getSolidPoleTide(ut1.getEOPHistory()), FramesFactory.getITRF(IERSConventions.IERS_2010, false), Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, TideSystem.ZERO_TIDE, CelestialBodyFactory.getSun(), CelestialBodyFactory.getMoon());
Method frequencyDependentPart = SolidTidesField.class.getDeclaredMethod("frequencyDependentPart", AbsoluteDate.class, double[][].class, double[][].class);
frequencyDependentPart.setAccessible(true);
double[][] cachedCNM = new double[5][5];
double[][] cachedSNM = new double[5][5];
AbsoluteDate t0 = new AbsoluteDate(2003, 5, 6, 13, 43, 32.125, TimeScalesFactory.getUTC());
for (double dt = 0; dt < Constants.JULIAN_DAY; dt += 300) {
AbsoluteDate date = t0.shiftedBy(dt);
for (int i = 0; i < cachedCNM.length; ++i) {
Arrays.fill(cachedCNM[i], 0.0);
Arrays.fill(cachedSNM[i], 0.0);
}
frequencyDependentPart.invoke(tf, date, cachedCNM, cachedSNM);
double thetaPlusPi = gmstFunction.value(date) + FastMath.PI;
Assert.assertEquals(470.9e-12 * FastMath.sin(thetaPlusPi) - 30.2e-12 * FastMath.cos(thetaPlusPi), cachedCNM[2][1], 2.0e-25);
Assert.assertEquals(470.9e-12 * FastMath.cos(thetaPlusPi) + 30.2e-12 * FastMath.sin(thetaPlusPi), cachedSNM[2][1], 2.0e-25);
}
}
use of org.orekit.time.TimeScalarFunction in project Orekit by CS-SI.
the class TideTest method patchEarthRotationModel.
/**
* Patch FundamentalNutationArguments to use a simplified Earth rotation angle.
* <p>
* The angle is simply computed such that Sun is at the anti-meridian at 00h00 UT1,
* and Earth rotates at 15°/hour between 00h00 UT1 and the current date.
* </p>
* @param fna FundamentalNutationArguments to patch
* @param ut1 UT1 time scale to use for computing date components
*/
public static void patchEarthRotationModel(FundamentalNutationArguments fna, final TimeScale ut1) {
try {
final Field conventionsField = FundamentalNutationArguments.class.getDeclaredField("conventions");
conventionsField.setAccessible(true);
final IERSConventions conventions = (IERSConventions) conventionsField.get(fna);
final Field fCoeffField = FundamentalNutationArguments.class.getDeclaredField("fCoefficients");
fCoeffField.setAccessible(true);
final double[] fCoefficients = (double[]) fCoeffField.get(fna);
final Field dCoeffField = FundamentalNutationArguments.class.getDeclaredField("dCoefficients");
dCoeffField.setAccessible(true);
final double[] dCoefficients = (double[]) dCoeffField.get(fna);
final Field oCoeffField = FundamentalNutationArguments.class.getDeclaredField("omegaCoefficients");
oCoeffField.setAccessible(true);
final double[] oCoefficients = (double[]) oCoeffField.get(fna);
final Method valueMethod = FundamentalNutationArguments.class.getDeclaredMethod("value", Double.TYPE, double[].class);
valueMethod.setAccessible(true);
final Field gmstFunctionField = FundamentalNutationArguments.class.getDeclaredField("gmstFunction");
gmstFunctionField.setAccessible(true);
final TimeScalarFunction old = (TimeScalarFunction) gmstFunctionField.get(fna);
gmstFunctionField.set(fna, new TimeScalarFunction() {
private double sunAngle(AbsoluteDate date) {
try {
double tc = conventions.evaluateTC(date);
return ((Double) valueMethod.invoke(fna, tc, fCoefficients)).doubleValue() + ((Double) valueMethod.invoke(fna, tc, oCoefficients)).doubleValue() - ((Double) valueMethod.invoke(fna, tc, dCoefficients)).doubleValue();
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
return Double.NaN;
}
}
@Override
public double value(AbsoluteDate date) {
double dayFraction = date.getComponents(ut1).getTime().getSecondsInUTCDay() / Constants.JULIAN_DAY;
double v = 2 * FastMath.PI * dayFraction + sunAngle(date) + FastMath.PI;
// the patched value is about 24 arc seconds from the IERS value (almost independent on date)
double deltaArcSeconds = 3600.0 * FastMath.toDegrees(MathUtils.normalizeAngle(old.value(date) - v, 0.0));
Assert.assertEquals(0.0, deltaArcSeconds, 23.7);
return v;
}
@Override
public <T extends RealFieldElement<T>> T value(final FieldAbsoluteDate<T> date) {
return null;
}
});
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | NoSuchMethodException | SecurityException e) {
Assert.fail(e.getLocalizedMessage());
}
}
use of org.orekit.time.TimeScalarFunction in project Orekit by CS-SI.
the class IERSConventionsTest method testGMST2000vs82.
@Test
public void testGMST2000vs82() throws OrekitException {
final TimeScalarFunction gmst82 = IERSConventions.IERS_1996.getGMSTFunction(TimeScalesFactory.getUT1(IERSConventions.IERS_1996, true));
final TimeScalarFunction gmst00 = IERSConventions.IERS_2003.getGMSTFunction(TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true));
final DSFactory factory = new DSFactory(1, 1);
final FieldAbsoluteDate<DerivativeStructure> ds2000 = FieldAbsoluteDate.getJ2000Epoch(factory.getDerivativeField());
for (double dt = 0; dt < 10 * Constants.JULIAN_YEAR; dt += 10 * Constants.JULIAN_DAY) {
FieldAbsoluteDate<DerivativeStructure> date = ds2000.shiftedBy(factory.variable(0, dt));
DerivativeStructure delta = gmst00.value(date).subtract(gmst82.value(date));
// GMST82 and GMST2000 are similar to about 15 milli-arcseconds between 2000 and 2010
Assert.assertEquals(0.0, MathUtils.normalizeAngle(delta.getValue(), 0.0), 7.1e-8);
Assert.assertEquals(0.0, delta.getPartialDerivative(1), 1.0e-15);
}
}
use of org.orekit.time.TimeScalarFunction in project Orekit by CS-SI.
the class IERSConventionsTest method testGMST00Sofa.
@Test
public void testGMST00Sofa() throws OrekitException {
// the reference value has been computed using the March 2012 version of the SOFA library
// http://www.iausofa.org/2012_0301_C.html, with the following code
//
// double utc1, utc2, tai1, tai2, tt1, tt2, ut11, ut12, gmst;
//
// // 2004-02-14:00:00:00Z, MJD = 53049, UT1-UTC = -0.4093509
// utc1 = DJM0 + 53049.0;
// utc2 = 0.0;
// iauUtctai(utc1, utc2, &tai1, &tai2);
// iauTaitt(tai1, tai2, &tt1, &tt2);
// iauUtcut1(utc1, utc2, -0.4093509, &ut11, &ut12);
// gmst = iauGmst00(ut11, ut12, tt1, tt2);
// printf("iaugmst00(%.20g, %.20g, %.20g, %.20g)\n --> %.20g\n",
// ut11, ut12, tt1, tt2, gmst);
//
// // 2004-02-29:00:00:00Z, MJD = 53064, UT1-UTC = -0.4175723
// utc1 = DJM0 + 53064.0;
// utc2 = 0.0;
// iauUtctai(utc1, utc2, &tai1, &tai2);
// iauTaitt(tai1, tai2, &tt1, &tt2);
// iauUtcut1(utc1, utc2, -0.4175723, &ut11, &ut12);
// gmst = iauGmst00(ut11, ut12, tt1, tt2);
// printf("iaugmst00(%.20g, %.20g, %.20g, %.20g)\n --> %.20g\n",
// ut11, ut12, tt1, tt2, gmst);
//
// the output of this test reads:
// iaugmst00(2453049.5, -4.7378576388888813016e-06, 2453049.5, 0.00074287037037037029902)
// --> 2.5021977786243789765
// iaugmst00(2453064.5, -4.8330127314815448519e-06, 2453064.5, 0.00074287037037037029902)
// --> 2.7602390558728311376
final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2003, true);
final TimeScalarFunction gmst00 = IERSConventions.IERS_2003.getGMSTFunction(ut1);
AbsoluteDate date = new AbsoluteDate(2004, 2, 14, TimeScalesFactory.getUTC());
double gmst = MathUtils.normalizeAngle(gmst00.value(date), 0.0);
Assert.assertEquals(2.5021977786243789765, gmst, 1.0e-15);
date = new AbsoluteDate(2004, 2, 29, TimeScalesFactory.getUTC());
gmst = MathUtils.normalizeAngle(gmst00.value(date), 0.0);
Assert.assertEquals(2.7602390558728311376, gmst, 1.0e-15);
}
use of org.orekit.time.TimeScalarFunction in project Orekit by CS-SI.
the class IERSConventionsTest method testGMST2000vs2006.
@Test
public void testGMST2000vs2006() throws OrekitException {
final UT1Scale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
final TimeScalarFunction gmst00 = IERSConventions.IERS_2003.getGMSTFunction(ut1);
final TimeScalarFunction gmst06 = IERSConventions.IERS_2010.getGMSTFunction(ut1);
final DSFactory factory = new DSFactory(1, 1);
final FieldAbsoluteDate<DerivativeStructure> ds2000 = FieldAbsoluteDate.getJ2000Epoch(factory.getDerivativeField());
for (double dt = 0; dt < 10 * Constants.JULIAN_YEAR; dt += 10 * Constants.JULIAN_DAY) {
FieldAbsoluteDate<DerivativeStructure> date = ds2000.shiftedBy(factory.variable(0, dt));
DerivativeStructure delta = gmst06.value(date).subtract(gmst00.value(date));
// GMST2006 and GMST2000 are similar to about 0.15 milli-arcseconds between 2000 and 2010
Assert.assertEquals(0.0, MathUtils.normalizeAngle(delta.getValue(), 0.0), 7e-10);
Assert.assertEquals(0.0, delta.getPartialDerivative(1), 3.0e-18);
}
}
Aggregations