1 #include "sofa.h"
2 #include "sofam.h"
3
iauTcbtdb(double tcb1,double tcb2,double * tdb1,double * tdb2)4 int iauTcbtdb(double tcb1, double tcb2, double *tdb1, double *tdb2)
5 /*
6 ** - - - - - - - - - -
7 ** i a u T c b t d b
8 ** - - - - - - - - - -
9 **
10 ** Time scale transformation: Barycentric Coordinate Time, TCB, to
11 ** Barycentric Dynamical Time, TDB.
12 **
13 ** This function is part of the International Astronomical Union's
14 ** SOFA (Standards of Fundamental Astronomy) software collection.
15 **
16 ** Status: canonical.
17 **
18 ** Given:
19 ** tcb1,tcb2 double TCB as a 2-part Julian Date
20 **
21 ** Returned:
22 ** tdb1,tdb2 double TDB as a 2-part Julian Date
23 **
24 ** Returned (function value):
25 ** int status: 0 = OK
26 **
27 ** Notes:
28 **
29 ** 1) tcb1+tcb2 is Julian Date, apportioned in any convenient way
30 ** between the two arguments, for example where tcb1 is the Julian
31 ** Day Number and tcb2 is the fraction of a day. The returned
32 ** tdb1,tdb2 follow suit.
33 **
34 ** 2) The 2006 IAU General Assembly introduced a conventional linear
35 ** transformation between TDB and TCB. This transformation
36 ** compensates for the drift between TCB and terrestrial time TT,
37 ** and keeps TDB approximately centered on TT. Because the
38 ** relationship between TT and TCB depends on the adopted solar
39 ** system ephemeris, the degree of alignment between TDB and TT over
40 ** long intervals will vary according to which ephemeris is used.
41 ** Former definitions of TDB attempted to avoid this problem by
42 ** stipulating that TDB and TT should differ only by periodic
43 ** effects. This is a good description of the nature of the
44 ** relationship but eluded precise mathematical formulation. The
45 ** conventional linear relationship adopted in 2006 sidestepped
46 ** these difficulties whilst delivering a TDB that in practice was
47 ** consistent with values before that date.
48 **
49 ** 3) TDB is essentially the same as Teph, the time argument for the
50 ** JPL solar system ephemerides.
51 **
52 ** Reference:
53 **
54 ** IAU 2006 Resolution B3
55 **
56 ** This revision: 2021 May 11
57 **
58 ** SOFA release 2021-05-12
59 **
60 ** Copyright (C) 2021 IAU SOFA Board. See notes at end.
61 */
62 {
63
64 /* 1977 Jan 1 00:00:32.184 TT, as two-part JD */
65 static const double t77td = DJM0 + DJM77;
66 static const double t77tf = TTMTAI/DAYSEC;
67
68 /* TDB (days) at TAI 1977 Jan 1.0 */
69 static const double tdb0 = TDB0/DAYSEC;
70
71 double d;
72
73
74 /* Result, safeguarding precision. */
75 if ( fabs(tcb1) > fabs(tcb2) ) {
76 d = tcb1 - t77td;
77 *tdb1 = tcb1;
78 *tdb2 = tcb2 + tdb0 - ( d + ( tcb2 - t77tf ) ) * ELB;
79 } else {
80 d = tcb2 - t77td;
81 *tdb1 = tcb1 + tdb0 - ( d + ( tcb1 - t77tf ) ) * ELB;
82 *tdb2 = tcb2;
83 }
84
85 /* Status (always OK). */
86 return 0;
87
88 /* Finished. */
89
90 /*----------------------------------------------------------------------
91 **
92 ** Copyright (C) 2021
93 ** Standards Of Fundamental Astronomy Board
94 ** of the International Astronomical Union.
95 **
96 ** =====================
97 ** SOFA Software License
98 ** =====================
99 **
100 ** NOTICE TO USER:
101 **
102 ** BY USING THIS SOFTWARE YOU ACCEPT THE FOLLOWING SIX TERMS AND
103 ** CONDITIONS WHICH APPLY TO ITS USE.
104 **
105 ** 1. The Software is owned by the IAU SOFA Board ("SOFA").
106 **
107 ** 2. Permission is granted to anyone to use the SOFA software for any
108 ** purpose, including commercial applications, free of charge and
109 ** without payment of royalties, subject to the conditions and
110 ** restrictions listed below.
111 **
112 ** 3. You (the user) may copy and distribute SOFA source code to others,
113 ** and use and adapt its code and algorithms in your own software,
114 ** on a world-wide, royalty-free basis. That portion of your
115 ** distribution that does not consist of intact and unchanged copies
116 ** of SOFA source code files is a "derived work" that must comply
117 ** with the following requirements:
118 **
119 ** a) Your work shall be marked or carry a statement that it
120 ** (i) uses routines and computations derived by you from
121 ** software provided by SOFA under license to you; and
122 ** (ii) does not itself constitute software provided by and/or
123 ** endorsed by SOFA.
124 **
125 ** b) The source code of your derived work must contain descriptions
126 ** of how the derived work is based upon, contains and/or differs
127 ** from the original SOFA software.
128 **
129 ** c) The names of all routines in your derived work shall not
130 ** include the prefix "iau" or "sofa" or trivial modifications
131 ** thereof such as changes of case.
132 **
133 ** d) The origin of the SOFA components of your derived work must
134 ** not be misrepresented; you must not claim that you wrote the
135 ** original software, nor file a patent application for SOFA
136 ** software or algorithms embedded in the SOFA software.
137 **
138 ** e) These requirements must be reproduced intact in any source
139 ** distribution and shall apply to anyone to whom you have
140 ** granted a further right to modify the source code of your
141 ** derived work.
142 **
143 ** Note that, as originally distributed, the SOFA software is
144 ** intended to be a definitive implementation of the IAU standards,
145 ** and consequently third-party modifications are discouraged. All
146 ** variations, no matter how minor, must be explicitly marked as
147 ** such, as explained above.
148 **
149 ** 4. You shall not cause the SOFA software to be brought into
150 ** disrepute, either by misuse, or use for inappropriate tasks, or
151 ** by inappropriate modification.
152 **
153 ** 5. The SOFA software is provided "as is" and SOFA makes no warranty
154 ** as to its use or performance. SOFA does not and cannot warrant
155 ** the performance or results which the user may obtain by using the
156 ** SOFA software. SOFA makes no warranties, express or implied, as
157 ** to non-infringement of third party rights, merchantability, or
158 ** fitness for any particular purpose. In no event will SOFA be
159 ** liable to the user for any consequential, incidental, or special
160 ** damages, including any lost profits or lost savings, even if a
161 ** SOFA representative has been advised of such damages, or for any
162 ** claim by any third party.
163 **
164 ** 6. The provision of any version of the SOFA software under the terms
165 ** and conditions specified herein does not imply that future
166 ** versions will also be made available under the same terms and
167 ** conditions.
168 *
169 ** In any published work or commercial product which uses the SOFA
170 ** software directly, acknowledgement (see www.iausofa.org) is
171 ** appreciated.
172 **
173 ** Correspondence concerning SOFA software should be addressed as
174 ** follows:
175 **
176 ** By email: sofa@ukho.gov.uk
177 ** By post: IAU SOFA Center
178 ** HM Nautical Almanac Office
179 ** UK Hydrographic Office
180 ** Admiralty Way, Taunton
181 ** Somerset, TA1 2DN
182 ** United Kingdom
183 **
184 **--------------------------------------------------------------------*/
185 }
186