source: trunk/FACT++/erfa/src/utcut1.c@ 18350

Last change on this file since 18350 was 18348, checked in by tbretz, 9 years ago
File size: 5.9 KB
Line 
1#include "erfa.h"
2
3int eraUtcut1(double utc1, double utc2, double dut1,
4 double *ut11, double *ut12)
5/*
6** - - - - - - - - - -
7** e r a U t c u t 1
8** - - - - - - - - - -
9**
10** Time scale transformation: Coordinated Universal Time, UTC, to
11** Universal Time, UT1.
12**
13** Given:
14** utc1,utc2 double UTC as a 2-part quasi Julian Date (Notes 1-4)
15** dut1 double Delta UT1 = UT1-UTC in seconds (Note 5)
16**
17** Returned:
18** ut11,ut12 double UT1 as a 2-part Julian Date (Note 6)
19**
20** Returned (function value):
21** int status: +1 = dubious year (Note 3)
22** 0 = OK
23** -1 = unacceptable date
24**
25** Notes:
26**
27** 1) utc1+utc2 is quasi Julian Date (see Note 2), apportioned in any
28** convenient way between the two arguments, for example where utc1
29** is the Julian Day Number and utc2 is the fraction of a day.
30**
31** 2) JD cannot unambiguously represent UTC during a leap second unless
32** special measures are taken. The convention in the present
33** function is that the JD day represents UTC days whether the
34** length is 86399, 86400 or 86401 SI seconds.
35**
36** 3) The warning status "dubious year" flags UTCs that predate the
37** introduction of the time scale or that are too far in the future
38** to be trusted. See eraDat for further details.
39**
40** 4) The function eraDtf2d converts from calendar date and time of
41** day into 2-part Julian Date, and in the case of UTC implements
42** the leap-second-ambiguity convention described above.
43**
44** 5) Delta UT1 can be obtained from tabulations provided by the
45** International Earth Rotation and Reference Systems Service.
46** It is the caller's responsibility to supply a dut1 argument
47** containing the UT1-UTC value that matches the given UTC.
48**
49** 6) The returned ut11,ut12 are such that their sum is the UT1 Julian
50** Date.
51**
52** References:
53**
54** McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
55** IERS Technical Note No. 32, BKG (2004)
56**
57** Explanatory Supplement to the Astronomical Almanac,
58** P. Kenneth Seidelmann (ed), University Science Books (1992)
59**
60** Called:
61** eraJd2cal JD to Gregorian calendar
62** eraDat delta(AT) = TAI-UTC
63** eraUtctai UTC to TAI
64** eraTaiut1 TAI to UT1
65**
66** Copyright (C) 2013-2015, NumFOCUS Foundation.
67** Derived, with permission, from the SOFA library. See notes at end of file.
68*/
69{
70 int iy, im, id, js, jw;
71 double w, dat, dta, tai1, tai2;
72
73/* Look up TAI-UTC. */
74 if ( eraJd2cal(utc1, utc2, &iy, &im, &id, &w) ) return -1;
75 js = eraDat ( iy, im, id, 0.0, &dat);
76 if ( js < 0 ) return -1;
77
78/* Form UT1-TAI. */
79 dta = dut1 - dat;
80
81/* UTC to TAI to UT1. */
82 jw = eraUtctai(utc1, utc2, &tai1, &tai2);
83 if ( jw < 0 ) {
84 return -1;
85 } else if ( jw > 0 ) {
86 js = jw;
87 }
88 if ( eraTaiut1(tai1, tai2, dta, ut11, ut12) ) return -1;
89
90/* Status. */
91 return js;
92
93}
94/*----------------------------------------------------------------------
95**
96**
97** Copyright (C) 2013-2015, NumFOCUS Foundation.
98** All rights reserved.
99**
100** This library is derived, with permission, from the International
101** Astronomical Union's "Standards of Fundamental Astronomy" library,
102** available from http://www.iausofa.org.
103**
104** The ERFA version is intended to retain identical functionality to
105** the SOFA library, but made distinct through different function and
106** file names, as set out in the SOFA license conditions. The SOFA
107** original has a role as a reference standard for the IAU and IERS,
108** and consequently redistribution is permitted only in its unaltered
109** state. The ERFA version is not subject to this restriction and
110** therefore can be included in distributions which do not support the
111** concept of "read only" software.
112**
113** Although the intent is to replicate the SOFA API (other than
114** replacement of prefix names) and results (with the exception of
115** bugs; any that are discovered will be fixed), SOFA is not
116** responsible for any errors found in this version of the library.
117**
118** If you wish to acknowledge the SOFA heritage, please acknowledge
119** that you are using a library derived from SOFA, rather than SOFA
120** itself.
121**
122**
123** TERMS AND CONDITIONS
124**
125** Redistribution and use in source and binary forms, with or without
126** modification, are permitted provided that the following conditions
127** are met:
128**
129** 1 Redistributions of source code must retain the above copyright
130** notice, this list of conditions and the following disclaimer.
131**
132** 2 Redistributions in binary form must reproduce the above copyright
133** notice, this list of conditions and the following disclaimer in
134** the documentation and/or other materials provided with the
135** distribution.
136**
137** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
138** the International Astronomical Union nor the names of its
139** contributors may be used to endorse or promote products derived
140** from this software without specific prior written permission.
141**
142** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
143** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
144** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
145** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
146** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
147** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
148** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
149** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
150** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
151** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
152** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
153** POSSIBILITY OF SUCH DAMAGE.
154**
155*/
Note: See TracBrowser for help on using the repository browser.