equationoftime 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/.buildpath +5 -0
  3. data/.project +17 -0
  4. data/.rvmrc +1 -0
  5. data/.settings/org.eclipse.ltk.core.refactoring.prefs +2 -0
  6. data/Makefile +238 -0
  7. data/Rakefile +40 -3
  8. data/analemma_data.yml +2925 -0
  9. data/equationoftime.gemspec +6 -3
  10. data/examples/analemma_data_generator.rb +12 -12
  11. data/examples/celes_parts/.RUBYARCHDIR.time +0 -0
  12. data/examples/celes_parts/.cproject +56 -0
  13. data/examples/celes_parts/.project +78 -0
  14. data/examples/celes_parts/a2af.c +120 -0
  15. data/examples/celes_parts/a2tf.c +116 -0
  16. data/examples/celes_parts/af2a.c +107 -0
  17. data/examples/celes_parts/anp.c +82 -0
  18. data/examples/celes_parts/anpm.c +82 -0
  19. data/examples/celes_parts/bi00.c +116 -0
  20. data/examples/celes_parts/bp00.c +173 -0
  21. data/examples/celes_parts/bp06.c +136 -0
  22. data/examples/celes_parts/bpn2xy.c +100 -0
  23. data/examples/celes_parts/c2i00a.c +139 -0
  24. data/examples/celes_parts/c2i00b.c +139 -0
  25. data/examples/celes_parts/c2i06a.c +136 -0
  26. data/examples/celes_parts/c2ibpn.c +142 -0
  27. data/examples/celes_parts/c2ixy.c +131 -0
  28. data/examples/celes_parts/c2ixys.c +123 -0
  29. data/examples/celes_parts/c2s.c +96 -0
  30. data/examples/celes_parts/c2t00a.c +154 -0
  31. data/examples/celes_parts/c2t00b.c +150 -0
  32. data/examples/celes_parts/c2t06a.c +152 -0
  33. data/examples/celes_parts/c2tcio.c +122 -0
  34. data/examples/celes_parts/c2teqx.c +122 -0
  35. data/examples/celes_parts/c2tpe.c +167 -0
  36. data/examples/celes_parts/c2txy.c +159 -0
  37. data/examples/celes_parts/cal2jd.c +139 -0
  38. data/examples/celes_parts/celes_core.c +2522 -0
  39. data/examples/celes_parts/cp.c +80 -0
  40. data/examples/celes_parts/cpv.c +82 -0
  41. data/examples/celes_parts/cr.c +83 -0
  42. data/examples/celes_parts/d2dtf.c +206 -0
  43. data/examples/celes_parts/d2tf.c +160 -0
  44. data/examples/celes_parts/dat.c +289 -0
  45. data/examples/celes_parts/depend +25 -0
  46. data/examples/celes_parts/dtdb.c +1213 -0
  47. data/examples/celes_parts/dtf2d.c +196 -0
  48. data/examples/celes_parts/ee00.c +128 -0
  49. data/examples/celes_parts/ee00a.c +135 -0
  50. data/examples/celes_parts/ee00b.c +141 -0
  51. data/examples/celes_parts/ee06a.c +122 -0
  52. data/examples/celes_parts/eect00.c +282 -0
  53. data/examples/celes_parts/eform.c +147 -0
  54. data/examples/celes_parts/eo06a.c +131 -0
  55. data/examples/celes_parts/eors.c +108 -0
  56. data/examples/celes_parts/epb.c +96 -0
  57. data/examples/celes_parts/epb2jd.c +91 -0
  58. data/examples/celes_parts/epj.c +93 -0
  59. data/examples/celes_parts/epj2jd.c +91 -0
  60. data/examples/celes_parts/epv00.c +2589 -0
  61. data/examples/celes_parts/eqeq94.c +131 -0
  62. data/examples/celes_parts/era00.c +136 -0
  63. data/examples/celes_parts/extconf.rb +4 -0
  64. data/examples/celes_parts/fad03.c +103 -0
  65. data/examples/celes_parts/fae03.c +102 -0
  66. data/examples/celes_parts/faf03.c +106 -0
  67. data/examples/celes_parts/faju03.c +102 -0
  68. data/examples/celes_parts/fal03.c +103 -0
  69. data/examples/celes_parts/falp03.c +103 -0
  70. data/examples/celes_parts/fama03.c +102 -0
  71. data/examples/celes_parts/fame03.c +102 -0
  72. data/examples/celes_parts/fane03.c +99 -0
  73. data/examples/celes_parts/faom03.c +104 -0
  74. data/examples/celes_parts/fapa03.c +103 -0
  75. data/examples/celes_parts/fasa03.c +102 -0
  76. data/examples/celes_parts/faur03.c +99 -0
  77. data/examples/celes_parts/fave03.c +102 -0
  78. data/examples/celes_parts/fk52h.c +143 -0
  79. data/examples/celes_parts/fk5hip.c +126 -0
  80. data/examples/celes_parts/fk5hz.c +160 -0
  81. data/examples/celes_parts/fw2m.c +134 -0
  82. data/examples/celes_parts/fw2xy.c +120 -0
  83. data/examples/celes_parts/gc2gd.c +134 -0
  84. data/examples/celes_parts/gc2gde.c +200 -0
  85. data/examples/celes_parts/gd2gc.c +134 -0
  86. data/examples/celes_parts/gd2gce.c +138 -0
  87. data/examples/celes_parts/gmst00.c +145 -0
  88. data/examples/celes_parts/gmst06.c +136 -0
  89. data/examples/celes_parts/gmst82.c +151 -0
  90. data/examples/celes_parts/gst00a.c +138 -0
  91. data/examples/celes_parts/gst00b.c +146 -0
  92. data/examples/celes_parts/gst06.c +140 -0
  93. data/examples/celes_parts/gst06a.c +131 -0
  94. data/examples/celes_parts/gst94.c +131 -0
  95. data/examples/celes_parts/h2fk5.c +148 -0
  96. data/examples/celes_parts/hfk5z.c +175 -0
  97. data/examples/celes_parts/ir.c +83 -0
  98. data/examples/celes_parts/jd2cal.c +155 -0
  99. data/examples/celes_parts/jdcalf.c +161 -0
  100. data/examples/celes_parts/num00a.c +121 -0
  101. data/examples/celes_parts/num00b.c +121 -0
  102. data/examples/celes_parts/num06a.c +125 -0
  103. data/examples/celes_parts/numat.c +109 -0
  104. data/examples/celes_parts/nut00a.c +2047 -0
  105. data/examples/celes_parts/nut00b.c +372 -0
  106. data/examples/celes_parts/nut06a.c +153 -0
  107. data/examples/celes_parts/nut80.c +325 -0
  108. data/examples/celes_parts/nutm80.c +117 -0
  109. data/examples/celes_parts/obl06.c +118 -0
  110. data/examples/celes_parts/obl80.c +118 -0
  111. data/examples/celes_parts/p06e.c +321 -0
  112. data/examples/celes_parts/p2pv.c +83 -0
  113. data/examples/celes_parts/p2s.c +91 -0
  114. data/examples/celes_parts/pap.c +139 -0
  115. data/examples/celes_parts/pas.c +96 -0
  116. data/examples/celes_parts/pb06.c +144 -0
  117. data/examples/celes_parts/pdp.c +84 -0
  118. data/examples/celes_parts/pfw06.c +165 -0
  119. data/examples/celes_parts/plan94.c +514 -0
  120. data/examples/celes_parts/pm.c +83 -0
  121. data/examples/celes_parts/pmat00.c +118 -0
  122. data/examples/celes_parts/pmat06.c +122 -0
  123. data/examples/celes_parts/pmat76.c +141 -0
  124. data/examples/celes_parts/pmp.c +85 -0
  125. data/examples/celes_parts/pn.c +109 -0
  126. data/examples/celes_parts/pn00.c +177 -0
  127. data/examples/celes_parts/pn00a.c +162 -0
  128. data/examples/celes_parts/pn00b.c +162 -0
  129. data/examples/celes_parts/pn06.c +187 -0
  130. data/examples/celes_parts/pn06a.c +152 -0
  131. data/examples/celes_parts/pnm00a.c +121 -0
  132. data/examples/celes_parts/pnm00b.c +121 -0
  133. data/examples/celes_parts/pnm06a.c +124 -0
  134. data/examples/celes_parts/pnm80.c +126 -0
  135. data/examples/celes_parts/pom00.c +115 -0
  136. data/examples/celes_parts/ppp.c +85 -0
  137. data/examples/celes_parts/ppsp.c +94 -0
  138. data/examples/celes_parts/pr00.c +142 -0
  139. data/examples/celes_parts/prec76.c +148 -0
  140. data/examples/celes_parts/pv2p.c +81 -0
  141. data/examples/celes_parts/pv2s.c +144 -0
  142. data/examples/celes_parts/pvdpv.c +102 -0
  143. data/examples/celes_parts/pvm.c +86 -0
  144. data/examples/celes_parts/pvmpv.c +87 -0
  145. data/examples/celes_parts/pvppv.c +87 -0
  146. data/examples/celes_parts/pvstar.c +207 -0
  147. data/examples/celes_parts/pvu.c +93 -0
  148. data/examples/celes_parts/pvup.c +88 -0
  149. data/examples/celes_parts/pvxpv.c +107 -0
  150. data/examples/celes_parts/pxp.c +94 -0
  151. data/examples/celes_parts/rm2v.c +111 -0
  152. data/examples/celes_parts/rv2m.c +118 -0
  153. data/examples/celes_parts/rx.c +110 -0
  154. data/examples/celes_parts/rxp.c +99 -0
  155. data/examples/celes_parts/rxpv.c +86 -0
  156. data/examples/celes_parts/rxr.c +99 -0
  157. data/examples/celes_parts/ry.c +110 -0
  158. data/examples/celes_parts/rz.c +110 -0
  159. data/examples/celes_parts/s00.c +371 -0
  160. data/examples/celes_parts/s00a.c +143 -0
  161. data/examples/celes_parts/s00b.c +143 -0
  162. data/examples/celes_parts/s06.c +368 -0
  163. data/examples/celes_parts/s06a.c +145 -0
  164. data/examples/celes_parts/s2c.c +85 -0
  165. data/examples/celes_parts/s2p.c +88 -0
  166. data/examples/celes_parts/s2pv.c +103 -0
  167. data/examples/celes_parts/s2xpv.c +87 -0
  168. data/examples/celes_parts/sepp.c +105 -0
  169. data/examples/celes_parts/seps.c +93 -0
  170. data/examples/celes_parts/sofa.h +379 -0
  171. data/examples/celes_parts/sofam.h +155 -0
  172. data/examples/celes_parts/sp00.c +118 -0
  173. data/examples/celes_parts/starpm.c +205 -0
  174. data/examples/celes_parts/starpv.c +264 -0
  175. data/examples/celes_parts/sxp.c +84 -0
  176. data/examples/celes_parts/sxpv.c +85 -0
  177. data/examples/celes_parts/taitt.c +110 -0
  178. data/examples/celes_parts/taiut1.c +112 -0
  179. data/examples/celes_parts/taiutc.c +182 -0
  180. data/examples/celes_parts/tcbtdb.c +132 -0
  181. data/examples/celes_parts/tcgtt.c +109 -0
  182. data/examples/celes_parts/tdbtcb.c +137 -0
  183. data/examples/celes_parts/tdbtt.c +122 -0
  184. data/examples/celes_parts/test_celes.rb +48 -0
  185. data/examples/celes_parts/tf2a.c +107 -0
  186. data/examples/celes_parts/tf2d.c +107 -0
  187. data/examples/celes_parts/tr.c +93 -0
  188. data/examples/celes_parts/trxp.c +93 -0
  189. data/examples/celes_parts/trxpv.c +93 -0
  190. data/examples/celes_parts/tttai.c +110 -0
  191. data/examples/celes_parts/tttcg.c +112 -0
  192. data/examples/celes_parts/tttdb.c +121 -0
  193. data/examples/celes_parts/ttut1.c +110 -0
  194. data/examples/celes_parts/ut1tai.c +111 -0
  195. data/examples/celes_parts/ut1tt.c +110 -0
  196. data/examples/celes_parts/ut1utc.c +193 -0
  197. data/examples/celes_parts/utctai.c +163 -0
  198. data/examples/celes_parts/utcut1.c +151 -0
  199. data/examples/celes_parts/xy06.c +2758 -0
  200. data/examples/celes_parts/xys00a.c +133 -0
  201. data/examples/celes_parts/xys00b.c +133 -0
  202. data/examples/celes_parts/xys06a.c +133 -0
  203. data/examples/celes_parts/zp.c +77 -0
  204. data/examples/celes_parts/zpv.c +79 -0
  205. data/examples/celes_parts/zr.c +83 -0
  206. data/examples/check_date_type.rb +2 -4
  207. data/examples/compare_geoc_long_ra.rb +19 -11
  208. data/examples/data_table_for_astro_dog.rb +40 -0
  209. data/examples/earth_rotation.rb +28 -3
  210. data/examples/eot.c +15 -0
  211. data/examples/eot.h +2 -0
  212. data/examples/eot_methods_list.rb +30 -3
  213. data/examples/eot_suntimes.rb +99 -95
  214. data/examples/extconf.rb +2 -0
  215. data/examples/{read_nutation_data.rb → gmst_gast_non_sofa.rb} +103 -98
  216. data/examples/nutation_table5_3a.yaml +1658 -1658
  217. data/examples/rbeot.c +24 -0
  218. data/examples/test_eot.rb +17 -0
  219. data/examples/test_poly_eval.rb +6 -17
  220. data/examples/time_scales.rb +4 -7
  221. data/examples/times_year.rb +50 -0
  222. data/examples/usage_example.rb +15 -5
  223. data/examples/use_angles.rb +151 -87
  224. data/lib/eot/angles.rb +130 -177
  225. data/lib/eot/constants.rb +41 -44
  226. data/lib/eot/displays.rb +40 -37
  227. data/lib/eot/geo_lat_lng_smt.rb +7 -6
  228. data/lib/eot/init.rb +62 -39
  229. data/lib/eot/nutation.rb +53 -45
  230. data/lib/eot/times.rb +32 -41
  231. data/lib/eot/utilities.rb +11 -90
  232. data/lib/eot/version.rb +3 -2
  233. data/rise_set_data.yml +1461 -0
  234. data/run_tests_eclipse.rb +1 -0
  235. data/tests/minitest/aliased_angles_spec.rb +119 -165
  236. data/tests/minitest/aliased_displays_spec.rb +41 -39
  237. data/tests/minitest/aliased_utilities_spec.rb +11 -22
  238. data/tests/minitest/angles_spec.rb +134 -181
  239. data/tests/minitest/constants_spec.rb +4 -10
  240. data/tests/minitest/delta_epsilon_spec.rb +13 -16
  241. data/tests/minitest/displays_spec.rb +39 -37
  242. data/tests/minitest/geo_spec.rb +15 -11
  243. data/tests/minitest/init_spec.rb +30 -16
  244. data/tests/minitest/nutation_spec.rb +19 -13
  245. data/tests/minitest/times_spec.rb +77 -75
  246. data/tests/minitest/utilities_spec.rb +10 -94
  247. data/wiki.md +7 -9
  248. metadata +218 -26
  249. data/examples/data_table.rb +0 -26
  250. data/lib/eot/nutation_table5_3a.yaml +0 -9532
  251. data/tests/minitest/aliased_times_spec.rb +0 -36
