| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | /* | 
| 2 |  |  |  |  |  |  | *+ | 
| 3 |  |  |  |  |  |  | *  Name: | 
| 4 |  |  |  |  |  |  | *     palDt | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | *  Purpose: | 
| 7 |  |  |  |  |  |  | *     Estimate the offset between dynamical time and UT | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | *  Language: | 
| 10 |  |  |  |  |  |  | *     Starlink ANSI C | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | *  Type of Module: | 
| 13 |  |  |  |  |  |  | *     Library routine | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | *  Invocation: | 
| 16 |  |  |  |  |  |  | *     double palDt( double epoch ); | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | *  Arguments: | 
| 19 |  |  |  |  |  |  | *     epoch = double (Given) | 
| 20 |  |  |  |  |  |  | *        Julian epoch (e.g. 1850.0) | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | *  Returned Value: | 
| 23 |  |  |  |  |  |  | *     palDt = double | 
| 24 |  |  |  |  |  |  | *        Rough estimate of ET-UT (after 1984, TT-UT) at the | 
| 25 |  |  |  |  |  |  | *        given epoch, in seconds. | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | *  Description: | 
| 28 |  |  |  |  |  |  | *     Estimate the offset between dynamical time and Universal Time | 
| 29 |  |  |  |  |  |  | *     for a given historical epoch. | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | *  Authors: | 
| 32 |  |  |  |  |  |  | *     TIMJ: Tim Jenness (JAC, Hawaii) | 
| 33 |  |  |  |  |  |  | *     PTW: Patrick T. Wallace | 
| 34 |  |  |  |  |  |  | *     {enter_new_authors_here} | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | *  Notes: | 
| 37 |  |  |  |  |  |  | *     - Depending on the epoch, one of three parabolic approximations | 
| 38 |  |  |  |  |  |  | *       is used: | 
| 39 |  |  |  |  |  |  | * | 
| 40 |  |  |  |  |  |  | *         before 979    Stephenson & Morrison's 390 BC to AD 948 model | 
| 41 |  |  |  |  |  |  | *         979 to 1708   Stephenson & Morrison's 948 to 1600 model | 
| 42 |  |  |  |  |  |  | *         after 1708    McCarthy & Babcock's post-1650 model | 
| 43 |  |  |  |  |  |  | * | 
| 44 |  |  |  |  |  |  | *       The breakpoints are chosen to ensure continuity:  they occur | 
| 45 |  |  |  |  |  |  | *       at places where the adjacent models give the same answer as | 
| 46 |  |  |  |  |  |  | *       each other. | 
| 47 |  |  |  |  |  |  | *     - The accuracy is modest, with errors of up to 20 sec during | 
| 48 |  |  |  |  |  |  | *       the interval since 1650, rising to perhaps 30 min by 1000 BC. | 
| 49 |  |  |  |  |  |  | *       Comparatively accurate values from AD 1600 are tabulated in | 
| 50 |  |  |  |  |  |  | *       the Astronomical Almanac (see section K8 of the 1995 AA). | 
| 51 |  |  |  |  |  |  | *     - The use of double-precision for both argument and result is | 
| 52 |  |  |  |  |  |  | *       purely for compatibility with other SLALIB time routines. | 
| 53 |  |  |  |  |  |  | *     - The models used are based on a lunar tidal acceleration value | 
| 54 |  |  |  |  |  |  | *       of -26.00 arcsec per century. | 
| 55 |  |  |  |  |  |  | * | 
| 56 |  |  |  |  |  |  | *  See Also: | 
| 57 |  |  |  |  |  |  | *     Explanatory Supplement to the Astronomical Almanac, | 
| 58 |  |  |  |  |  |  | *     ed P.K.Seidelmann, University Science Books (1992), | 
| 59 |  |  |  |  |  |  | *     section 2.553, p83.  This contains references to | 
| 60 |  |  |  |  |  |  | *     the Stephenson & Morrison and McCarthy & Babcock | 
| 61 |  |  |  |  |  |  | *     papers. | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | *  History: | 
| 64 |  |  |  |  |  |  | *     2012-03-08 (TIMJ): | 
| 65 |  |  |  |  |  |  | *        Initial version with documentation from SLA/F. | 
| 66 |  |  |  |  |  |  | *        Adapted with permission from the Fortran SLALIB library. | 
| 67 |  |  |  |  |  |  | *     {enter_further_changes_here} | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | *  Copyright: | 
| 70 |  |  |  |  |  |  | *     Copyright (C) 1995 Rutherford Appleton Laboratory | 
| 71 |  |  |  |  |  |  | *     Copyright (C) 2012 Science and Technology Facilities Council. | 
| 72 |  |  |  |  |  |  | *     All Rights Reserved. | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | *  Licence: | 
| 75 |  |  |  |  |  |  | *     This program is free software; you can redistribute it and/or | 
| 76 |  |  |  |  |  |  | *     modify it under the terms of the GNU General Public License as | 
| 77 |  |  |  |  |  |  | *     published by the Free Software Foundation; either version 3 of | 
| 78 |  |  |  |  |  |  | *     the License, or (at your option) any later version. | 
| 79 |  |  |  |  |  |  | * | 
| 80 |  |  |  |  |  |  | *     This program is distributed in the hope that it will be | 
| 81 |  |  |  |  |  |  | *     useful, but WITHOUT ANY WARRANTY; without even the implied | 
| 82 |  |  |  |  |  |  | *     warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | 
| 83 |  |  |  |  |  |  | *     PURPOSE. See the GNU General Public License for more details. | 
| 84 |  |  |  |  |  |  | * | 
| 85 |  |  |  |  |  |  | *     You should have received a copy of the GNU General Public License | 
| 86 |  |  |  |  |  |  | *     along with this program; if not, write to the Free Software | 
| 87 |  |  |  |  |  |  | *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 
| 88 |  |  |  |  |  |  | *     MA 02110-1301, USA. | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | *  Bugs: | 
| 91 |  |  |  |  |  |  | *     {note_any_bugs_here} | 
| 92 |  |  |  |  |  |  | *- | 
| 93 |  |  |  |  |  |  | */ | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | #include "pal.h" | 
| 96 |  |  |  |  |  |  |  | 
| 97 | 10 |  |  |  |  |  | double palDt ( double epoch ) { | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | double t,w,s; | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | /* Centuries since 1800 */ | 
| 102 | 10 |  |  |  |  |  | t = (epoch - 1800.0) / 100.0; | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | /* Select model */ | 
| 105 | 10 | 50 |  |  |  |  | if ( epoch >= 1708.185161980887 ) { | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | /* Post-1708: use McCarthy & Babcock */ | 
| 108 | 10 |  |  |  |  |  | w = t - 0.19; | 
| 109 | 10 |  |  |  |  |  | s = 5.156 + 13.3066 * w * w; | 
| 110 |  |  |  |  |  |  |  | 
| 111 | 0 | 0 |  |  |  |  | } else if ( epoch >= 979.0258204760233 ) { | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | /* 978-1708: use Stephenson & Morrison's 948-1600 model */ | 
| 114 | 0 |  |  |  |  |  | s = 25.5 * t * t; | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | } else { | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | /* Pre-979: use Stephenson & Morrison's 390 BC to AD 948 model */ | 
| 119 | 0 |  |  |  |  |  | s = 1360.0 + (320.0 + 44.3*t) * t; | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | } | 
| 122 |  |  |  |  |  |  |  | 
| 123 | 10 |  |  |  |  |  | return s; | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | } |