Commit b95bc940 authored by Luc Maisonobe's avatar Luc Maisonobe

added TDB time scale

(first development by Aude)
parent b5f7da94
......@@ -73,6 +73,14 @@
<role>developer</role>
</roles>
</developer>
<developer>
<name>Aude Privat</name>
<id>aude</id>
<email>Aude.Privat at c-s dot fr</email>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>
<contributors>
......@@ -94,9 +102,6 @@
<contributor>
<name>Christine Fernandez-Martin</name>
</contributor>
<contributor>
<name>Aude Privat</name>
</contributor>
<contributor>
<name>Silvia R&#237;os Berganti&#241;os</name>
</contributor>
......
......@@ -35,7 +35,7 @@ discrete events. Here is a short list of the features offered by the library:</p
<li>Time
<ul>
<li>high accuracy absolute dates</li>
<li>time scales (TAI, UTC, GPS, TCG, TT ...)</li>
<li>time scales (TAI, UTC, GPS, TCG, TT, TDB ...)</li>
<li>transparent handling of leap seconds</li>
</ul>
</li>
......
/* Copyright 2002-2008 CS Communication & Systèmes
* Licensed to CS Communication & Systèmes (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.time;
/** Barycentric Dynamic Time.
* <p>Time used to take account of time dilation when calculating orbits of planets,
* asteroids, comets and interplanetary spacecraft in the Solar system. It was based
* on a Dynamical time scale but was not well defined and not rigorously correct as
* a relativistic time scale. It was subsequently deprecated in favour of
* Barycentric Coordinate Time (TCB), but at the 2006 General Assembly of the
* International Astronomical Union TDB was rehabilitated by making it a specific
* fixed linear transformation of TCB.</p>
* <p>By convention, TDB = TT + 0.001658 sin(g) + 0.000014 sin(2g)seconds
* where g = 357.53 + 0.9856003 (JD - 2451545) degrees.</p>
* <p>This is a singleton class, so there is no public constructor.</p>
* @author Aude Privat
* @see AbsoluteDate
* @version $Revision:1665 $ $Date:2008-06-11 12:12:59 +0200 (mer., 11 juin 2008) $
*/
public class TDBScale implements TimeScale {
/** Serializable UID. */
private static final long serialVersionUID = -1586357980576711360L;
/** Package private constructor for the factory.
*/
TDBScale() {
}
/** {@inheritDoc} */
public double offsetFromTAI(final AbsoluteDate date) {
final double dtDays = date.durationFrom(AbsoluteDate.J2000_EPOCH) / 86400;
final double g = Math.toRadians(357.53 + 0.9856003 * dtDays);
return TimeScalesFactory.getTT().offsetFromTAI(date) + (0.001658 * Math.sin(g) + 0.000014 * Math.sin(2 * g));
}
/** {@inheritDoc} */
public double offsetToTAI(final DateComponents date, final TimeComponents time) {
final AbsoluteDate reference = new AbsoluteDate(date, time, TimeScalesFactory.getTAI());
double offset = 0;
for (int i = 0; i < 3; i++){
offset = -offsetFromTAI(new AbsoluteDate(reference, offset));
}
return offset;
}
/** {@inheritDoc} */
public String getName() {
return "TDB";
}
/** {@inheritDoc} */
public String toString() {
return getName();
}
}
......@@ -46,6 +46,9 @@ public class TimeScalesFactory implements Serializable {
/** Geocentric Coordinate Time scale. */
private static TCGScale tcg = null;
/** Barycentric Dynamic Coordinate Time scale. */
private static TDBScale tdb = null;
/** Private constructor.
* <p>This class is a utility class, it should neither have a public
......@@ -131,4 +134,19 @@ public class TimeScalesFactory implements Serializable {
}
}
/** Get the Barycentric Dynamic Time scale.
* @return Barycentric Dynamic Time scale
*/
public static TDBScale getTDB() {
synchronized (TimeScalesFactory.class) {
if (tdb == null) {
tdb = new TDBScale();
}
return tdb;
}
}
}
......@@ -26,7 +26,7 @@ Overview
* high accuracy absolute dates
* time scales (TAI, UTC, GPS, TCG, TT, ...)
* time scales (TAI, UTC, GPS, TCG, TT, TDB ...)
* transparent handling of leap seconds
......
......@@ -31,6 +31,9 @@
to retrieve gravity potential files. This mechanism has also been vastly improved
to support new use cases (loading from disk, from classpath, from network delegating
loading to an external library ...)">
<action dev="aude" type="add" >
added TDB time scale
</action>
<action dev="luc" type="update" >
the RadiationSensitive and DragForce interfaces now have an
additional SpacecraftState parameter in all their get methods.
......
package org.orekit.time;
import org.junit.Assert;
import org.junit.Test;
public class TDBScaleTest {
@Test
public void testReference() {
TimeScale scale = TimeScalesFactory.getTDB();
Assert.assertEquals("TDB", scale.toString());
Assert.assertEquals(32.183927340791372839, scale.offsetFromTAI(AbsoluteDate.J2000_EPOCH), 1.0e-15);
}
@Test
public void testDate5000000() {
TimeScale scale = TimeScalesFactory.getTDB();
AbsoluteDate date = new AbsoluteDate(AbsoluteDate.J2000_EPOCH, 5000000);
Assert.assertEquals(32.185364155950634549, scale.offsetFromTAI(date), 1.0e-13);
}
@Test
public void testToTAI5000000() {
TimeScale scale = TimeScalesFactory.getTDB();
AbsoluteDate date = new AbsoluteDate(2000, 2, 28, 8, 53, 20.001364155950634549, scale);
double dt = new AbsoluteDate(AbsoluteDate.J2000_EPOCH, 5000000).durationFrom(date);
Assert.assertTrue(Math.abs(dt) < 1.0e-13);
}
@Test
public void testToTAI() {
TimeScale scale = TimeScalesFactory.getTDB();
AbsoluteDate date = new AbsoluteDate(2000, 01, 01, 11, 59, 59.999927340791372839, scale);
double dt = AbsoluteDate.J2000_EPOCH.durationFrom(date);
Assert.assertTrue(Math.abs(dt) < 1.0e-13);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment