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