FACT++  1.0
tdbtcb.c
Go to the documentation of this file.
1 #include "erfa.h"
2 
3 int eraTdbtcb(double tdb1, double tdb2, double *tcb1, double *tcb2)
4 /*
5 ** - - - - - - - - - -
6 ** e r a T d b t c b
7 ** - - - - - - - - - -
8 **
9 ** Time scale transformation: Barycentric Dynamical Time, TDB, to
10 ** Barycentric Coordinate Time, TCB.
11 **
12 ** Given:
13 ** tdb1,tdb2 double TDB as a 2-part Julian Date
14 **
15 ** Returned:
16 ** tcb1,tcb2 double TCB as a 2-part Julian Date
17 **
18 ** Returned (function value):
19 ** int status: 0 = OK
20 **
21 ** Notes:
22 **
23 ** 1) tdb1+tdb2 is Julian Date, apportioned in any convenient way
24 ** between the two arguments, for example where tdb1 is the Julian
25 ** Day Number and tdb2 is the fraction of a day. The returned
26 ** tcb1,tcb2 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 /* TDB to TCB rate */
63  static const double elbb = ERFA_ELB/(1.0-ERFA_ELB);
64 
65  double d, f;
66 
67 /* Result, preserving date format but safeguarding precision. */
68  if ( tdb1 > tdb2 ) {
69  d = t77td - tdb1;
70  f = tdb2 - tdb0;
71  *tcb1 = tdb1;
72  *tcb2 = f - ( d - ( f - t77tf ) ) * elbb;
73  } else {
74  d = t77td - tdb2;
75  f = tdb1 - tdb0;
76  *tcb1 = f + ( d - ( f - t77tf ) ) * elbb;
77  *tcb2 = tdb2;
78  }
79 
80 /* Status (always OK). */
81  return 0;
82 
83 }
84 /*----------------------------------------------------------------------
85 **
86 **
87 ** Copyright (C) 2013-2015, NumFOCUS Foundation.
88 ** All rights reserved.
89 **
90 ** This library is derived, with permission, from the International
91 ** Astronomical Union's "Standards of Fundamental Astronomy" library,
92 ** available from http://www.iausofa.org.
93 **
94 ** The ERFA version is intended to retain identical functionality to
95 ** the SOFA library, but made distinct through different function and
96 ** file names, as set out in the SOFA license conditions. The SOFA
97 ** original has a role as a reference standard for the IAU and IERS,
98 ** and consequently redistribution is permitted only in its unaltered
99 ** state. The ERFA version is not subject to this restriction and
100 ** therefore can be included in distributions which do not support the
101 ** concept of "read only" software.
102 **
103 ** Although the intent is to replicate the SOFA API (other than
104 ** replacement of prefix names) and results (with the exception of
105 ** bugs; any that are discovered will be fixed), SOFA is not
106 ** responsible for any errors found in this version of the library.
107 **
108 ** If you wish to acknowledge the SOFA heritage, please acknowledge
109 ** that you are using a library derived from SOFA, rather than SOFA
110 ** itself.
111 **
112 **
113 ** TERMS AND CONDITIONS
114 **
115 ** Redistribution and use in source and binary forms, with or without
116 ** modification, are permitted provided that the following conditions
117 ** are met:
118 **
119 ** 1 Redistributions of source code must retain the above copyright
120 ** notice, this list of conditions and the following disclaimer.
121 **
122 ** 2 Redistributions in binary form must reproduce the above copyright
123 ** notice, this list of conditions and the following disclaimer in
124 ** the documentation and/or other materials provided with the
125 ** distribution.
126 **
127 ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
128 ** the International Astronomical Union nor the names of its
129 ** contributors may be used to endorse or promote products derived
130 ** from this software without specific prior written permission.
131 **
132 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
133 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
134 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
135 ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
136 ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
137 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
138 ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
139 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
140 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
141 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
142 ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
143 ** POSSIBILITY OF SUCH DAMAGE.
144 **
145 */
#define ERFA_ELB
Definition: erfam.h:117
#define ERFA_DJM0
Definition: erfam.h:90
#define ERFA_DJM77
Definition: erfam.h:96
#define ERFA_DAYSEC
Definition: erfam.h:75
#define ERFA_TDB0
Definition: erfam.h:118
int eraTdbtcb(double tdb1, double tdb2, double *tcb1, double *tcb2)
Definition: tdbtcb.c:3
#define ERFA_TTMTAI
Definition: erfam.h:99