~ubuntu-branches/ubuntu/raring/wcstools/raring

« back to all changes in this revision

Viewing changes to libwcs/dateutil.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2012-06-04 08:30:00 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120604083000-x5s0xb20edvm7qpf
Tags: 3.8.5-1
* New upstream version.
* Bump Standards version to 3.9.3.
* Set DM-Upload-Allowed: yes
* Fix a crash that appears in saods9

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
  tsu = UT seconds since 1970-01-01T00:00 (used as Unix system time)
54
54
  tsd = UT seconds of current day
55
55
   ut = Universal Time (UTC)
56
 
   et = Ephemeris Time (or TDB or TT)
 
56
   et = Ephemeris Time (or TDB or TT) = TAI + 32.184 seconds
 
57
  tai = International Atomic Time (Temps Atomique International) = ET - 32.184 seconds
 
58
  gps = GPS time = TAI - 19 seconds
57
59
  mst = Mean Greenwich Sidereal Time
58
60
  gst = Greenwich Sidereal Time (includes nutation)
59
61
  lst = Local Sidereal Time (includes nutation) (longitude must be set)
122
124
 *      Convert date (yyyy.ddmm) and time (hh.mmsss) to ephemeris time
123
125
 * edt2dt (date, time)
124
126
 *      Convert ephemeris date (yyyy.ddmm) and time (hh.mmsss) to UT
 
127
 * dt2tai (date, time)
 
128
 *      Convert date (yyyy.ddmm) and time (hh.mmsss) to TAI date and time
 
129
 * tai2dt (date, time)
 
130
 *      Convert TAI date (yyyy.ddmm) and time (hh.mmsss) to UT
125
131
 * ts2ets (tsec)
126
132
 *      Convert from UT in seconds since 1950-01-01 to ET in same format
127
133
 * ets2ts (tsec)
2005
2011
 
2006
2012
/* TAI-UTC from the U.S. Naval Observatory */
2007
2013
/* ftp://maia.usno.navy.mil/ser7/tai-utc.dat */
2008
 
static double taijd[23]={2441317.5, 2441499.5, 2441683.5, 2442048.5, 2442413.5,
 
2014
static double taijd[26]={2441317.5, 2441499.5, 2441683.5, 2442048.5, 2442413.5,
2009
2015
              2442778.5, 2443144.5, 2443509.5, 2443874.5, 2444239.5, 2444786.5,
2010
2016
              2445151.5, 2445516.5, 2446247.5, 2447161.5, 2447892.5, 2448257.5,
2011
 
              2448804.5, 2449169.5, 2449534.5, 2450083.5, 2450630.5, 2451179.5};
2012
 
static double taidt[23]={10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,
2013
 
           20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,32.0};
 
2017
              2448804.5, 2449169.5, 2449534.5, 2450083.5, 2450630.5, 2451179.5,
 
2018
              2453736.5, 2454832.5, 2456293.5};
 
2019
static double taidt[26]={10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,
 
2020
           20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,32.0,
 
2021
           33.0,34.0,35.0};
2014
2022
static double dttab[173]={13.7,13.4,13.1,12.9,12.7,12.6,12.5,12.5,12.5,12.5,
2015
2023
           12.5,12.5,12.5,12.5,12.5,12.5,12.5,12.4,12.3,12.2,12.0,11.7,11.4,
2016
2024
           11.1,10.6,10.2, 9.6, 9.1, 8.6, 8.0, 7.5, 7.0, 6.6, 6.3, 6.0, 5.8,
2029
2037
          42.23};
2030
2038
 
2031
2039
 
 
2040
/* TAI2FD-- convert from TAI in FITS format to UT in FITS format */
 
2041
 
 
2042
char *
 
2043
tai2fd (string)
 
2044
 
 
2045
char *string;   /* FITS date string, which may be:
 
2046
                        fractional year
 
2047
                        dd/mm/yy (FITS standard before 2000)
 
2048
                        dd-mm-yy (nonstandard use before 2000)
 
2049
                        yyyy-mm-dd (FITS standard after 1999)
 
2050
                        yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */
 
