source: trunk/FACT++/erfa/src/tcbtdb.c@ 18403

Last change on this file since 18403 was 18348, checked in by tbretz, 9 years ago
File size: 5.4 KB
Line 
1#include "erfa.h"
2
3int eraTcbtdb(double tcb1, double tcb2, double *tdb1, double *tdb2)
4/*
5** - - - - - - - - - -
6** e r a T c b t d b
7** - - - - - - - - - -
8**
9** Time scale transformation: Barycentric Coordinate Time, TCB, to
10** Barycentric Dynamical Time, TDB.
11**
12** Given:
13** tcb1,tcb2 double TCB as a 2-part Julian Date
14**
15** Returned:
16** tdb1,tdb2 double TDB as a 2-part Julian Date
17**
18** Returned (function value):
19** int status: 0 = OK
20**
21** Notes:
22**
23** 1) tcb1+tcb2 is Julian Date, apportioned in any convenient way
24** between the two arguments, for example where tcb1 is the Julian
25** Day Number and tcb2 is the fraction of a day. The returned
26** tdb1,tdb2 follow suit.
27**
28** 2) The 2006 IAU General Assembly introduced a conventional linear
29** transformation between TDB and TCB. This transformation
30** compensates for the drift between TCB and terrestrial time TT,
31** and keeps TDB approximately centered on TT. Because the
32** relationship between TT and TCB depends on the adopted solar
33** system ephemeris, the degree of alignment between TDB and TT over
34** long intervals will vary according to which ephemeris is used.
35** Former definitions of TDB attempted to avoid this problem by
36** stipulating that TDB and TT should differ only by periodic
37** effects. This is a good description of the nature of the
38** relationship but eluded precise mathematical formulation. The
39** conventional linear relationship adopted in 2006 sidestepped
40** these difficulties whilst delivering a TDB that in practice was
41** consistent with values before that date.
42**
43** 3) TDB is essentially the same as Teph, the time argument for the
44** JPL solar system ephemerides.
45**
46** Reference:
47**
48** IAU 2006 Resolution B3
49**
50** Copyright (C) 2013-2015, NumFOCUS Foundation.
51** Derived, with permission, from the SOFA library. See notes at end of file.
52*/
53{
54
55/* 1977 Jan 1 00:00:32.184 TT, as two-part JD */
56 static const double t77td = ERFA_DJM0 + ERFA_DJM77;
57 static const double t77tf = ERFA_TTMTAI/ERFA_DAYSEC;
58
59/* TDB (days) at TAI 1977 Jan 1.0 */
60 static const double tdb0 = ERFA_TDB0/ERFA_DAYSEC;
61
62 double d;
63
64/* Result, safeguarding precision. */
65 if ( tcb1 > tcb2 ) {
66 d = tcb1 - t77td;
67 *tdb1 = tcb1;
68 *tdb2 = tcb2 + tdb0 - ( d + ( tcb2 - t77tf ) ) * ERFA_ELB;
69 } else {
70 d = tcb2 - t77td;
71 *tdb1 = tcb1 + tdb0 - ( d + ( tcb1 - t77tf ) ) * ERFA_ELB;
72 *tdb2 = tcb2;
73 }
74
75/* Status (always OK). */
76 return 0;
77
78}
79/*----------------------------------------------------------------------
80**
81**
82** Copyright (C) 2013-2015, NumFOCUS Foundation.
83** All rights reserved.
84**
85** This library is derived, with permission, from the International
86** Astronomical Union's "Standards of Fundamental Astronomy" library,
87** available from http://www.iausofa.org.
88**
89** The ERFA version is intended to retain identical functionality to
90** the SOFA library, but made distinct through different function and
91** file names, as set out in the SOFA license conditions. The SOFA
92** original has a role as a reference standard for the IAU and IERS,
93** and consequently redistribution is permitted only in its unaltered
94** state. The ERFA version is not subject to this restriction and
95** therefore can be included in distributions which do not support the
96** concept of "read only" software.
97**
98** Although the intent is to replicate the SOFA API (other than
99** replacement of prefix names) and results (with the exception of
100** bugs; any that are discovered will be fixed), SOFA is not
101** responsible for any errors found in this version of the library.
102**
103** If you wish to acknowledge the SOFA heritage, please acknowledge
104** that you are using a library derived from SOFA, rather than SOFA
105** itself.
106**
107**
108** TERMS AND CONDITIONS
109**
110** Redistribution and use in source and binary forms, with or without
111** modification, are permitted provided that the following conditions
112** are met:
113**
114** 1 Redistributions of source code must retain the above copyright
115** notice, this list of conditions and the following disclaimer.
116**
117** 2 Redistributions in binary form must reproduce the above copyright
118** notice, this list of conditions and the following disclaimer in
119** the documentation and/or other materials provided with the
120** distribution.
121**
122** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
123** the International Astronomical Union nor the names of its
124** contributors may be used to endorse or promote products derived
125** from this software without specific prior written permission.
126**
127** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
128** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
129** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
130** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
131** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
132** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
133** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
134** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
135** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
136** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
137** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
138** POSSIBILITY OF SUCH DAMAGE.
139**
140*/
Note: See TracBrowser for help on using the repository browser.