1 #include "erfa.h"
2 #include "erfam.h"
3 
eraTttdb(double tt1,double tt2,double dtr,double * tdb1,double * tdb2)4 int eraTttdb(double tt1, double tt2, double dtr,
5              double *tdb1, double *tdb2)
6 /*
7 **  - - - - - - - - -
8 **   e r a T t t d b
9 **  - - - - - - - - -
10 **
11 **  Time scale transformation:  Terrestrial Time, TT, to Barycentric
12 **  Dynamical Time, TDB.
13 **
14 **  Given:
15 **     tt1,tt2    double    TT as a 2-part Julian Date
16 **     dtr        double    TDB-TT in seconds
17 **
18 **  Returned:
19 **     tdb1,tdb2  double    TDB as a 2-part Julian Date
20 **
21 **  Returned (function value):
22 **                int       status:  0 = OK
23 **
24 **  Notes:
25 **
26 **  1) tt1+tt2 is Julian Date, apportioned in any convenient way between
27 **     the two arguments, for example where tt1 is the Julian Day Number
28 **     and tt2 is the fraction of a day.  The returned tdb1,tdb2 follow
29 **     suit.
30 **
31 **  2) The argument dtr represents the quasi-periodic component of the
32 **     GR transformation between TT and TCB.  It is dependent upon the
33 **     adopted solar-system ephemeris, and can be obtained by numerical
34 **     integration, by interrogating a precomputed time ephemeris or by
35 **     evaluating a model such as that implemented in the ERFA function
36 **     eraDtdb.   The quantity is dominated by an annual term of 1.7 ms
37 **     amplitude.
38 **
39 **  3) TDB is essentially the same as Teph, the time argument for the JPL
40 **     solar system ephemerides.
41 **
42 **  References:
43 **
44 **     McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
45 **     IERS Technical Note No. 32, BKG (2004)
46 **
47 **     IAU 2006 Resolution 3
48 **
49 **  This revision:  2021 May 11
50 **
51 **  Copyright (C) 2013-2021, NumFOCUS Foundation.
52 **  Derived, with permission, from the SOFA library.  See notes at end of file.
53 */
54 {
55    double dtrd;
56 
57 
58 /* Result, safeguarding precision. */
59    dtrd = dtr / ERFA_DAYSEC;
60    if ( fabs(tt1) > fabs(tt2) ) {
61       *tdb1 = tt1;
62       *tdb2 = tt2 + dtrd;
63    } else {
64       *tdb1 = tt1 + dtrd;
65       *tdb2 = tt2;
66    }
67 
68 /* Status (always OK). */
69    return 0;
70 
71 /* Finished. */
72 
73 }
74 /*----------------------------------------------------------------------
75 **
76 **
77 **  Copyright (C) 2013-2021, NumFOCUS Foundation.
78 **  All rights reserved.
79 **
80 **  This library is derived, with permission, from the International
81 **  Astronomical Union's "Standards of Fundamental Astronomy" library,
82 **  available from http://www.iausofa.org.
83 **
84 **  The ERFA version is intended to retain identical functionality to
85 **  the SOFA library, but made distinct through different function and
86 **  file names, as set out in the SOFA license conditions.  The SOFA
87 **  original has a role as a reference standard for the IAU and IERS,
88 **  and consequently redistribution is permitted only in its unaltered
89 **  state.  The ERFA version is not subject to this restriction and
90 **  therefore can be included in distributions which do not support the
91 **  concept of "read only" software.
92 **
93 **  Although the intent is to replicate the SOFA API (other than
94 **  replacement of prefix names) and results (with the exception of
95 **  bugs;  any that are discovered will be fixed), SOFA is not
96 **  responsible for any errors found in this version of the library.
97 **
98 **  If you wish to acknowledge the SOFA heritage, please acknowledge
99 **  that you are using a library derived from SOFA, rather than SOFA
100 **  itself.
101 **
102 **
103 **  TERMS AND CONDITIONS
104 **
105 **  Redistribution and use in source and binary forms, with or without
106 **  modification, are permitted provided that the following conditions
107 **  are met:
108 **
109 **  1 Redistributions of source code must retain the above copyright
110 **    notice, this list of conditions and the following disclaimer.
111 **
112 **  2 Redistributions in binary form must reproduce the above copyright
113 **    notice, this list of conditions and the following disclaimer in
114 **    the documentation and/or other materials provided with the
115 **    distribution.
116 **
117 **  3 Neither the name of the Standards Of Fundamental Astronomy Board,
118 **    the International Astronomical Union nor the names of its
119 **    contributors may be used to endorse or promote products derived
120 **    from this software without specific prior written permission.
121 **
122 **  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
123 **  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
124 **  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
125 **  FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
126 **  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
127 **  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
128 **  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
129 **  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
130 **  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
131 **  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
132 **  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
133 **  POSSIBILITY OF SUCH DAMAGE.
134 **
135 */
136