2051
{
 
2052
    double dj0, dj, tsec, dt;
 
2053
 
 
2054
    dj0 = fd2jd (string);
 
2055
    dt = utdt (dj0);
 
2056
    dj = dj0 - (dt / 86400.0);
 
2057
    dt = utdt (dj);
 
2058
    tsec = fd2ts (string);
 
2059
    tsec = tsec - dt + 32.184;
 
2060
    return (ts2fd (tsec));
 
2061
}
 
2062
 
 
2063
 
 
2064
/* FD2TAI-- convert from UT in FITS format to TAI in FITS format */
 
2065
 
 
2066
char *
 
2067
fd2tai (string)
 
2068
 
 
2069
char *string;   /* FITS date string, which may be:
 
2070
                        fractional year
 
2071
                        dd/mm/yy (FITS standard before 2000)
 
2072
                        dd-mm-yy (nonstandard use before 2000)
 
2073
                        yyyy-mm-dd (FITS standard after 1999)
 
2074
                        yyyy-mm-ddThh:mm:ss.ss (FITS standard after 1999) */
 
2075
{
 
2076
    double dj, tsec, dt;
 
2077
 
 
2078
    dj = fd2jd (string);
 
2079
    dt = utdt (dj);
 
2080
    tsec = fd2ts (string);
 
2081
    tsec = tsec + dt - 32.184;
 
2082
    return (ts2fd (tsec));
 
2083
}
 
2084
 
 
2085
 
 
2086
/* DT2TAI-- convert from UT as yyyy.mmdd hh.mmssss to TAI in same format */
 
2087
 
 
2088
void
 
2089
dt2tai (date, time)
 
2090
double  *date;  /* Date as yyyy.mmdd */
 
2091
double  *time;  /* Time as hh.mmssxxxx
 
2092
                 *if time<0, it is time as -(fraction of a day) */
 
2093
{
 
2094
    double dj, dt, tsec;
 
2095
 
 
2096
    dj = dt2jd (*date, *time);
 
2097
    dt = utdt (dj);
 
2098
    tsec = dt2ts (*date, *time);
 
2099
    tsec = tsec + dt - 32.184;
 
2100
    ts2dt (tsec, date, time);
 
2101
    return;
 
2102
}
 
2103
 
 
2104
 
 
2105
/* TAI2DT-- convert from TAI as yyyy.mmdd hh.mmssss to UT in same format */
 
2106
 
 
2107
void
 
2108
tai2dt (date, time)
 
2109
double  *date;  /* Date as yyyy.mmdd */
 
2110
double  *time;  /* Time as hh.mmssxxxx
 
2111
                 *if time<0, it is time as -(fraction of a day) */
 
2112
{
 
2113
    double dj, dt, tsec, tsec0;
 
2114
 
 
2115
    dj = dt2jd (*date, *time);
 
2116
    dt = utdt (dj);
 
2117
    tsec0 = dt2ts (*date, *time);
 
2118
    tsec = tsec0 + dt;
 
2119
    dj = ts2jd (tsec);
 
2120
    dt = utdt (dj);
 
2121
    tsec = tsec0 + dt + 32.184;
 
2122
    ts2dt (tsec, date, time);
 
2123
    return;
 
2124
}
 
2125
 
 
2126
 
2032
2127
/* ET2FD-- convert from ET (or TDT or TT) in FITS format to UT in FITS format */
2033
2128
 
2034
2129
char *
2196
2291
            if (dj >= taijd[i])
2197
2292
                dt = taidt[i];
2198
2293
            }
2199
 
        dt = dt + 32.84;
 
2294
        dt = dt + 32.184;
2200
2295
        }
2201
2296
 
2202
2297
    /* For 1800-01-01 to 1972-01-01, use table of ET-UT from AE */
4454
4549
 * Oct  8 2008  Clean up sidereal time computations
4455
4550
 *
4456
4551
 * Sep 24 2009  Add end to comment "Coefficients for fundamental arguments"
 
4552
 *
 
4553
 * Jan 11 2012  Add TAI, TT, GPS time
4457
4554
 */