@@ -0,0 +1,193 @@
1
+ #include "sofam.h"
2
+
3
+ int iauUt1utc(double ut11, double ut12, double dut1,
4
+ double *utc1, double *utc2)
5
+ /*
6
+ ** - - - - - - - - - -
7
+ ** i a u U t 1 u t c
8
+ ** - - - - - - - - - -
9
+ **
10
+ ** Time scale transformation: Universal Time, UT1, to Coordinated
11
+ ** Universal Time, UTC.
12
+ **
13
+ ** Status: canonical.
14
+ **
15
+ ** Given:
16
+ ** ut11,ut12 double UT1 as a 2-part Julian Date (Note 1)
17
+ ** dut1 double Delta UT1: UT1-UTC in seconds (Note 2)
18
+ **
19
+ ** Returned:
20
+ ** utc1,utc2 double UTC as a 2-part quasi Julian Date (Notes 3,4)
21
+ **
22
+ ** Returned (function value):
23
+ ** int status: +1 = dubious year (Note 5)
24
+ ** 0 = OK
25
+ ** -1 = unacceptable date
26
+ **
27
+ ** Notes:
28
+ **
29
+ ** 1) ut11+ut12 is Julian Date, apportioned in any convenient way
30
+ ** between the two arguments, for example where ut11 is the Julian
31
+ ** Day Number and ut12 is the fraction of a day. The returned utc1
32
+ ** and utc2 form an analogous pair, except that a special convention
33
+ ** is used, to deal with the problem of leap seconds - see Note 3.
34
+ **
35
+ ** 2) Delta UT1 can be obtained from tabulations provided by the
36
+ ** International Earth Rotation and Reference Systems Service. The
37
+ ** value changes abruptly by 1s at a leap second; however, close to
38
+ ** a leap second the algorithm used here is tolerant of the "wrong"
39
+ ** choice of value being made.
40
+ **
41
+ ** 3) JD cannot unambiguously represent UTC during a leap second unless
42
+ ** special measures are taken. The convention in the present
43
+ ** function is that the returned quasi JD day UTC1+UTC2 represents
44
+ ** UTC days whether the length is 86399, 86400 or 86401 SI seconds.
45
+ **
46
+ ** 4) The function iauD2dtf can be used to transform the UTC quasi-JD
47
+ ** into calendar date and clock time, including UTC leap second
48
+ ** handling.
49
+ **
50
+ ** 5) The warning status "dubious year" flags UTCs that predate the
51
+ ** introduction of the time scale and that are too far in the future
52
+ ** to be trusted. See iauDat for further details.
53
+ **
54
+ ** Called:
55
+ ** iauJd2cal JD to Gregorian calendar
56
+ ** iauDat delta(AT) = TAI-UTC
57
+ ** iauCal2jd Gregorian calendar to JD
58
+ **
59
+ ** References:
60
+ **
61
+ ** McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
62
+ ** IERS Technical Note No. 32, BKG (2004)
63
+ **
64
+ ** Explanatory Supplement to the Astronomical Almanac,
65
+ ** P. Kenneth Seidelmann (ed), University Science Books (1992)
66
+ **
67
+ ** This revision: 2011 May 14
68
+ **
69
+ ** Original version 2012-03-01
70
+ **
71
+ ** Copyright (C) 2013 Naoki Arita. See notes at end.
72
+ */
73
+ {
74
+ int big1;
75
+ int i, iy, im, id, js;
76
+ double duts, u1, u2, d1, dats1, d2, fd, dats2, ddats, us1, us2, du;
77
+
78
+
79
+ /* UT1-UTC in seconds. */
80
+ duts = dut1;
81
+
82
+ /* Put the two parts of the UT1 into big-first order. */
83
+ big1 = ( ut11 >= ut12 );
84
+ if ( big1 ) {
85
+ u1 = ut11;
86
+ u2 = ut12;
87
+ } else {
88
+ u1 = ut12;
89
+ u2 = ut11;
90
+ }
91
+
92
+ /* See if the UT1 can possibly be in a leap-second day. */
93
+ d1 = u1;
94
+ dats1 = 0;
95
+ for ( i = -1; i <= 3; i++ ) {
96
+ d2 = u2 + (double) i;
97
+ if ( iauJd2cal(d1, d2, &iy, &im, &id, &fd) ) return -1;
98
+ js = iauDat(iy, im, id, 0.0, &dats2);
99
+ if ( js < 0 ) return -1;
100
+ if ( i == - 1 ) dats1 = dats2;
101
+ ddats = dats2 - dats1;
102
+ if ( fabs(ddats) >= 0.5 ) {
103
+
104
+ /* Yes, leap second nearby: ensure UT1-UTC is "before" value. */
105
+ if ( ddats * duts >= 0 ) duts -= ddats;
106
+
107
+ /* UT1 for the start of the UTC day that ends in a leap. */
108
+ if ( iauCal2jd(iy, im, id, &d1, &d2) ) return -1;
109
+ us1 = d1;
110
+ us2 = d2 - 1.0 + duts/DAYSEC;
111
+
112
+ /* Is the UT1 after this point? */
113
+ du = u1 - us1;
114
+ du += u2 - us2;
115
+ if ( du > 0 ) {
116
+
117
+ /* Yes: fraction of the current UTC day that has elapsed. */
118
+ fd = du * DAYSEC / ( DAYSEC + ddats );
119
+
120
+ /* Ramp UT1-UTC to bring about SOFA's JD(UTC) convention. */
121
+ duts += ddats * ( fd <= 1.0 ? fd : 1.0 );
122
+ }
123
+
124
+ /* Done. */
125
+ break;
126
+ }
127
+ dats1 = dats2;
128
+ }
129
+
130
+ /* Subtract the (possibly adjusted) UT1-UTC from UT1 to give UTC. */
131
+ u2 -= duts / DAYSEC;
132
+
133
+ /* Result, safeguarding precision. */
134
+ if ( big1 ) {
135
+ *utc1 = u1;
136
+ *utc2 = u2;
137
+ } else {
138
+ *utc1 = u2;
139
+ *utc2 = u1;
140
+ }
141
+
142
+ /* Status. */
143
+ return js;
144
+
145
+ /*----------------------------------------------------------------------
146
+ **
147
+ ** Celes is a wrapper of the SOFA Library for Ruby.
148
+ **
149
+ ** This file is redistributed and relicensed in accordance with
150
+ ** the SOFA Software License (http://www.iausofa.org/tandc.html).
151
+ **
152
+ ** The original library is available from IAU Standards of
153
+ ** Fundamental Astronomy (http://www.iausofa.org/).
154
+ **
155
+ **
156
+ **
157
+ **
158
+ **
159
+ ** Copyright (C) 2013, Naoki Arita
160
+ ** All rights reserved.
161
+ **
162
+ ** Redistribution and use in source and binary forms, with or without
163
+ ** modification, are permitted provided that the following conditions
164
+ ** are met:
165
+ **
166
+ ** 1 Redistributions of source code must retain the above copyright
167
+ ** notice, this list of conditions and the following disclaimer.
168
+ **
169
+ ** 2 Redistributions in binary form must reproduce the above copyright
170
+ ** notice, this list of conditions and the following disclaimer in
171
+ ** the documentation and/or other materials provided with the
172
+ ** distribution.
173
+ **
174
+ ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
175
+ ** the International Astronomical Union nor the names of its
176
+ ** contributors may be used to endorse or promote products derived
177
+ ** from this software without specific prior written permission.
178
+ **
179
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
180
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
182
+ ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
183
+ ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
184
+ ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
185
+ ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
186
+ ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
187
+ ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
188
+ ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
189
+ ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
190
+ ** POSSIBILITY OF SUCH DAMAGE.
191
+ **
192
+ **--------------------------------------------------------------------*/
193
+ }
@@ -0,0 +1,163 @@
1
+ #include "sofam.h"
2
+
3
+ int iauUtctai(double utc1, double utc2, double *tai1, double *tai2)
4
+ /*
5
+ ** - - - - - - - - - -
6
+ ** i a u U t c t a i
7
+ ** - - - - - - - - - -
8
+ **
9
+ ** Time scale transformation: Coordinated Universal Time, UTC, to
10
+ ** International Atomic Time, TAI.
11
+ **
12
+ ** Status: canonical.
13
+ **
14
+ ** Given:
15
+ ** utc1,utc2 double UTC as a 2-part quasi Julian Date (Notes 1-4)
16
+ **
17
+ ** Returned:
18
+ ** tai1,tai2 double TAI as a 2-part Julian Date (Note 5)
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 and that are too far in the future
38
+ ** to be trusted. See iauDat for further details.
39
+ **
40
+ ** 4) The function iauDtf2d converts from calendar date and time of day
41
+ ** into 2-part Julian Date, and in the case of UTC implements the
42
+ ** leap-second-ambiguity convention described above.
43
+ **
44
+ ** 5) The returned TAI1,TAI2 are such that their sum is the TAI Julian
45
+ ** Date.
46
+ **
47
+ ** Called:
48
+ ** iauJd2cal JD to Gregorian calendar
49
+ ** iauDat delta(AT) = TAI-UTC
50
+ ** iauCal2jd Gregorian calendar to JD
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
+ ** This revision: 2010 September 10
61
+ **
62
+ ** Original version 2012-03-01
63
+ **
64
+ ** Copyright (C) 2013 Naoki Arita. See notes at end.
65
+ **
66
+ */
67
+ {
68
+ int big1;
69
+ int iy, im, id, js, iyt, imt, idt;
70
+ double u1, u2, fd, dats, fdt, datst, ddat, z1, z2, a2;
71
+
72
+
73
+ /* Put the two parts of the UTC into big-first order. */
74
+ big1 = ( utc1 >= utc2 );
75
+ if ( big1 ) {
76
+ u1 = utc1;
77
+ u2 = utc2;
78
+ } else {
79
+ u1 = utc2;
80
+ u2 = utc1;
81
+ }
82
+
83
+ /* Get TAI-UTC now. */
84
+ if ( iauJd2cal(u1, u2, &iy, &im, &id, &fd) ) return -1;
85
+ js = iauDat(iy, im, id, fd, &dats);
86
+ if ( js < 0 ) return -1;
87
+
88
+ /* Get TAI-UTC tomorrow. */
89
+ if ( iauJd2cal(u1+1.5, u2-fd, &iyt, &imt, &idt, &fdt) ) return -1;
90
+ js = iauDat(iyt, imt, idt, fdt, &datst);
91
+ if ( js < 0 ) return -1;
92
+
93
+ /* If today ends in a leap second, scale the fraction into SI days. */
94
+ ddat = datst - dats;
95
+ if ( fabs(ddat) > 0.5 ) fd += fd * ddat / DAYSEC;
96
+
97
+ /* Today's calendar date to 2-part JD. */
98
+ if ( iauCal2jd(iy, im, id, &z1, &z2) ) return -1;
99
+
100
+ /* Assemble the TAI result, preserving the UTC split and order. */
101
+ a2 = z1 - u1;
102
+ a2 += z2;
103
+ a2 += fd + dats / DAYSEC;
104
+ if ( big1 ) {
105
+ *tai1 = u1;
106
+ *tai2 = a2;
107
+ } else {
108
+ *tai1 = a2;
109
+ *tai2 = u1;
110
+ }
111
+
112
+ /* Status. */
113
+ return js;
114
+
115
+ /*----------------------------------------------------------------------
116
+ **
117
+ ** Celes is a wrapper of the SOFA Library for Ruby.
118
+ **
119
+ ** This file is redistributed and relicensed in accordance with
120
+ ** the SOFA Software License (http://www.iausofa.org/tandc.html).
121
+ **
122
+ ** The original library is available from IAU Standards of
123
+ ** Fundamental Astronomy (http://www.iausofa.org/).
124
+ **
125
+ **
126
+ **
127
+ **
128
+ **
129
+ ** Copyright (C) 2013, Naoki Arita
130
+ ** All rights reserved.
131
+ **
132
+ ** Redistribution and use in source and binary forms, with or without
133
+ ** modification, are permitted provided that the following conditions
134
+ ** are met:
135
+ **
136
+ ** 1 Redistributions of source code must retain the above copyright
137
+ ** notice, this list of conditions and the following disclaimer.
138
+ **
139
+ ** 2 Redistributions in binary form must reproduce the above copyright
140
+ ** notice, this list of conditions and the following disclaimer in
141
+ ** the documentation and/or other materials provided with the
142
+ ** distribution.
143
+ **
144
+ ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
145
+ ** the International Astronomical Union nor the names of its
146
+ ** contributors may be used to endorse or promote products derived
147
+ ** from this software without specific prior written permission.
148
+ **
149
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
150
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
151
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
152
+ ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
153
+ ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
154
+ ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
155
+ ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
156
+ ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
157
+ ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
158
+ ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
159
+ ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
160
+ ** POSSIBILITY OF SUCH DAMAGE.
161
+ **
162
+ **--------------------------------------------------------------------*/
163
+ }
@@ -0,0 +1,151 @@
1
+ #include "sofam.h"
2
+
3
+ int iauUtcut1(double utc1, double utc2, double dut1,
4
+ double *ut11, double *ut12)
5
+ /*
6
+ ** - - - - - - - - - -
7
+ ** i a u U t c u t 1
8
+ ** - - - - - - - - - -
9
+ **
10
+ ** Time scale transformation: Coordinated Universal Time, UTC, to
11
+ ** Universal Time, UT1.
12
+ **
13
+ ** Status: canonical.
14
+ **
15
+ ** Given:
16
+ ** utc1,utc2 double UTC as a 2-part quasi Julian Date (Notes 1-4)
17
+ ** dut1 double Delta UT1 = UT1-UTC in seconds (Note 5)
18
+ **
19
+ ** Returned:
20
+ ** ut11,ut12 double UT1 as a 2-part Julian Date (Note 6)
21
+ **
22
+ ** Returned (function value):
23
+ ** int status: +1 = dubious year (Note 7)
24
+ ** 0 = OK
25
+ ** -1 = unacceptable date
26
+ **
27
+ ** Notes:
28
+ **
29
+ ** 1) utc1+utc2 is quasi Julian Date (see Note 2), apportioned in any
30
+ ** convenient way between the two arguments, for example where utc1
31
+ ** is the Julian Day Number and utc2 is the fraction of a day.
32
+ **
33
+ ** 2) JD cannot unambiguously represent UTC during a leap second unless
34
+ ** special measures are taken. The convention in the present
35
+ ** function is that the JD day represents UTC days whether the
36
+ ** length is 86399, 86400 or 86401 SI seconds.
37
+ **
38
+ ** 3) The warning status "dubious year" flags UTCs that predate the
39
+ ** introduction of the time scale and that are too far in the future
40
+ ** to be trusted. See iauDat for further details.
41
+ **
42
+ ** 4) The function iauDtf2d converts from calendar date and time of
43
+ ** day into 2-part Julian Date, and in the case of UTC implements
44
+ ** the leap-second-ambiguity convention described above.
45
+ **
46
+ ** 5) Delta UT1 can be obtained from tabulations provided by the
47
+ ** International Earth Rotation and Reference Systems Service. It
48
+ ** It is the caller's responsibility to supply a DUT argument
49
+ ** containing the UT1-UTC value that matches the given UTC.
50
+ **
51
+ ** 6) The returned ut11,ut12 are such that their sum is the UT1 Julian
52
+ ** Date.
53
+ **
54
+ ** 7) The warning status "dubious year" flags UTCs that predate the
55
+ ** introduction of the time scale and that are too far in the future
56
+ ** to be trusted. See iauDat for further details.
57
+ **
58
+ ** References:
59
+ **
60
+ ** McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
61
+ ** IERS Technical Note No. 32, BKG (2004)
62
+ **
63
+ ** Explanatory Supplement to the Astronomical Almanac,
64
+ ** P. Kenneth Seidelmann (ed), University Science Books (1992)
65
+ **
66
+ ** Called:
67
+ ** iauJd2cal JD to Gregorian calendar
68
+ ** iauDat delta(AT) = TAI-UTC
69
+ ** iauUtctai UTC to TAI
70
+ ** iauTaiut1 TAI to UT1
71
+ **
72
+ ** This revision: 2010 May 16
73
+ **
74
+ ** Original version 2012-03-01
75
+ **
76
+ ** Copyright (C) 2013 Naoki Arita. See notes at end.
77
+ */
78
+ {
79
+ int iy, im, id, js, jw;
80
+ double w, dat, dta, tai1, tai2;
81
+
82
+
83
+ /* Look up TAI-UTC. */
84
+ if ( iauJd2cal(utc1, utc2, &iy, &im, &id, &w) ) return -1;
85
+ js = iauDat ( iy, im, id, 0.0, &dat);
86
+ if ( js < 0 ) return -1;
87
+
88
+ /* Form UT1-TAI. */
89
+ dta = dut1 - dat;
90
+
91
+ /* UTC to TAI to UT1. */
92
+ jw = iauUtctai(utc1, utc2, &tai1, &tai2);
93
+ if ( jw < 0 ) {
94
+ return -1;
95
+ } else if ( jw > 0 ) {
96
+ js = jw;
97
+ }
98
+ if ( iauTaiut1(tai1, tai2, dta, ut11, ut12) ) return -1;
99
+
100
+ /* Status. */
101
+ return js;
102
+
103
+ /*----------------------------------------------------------------------
104
+ **
105
+ ** Celes is a wrapper of the SOFA Library for Ruby.
106
+ **
107
+ ** This file is redistributed and relicensed in accordance with
108
+ ** the SOFA Software License (http://www.iausofa.org/tandc.html).
109
+ **
110
+ ** The original library is available from IAU Standards of
111
+ ** Fundamental Astronomy (http://www.iausofa.org/).
112
+ **
113
+ **
114
+ **
115
+ **
116
+ **
117
+ ** Copyright (C) 2013, Naoki Arita
118
+ ** All rights reserved.
119
+ **
120
+ ** Redistribution and use in source and binary forms, with or without
121
+ ** modification, are permitted provided that the following conditions
122
+ ** are met:
123
+ **
124
+ ** 1 Redistributions of source code must retain the above copyright
125
+ ** notice, this list of conditions and the following disclaimer.
126
+ **
127
+ ** 2 Redistributions in binary form must reproduce the above copyright
128
+ ** notice, this list of conditions and the following disclaimer in
129
+ ** the documentation and/or other materials provided with the
130
+ ** distribution.
131
+ **
132
+ ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
133
+ ** the International Astronomical Union nor the names of its
134
+ ** contributors may be used to endorse or promote products derived
135
+ ** from this software without specific prior written permission.
136
+ **
137
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
138
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
139
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
140
+ ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
141
+ ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
142
+ ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
143
+ ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
144
+ ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
145
+ ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
146
+ ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
147
+ ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
148
+ ** POSSIBILITY OF SUCH DAMAGE.
149
+ **
150
+ **--------------------------------------------------------------------*/
151
+ }