IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 24, 2004, 6:36:56 PM (22 years ago)
Author:
Paul Price
Message:

Hacked time stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/pslib/psLibADD.tex

    r1608 r1618  
    1 %%% $Id: psLibADD.tex,v 1.30 2004-08-24 19:32:18 eugene Exp $
     1%%% $Id: psLibADD.tex,v 1.31 2004-08-25 04:36:56 price Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    694694
    695695Correct time representation is critical in astronomical software.
    696 PSLib uses the \code{psTime} structure to represent all time values.
    697 This structure represents a time which is consists of seconds and
    698 fractions of seconds in a time system defined by the \code{psTimeType}
    699 element \code{type}.  Two possible time systems are currently
    700 available: TAI and UTC.  Both are defined in terms of the reference
    701 epoch 1970-01-01T00:00:00Z, but with minor modifications for
    702 leap-seconds as needed.  The first represenatation, TAI (International
    703 Atomic Time), has seconds of uniform length and no leap seconds.  The
    704 exact zero reference is 1970/01/01,00:00:10 UTC.  The second
    705 representations is UTC, which has seconds of uniform length and
    706 leap-seconds as needed to adjust it to remain within 0.9 seconds of
    707 the Earth's rotation.  It has a zero-point of exactly
    708 1970/01/01,00:00:00 UTC.
     696PSLib uses the \code{psTime} structure to represent time values.  This
     697structure represents a time which is consists of seconds and fractions
     698of seconds in a time system defined by the \code{psTimeType} element
     699\code{type}.  Two possible time systems are currently available: TAI
     700and UTC.  Both are defined in terms of the reference epoch
     7011970-01-01T00:00:00Z, but with minor modifications for leap seconds as
     702needed.  The first represenatation, TAI (International Atomic Time),
     703has seconds of uniform length and no leap seconds.  The exact zero
     704reference is 1970/01/01,00:00:10 UTC.  The second representation is
     705UTC, which has seconds of uniform length and leap seconds as needed to
     706adjust it to remain within 0.9 seconds of the Earth's rotation.  It
     707has a zero-point of exactly 1970/01/01,00:00:00 UTC.
     708
     709
     710The conversion from a time and longitude to local mean sidereal time
     711is performed using the SLALib function \code{sla_GMST}. 
     712\paragraph{Coordinated Universal Time (UTC)}
     713
     714Coordinated Univeral Time (UTC) is a system of time with SI length
     715seconds but attempts to stay within 1s of UT1.  This is done by the
     716insertion of leap second whenever UTC-UT1 $\ge$ 0.9s.  By definition
     717UTC-TAI is an integer number of seconds.  UTC went into effect on
     718"1972-01-01T00:00:00" and is defined as being UTC-TAI = 10s on that
     719date.  For dates prior to 1972-01-01 a fixed offset of +10s relative
     720to TAI will be assumed.
     721
     722\begin{equation}
     723UTC = TAI + 10s + leapseconds
     724\end{equation}
     725
     726Leapseconds are declared by the International Earth Rotation and
     727Reference Systems Service (IERS).  Leapseconds only occur in the UTC
     728time system and cannot be accurately predicted due to variations in
     729the Earth's rotational period.  To determine the number of leapsecond
     730in a given UTC date a table of leapseconds as annouced by the IERS
     731must be consulted.  This table will have to be updated each time a new
     732leapsecond occurs.
     733
     734For ease of conversion, UTC should be represented as the number of
     735seconds since the UNIX epoch of "1970-01-01T00:00:00".
     736
     737\paragraph{International Atomic Time (TAI)}
     738
     739International Atomic Time or Temps Atomique International (TAI) is a
     740system of time defined by the Bureau International des Poids et
     741Mesures (BIPM) with SI length seconds as measured at sea level.  To
     742convert from UTC to TAI subtract the base delta of $10s$ and all of
     743the accumulated leapsecons since 1972-01-01 up until the UTC date
     744being converted.
     745
     746\begin{equation}
     747{\rm TAI} = {\rm UTC} - 10{\rm s} - {\rm leapseconds}
     748\end{equation}
     749
     750For ease of conversion, TAI should be represented as the number of
     751seconds since the UNIX epoch of "1970-01-01T00:00:00".
     752
     753\paragraph{Leap seconds}
     754
     755Leap seconds keep UTC within 0.9s of UT1.  The offset between TAI and
     756UTC must be looked up from tables.  Jumps in the offset correspond to
     757leap seconds.
     758
     759\begin{verbatim}
     760 1972 JUL  1 =JD 2441499.5  TAI-UTC=  11.0       S + (MJD - 41317.) X 0.0 S
     761 1973 JAN  1 =JD 2441683.5  TAI-UTC=  12.0       S + (MJD - 41317.) X 0.0 S
     762 1974 JAN  1 =JD 2442048.5  TAI-UTC=  13.0       S + (MJD - 41317.) X 0.0 S
     763 1975 JAN  1 =JD 2442413.5  TAI-UTC=  14.0       S + (MJD - 41317.) X 0.0 S
     764 1976 JAN  1 =JD 2442778.5  TAI-UTC=  15.0       S + (MJD - 41317.) X 0.0 S
     765 1977 JAN  1 =JD 2443144.5  TAI-UTC=  16.0       S + (MJD - 41317.) X 0.0 S
     766 1978 JAN  1 =JD 2443509.5  TAI-UTC=  17.0       S + (MJD - 41317.) X 0.0 S
     767 1979 JAN  1 =JD 2443874.5  TAI-UTC=  18.0       S + (MJD - 41317.) X 0.0 S
     768 1980 JAN  1 =JD 2444239.5  TAI-UTC=  19.0       S + (MJD - 41317.) X 0.0 S
     769 1981 JUL  1 =JD 2444786.5  TAI-UTC=  20.0       S + (MJD - 41317.) X 0.0 S
     770 1982 JUL  1 =JD 2445151.5  TAI-UTC=  21.0       S + (MJD - 41317.) X 0.0 S
     771 1983 JUL  1 =JD 2445516.5  TAI-UTC=  22.0       S + (MJD - 41317.) X 0.0 S
     772 1985 JUL  1 =JD 2446247.5  TAI-UTC=  23.0       S + (MJD - 41317.) X 0.0 S
     773 1988 JAN  1 =JD 2447161.5  TAI-UTC=  24.0       S + (MJD - 41317.) X 0.0 S
     774 1990 JAN  1 =JD 2447892.5  TAI-UTC=  25.0       S + (MJD - 41317.) X 0.0 S
     775 1991 JAN  1 =JD 2448257.5  TAI-UTC=  26.0       S + (MJD - 41317.) X 0.0 S
     776 1992 JUL  1 =JD 2448804.5  TAI-UTC=  27.0       S + (MJD - 41317.) X 0.0 S
     777 1993 JUL  1 =JD 2449169.5  TAI-UTC=  28.0       S + (MJD - 41317.) X 0.0 S
     778 1994 JUL  1 =JD 2449534.5  TAI-UTC=  29.0       S + (MJD - 41317.) X 0.0 S
     779 1996 JAN  1 =JD 2450083.5  TAI-UTC=  30.0       S + (MJD - 41317.) X 0.0 S
     780 1997 JUL  1 =JD 2450630.5  TAI-UTC=  31.0       S + (MJD - 41317.) X 0.0 S
     781 1999 JAN  1 =JD 2451179.5  TAI-UTC=  32.0       S + (MJD - 41317.) X 0.0 S
     782\end{verbatim}
     783
     784For the present time, it should be assumed that this table resides on
     785local disk in a known location (i.e., there is no need that it is
     786downloaded from the internet by PSLib).  Later, the location of this
     787file will be made configurable.
     788
     789This data is available from
     790\code{http://hpiers.obspm.fr/eop-pc/earthor/utc/TAI-UTC_tab.html}
     791
     792\paragraph{Gregorian dates to seconds}
     793
     794The below algorithm converts from Gregorian-formatted dates to
     795seconds since the UNIX epoch.
     796
     797\begin{verbatim}
     798    Given year, month, day.
     799
     800    ### Make month in range 3..14 (treat Jan & Feb as months 13..14 of prev year):
     801    if ( month <= 2 )
     802    {
     803        year -= ( temp = ( 14 - month ) / 12 )
     804        month += 12 * temp
     805    }
     806    else if ( month > 14 )
     807    {
     808        year += ( temp = ( month - 3 ) / 12 )
     809        month -= 12 * temp
     810    }
     811 
     812    ### make year positive
     813    if ( year < 0 )
     814    {
     815        day -= 146097 * ( temp = ( 399 - year ) / 400 )
     816        year += 400 * temp
     817    }
     818 
     819    ### add: day of month, days of previous 0-11 month period that began
     820    ### w/March, days of previous 0-399 year period that began w/March
     821    ### of a 400-multiple year), days of any 400-year periods before
     822    ### that, and 306 days to adjust from Mar 1, year 0-relative to Jan
     823    ### 1, year 1-relative
     824    day += ( month * 367 - 1094 ) / 12 + year % 100 * 1461 / 4 +
     825          ( year / 100 * 36524 + year / 400 ) - 306
     826
     827    unix = ( ( day - 1 ) * 86400 ) - 62135596800
     828    utc = unix - leapseconds(unix)
     829\end{verbatim}
     830
     831To go the other way:
     832
     833\begin{verbatim}
     834    unix = utc + leapseconds(utc)
     835    day = ( unix + 62135596800 ) / 86400
     836    temp = 0
     837 
     838    ### add 306 days to make relative to Mar 1, 0; also adjust day to be
     839    ### within a range (1..2**28-1) where our calculations will work
     840    ### with 32bit ints
     841    if ( day > 2**28 - 307 )
     842    {
     843        ### avoid overflow if day close to maxint
     844        temp = ( day - 146097 + 306 ) / 146097 + 1
     845        day -= temp * 146097 - 306
     846    }
     847    else if ( ( day += 306 ) <= 0 )
     848    {
     849        temp = -( -day / 146097 + 1 )  ### avoid ambiguity in C division of negatives
     850        day -= temp * 146097
     851    }
     852 
     853    cent = ( day * 4 - 1 ) / 146097    ### calc number of centuries day is after 29 Feb of yr 0
     854    day -= cent * 146097 / 4           ### (4 centuries = 146097 days)
     855    year = ( day * 4 - 1 ) / 1461      ### calc number of years into the century,
     856    day -= year * 1461 / 4             ### again March-based (4 yrs =~ 146[01] days)
     857    month = ( day * 12 + 1093 ) / 367  ### get the month (3..14 represent March through
     858    day -= ( month * 367 - 1094 ) / 12 ### February of following year)
     859    year += cent * 100 + temp * 400    ### get the real year, which is off by
     860    if ( month > 12 )                  ### one if month is January or February
     861    {
     862        year++
     863        month -= 12
     864    }
     865
     866
     867    Output year, month, day.
     868\end{verbatim}
     869
     870(Above taken from \code{DateTime.pm} (C) 2003 Dave Rolsky, available
     871from \code{datetime.perl.org}.)
     872
     873
     874
     875\paragraph{Universal Time (UT1)}
     876\label{sec:ut1}
     877
     878Univseral Time is a measure of the rotation angle of the Earth.  When
     879corrected for polar motion it is referred to as UT1.  This is distict
     880from UT0 which does not involve corrections for polar motion.
     881
     882The offset of UTC from UT1, $\Delta$ UT1 = UTC - UT1, may be
     883determined from the following site in real time:
     884
     885\code{ftp://maia.usno.navy.mil/ser7/finals.all}
     886
     887\noindent with explanatory guide at
     888
     889\code{ftp://maia.usno.navy.mil/ser7/readme.finals}
     890
     891See also the web page \code{http://maia.usno.navy.mil/}.  The most
     892significant accuracy requirements are for the current value when
     893calculating the LST.  For this purpose, the table above
     894(\code{ser7.dat}), which provides predictions over a 2 month period,
     895must be made available locally to PSLib and updated regularly.
     896
     897For the present time, it should be assumed that this table resides on
     898local disk in a known location (i.e., there is no need that it is
     899downloaded from the internet by PSLib).  Later, the location of this
     900file will be made configurable.
     901
     902For dates within the range of the table, the value for the offset
     903between UTC and UT1 shall be derived from linear interpolation between
     904the nearest entries in the table.  For dates earlier the range of the
     905above table, a warning shall be generated, and the values calculated
     906from a different table (an estimate, instead of observations),
     907obtained from:
     908
     909\code{http://hpiers.obspm.fr/eoppc/eop/eopc01/eopc01.1900-2004}
     910
     911Dates outside the ranges of the above tables shall generate an error.
     912
     913These tables shall be read in only when required by the user, and
     914shall remain in memory until the termination of the program.  An
     915additional function, \code{psTimeTableReset} should be provided in
     916order to force the reloading of the time tables.
     917
     918\paragraph{Julian Day and Modified Julian Day}
    709919
    710920Julian Day (JD) and Modified Julian Day (MJD) are both continuous time
     
    716926
    717927\begin{verbatim}
    718 mjd = psTime.tv_sec/86400.0 + psTime.tv_usec/86400000000.0 + 40587.0;
    719  jd = psTime.tv_sec/86400.0 + psTime.tv_usec/86400000000.0 + 2440587.5;
     928mjd = psTime.sec/86400.0 + psTime.usec/86400000000.0 + 40587.0;
     929 jd = psTime.sec/86400.0 + psTime.usec/86400000000.0 + 2440587.5;
    720930\end{verbatim}
    721931
    722 The entry below gives the current relationship between JD, MJD, UTC,
    723 and TAI, and comes from the reference at
    724 \code{http://tycho.usno.navy.mil/leapsec.html}
    725 
    726 \begin{verbatim}
    727  1961 JAN  1 =JD 2437300.5  TAI-UTC=   1.4228180 S + (MJD - 37300.) X 0.001296 S
    728  1961 AUG  1 =JD 2437512.5  TAI-UTC=   1.3728180 S + (MJD - 37300.) X 0.001296 S
    729  1962 JAN  1 =JD 2437665.5  TAI-UTC=   1.8458580 S + (MJD - 37665.) X 0.0011232S
    730  1963 NOV  1 =JD 2438334.5  TAI-UTC=   1.9458580 S + (MJD - 37665.) X 0.0011232S
    731  1964 JAN  1 =JD 2438395.5  TAI-UTC=   3.2401300 S + (MJD - 38761.) X 0.001296 S
    732  1964 APR  1 =JD 2438486.5  TAI-UTC=   3.3401300 S + (MJD - 38761.) X 0.001296 S
    733  1964 SEP  1 =JD 2438639.5  TAI-UTC=   3.4401300 S + (MJD - 38761.) X 0.001296 S
    734  1965 JAN  1 =JD 2438761.5  TAI-UTC=   3.5401300 S + (MJD - 38761.) X 0.001296 S
    735  1965 MAR  1 =JD 2438820.5  TAI-UTC=   3.6401300 S + (MJD - 38761.) X 0.001296 S
    736  1965 JUL  1 =JD 2438942.5  TAI-UTC=   3.7401300 S + (MJD - 38761.) X 0.001296 S
    737  1965 SEP  1 =JD 2439004.5  TAI-UTC=   3.8401300 S + (MJD - 38761.) X 0.001296 S
    738  1966 JAN  1 =JD 2439126.5  TAI-UTC=   4.3131700 S + (MJD - 39126.) X 0.002592 S
    739  1968 FEB  1 =JD 2439887.5  TAI-UTC=   4.2131700 S + (MJD - 39126.) X 0.002592 S
    740  1972 JAN  1 =JD 2441317.5  TAI-UTC=  10.0       S + (MJD - 41317.) X 0.0      S
    741  1972 JUL  1 =JD 2441499.5  TAI-UTC=  11.0       S + (MJD - 41317.) X 0.0      S
    742  1973 JAN  1 =JD 2441683.5  TAI-UTC=  12.0       S + (MJD - 41317.) X 0.0      S
    743  1974 JAN  1 =JD 2442048.5  TAI-UTC=  13.0       S + (MJD - 41317.) X 0.0      S
    744  1975 JAN  1 =JD 2442413.5  TAI-UTC=  14.0       S + (MJD - 41317.) X 0.0      S
    745  1976 JAN  1 =JD 2442778.5  TAI-UTC=  15.0       S + (MJD - 41317.) X 0.0      S
    746  1977 JAN  1 =JD 2443144.5  TAI-UTC=  16.0       S + (MJD - 41317.) X 0.0      S
    747  1978 JAN  1 =JD 2443509.5  TAI-UTC=  17.0       S + (MJD - 41317.) X 0.0      S
    748  1979 JAN  1 =JD 2443874.5  TAI-UTC=  18.0       S + (MJD - 41317.) X 0.0      S
    749  1980 JAN  1 =JD 2444239.5  TAI-UTC=  19.0       S + (MJD - 41317.) X 0.0      S
    750  1981 JUL  1 =JD 2444786.5  TAI-UTC=  20.0       S + (MJD - 41317.) X 0.0      S
    751  1982 JUL  1 =JD 2445151.5  TAI-UTC=  21.0       S + (MJD - 41317.) X 0.0      S
    752  1983 JUL  1 =JD 2445516.5  TAI-UTC=  22.0       S + (MJD - 41317.) X 0.0      S
    753  1985 JUL  1 =JD 2446247.5  TAI-UTC=  23.0       S + (MJD - 41317.) X 0.0      S
    754  1988 JAN  1 =JD 2447161.5  TAI-UTC=  24.0       S + (MJD - 41317.) X 0.0      S
    755  1990 JAN  1 =JD 2447892.5  TAI-UTC=  25.0       S + (MJD - 41317.) X 0.0      S
    756  1991 JAN  1 =JD 2448257.5  TAI-UTC=  26.0       S + (MJD - 41317.) X 0.0      S
    757  1992 JUL  1 =JD 2448804.5  TAI-UTC=  27.0       S + (MJD - 41317.) X 0.0      S
    758  1993 JUL  1 =JD 2449169.5  TAI-UTC=  28.0       S + (MJD - 41317.) X 0.0      S
    759  1994 JUL  1 =JD 2449534.5  TAI-UTC=  29.0       S + (MJD - 41317.) X 0.0      S
    760  1996 JAN  1 =JD 2450083.5  TAI-UTC=  30.0       S + (MJD - 41317.) X 0.0      S
    761  1997 JUL  1 =JD 2450630.5  TAI-UTC=  31.0       S + (MJD - 41317.) X 0.0      S
    762  1999 JAN  1 =JD 2451179.5  TAI-UTC=  32.0       S + (MJD - 41317.) X 0.0      S
    763 \end{verbatim}
    764 
    765 The conversion from a time and longitude to local mean sidereal time
    766 is performed using the SLA Lib function \code{sla_GMST}.  This
    767 function requires the value $\Delta$ UT1 = UTC - UT1.  The value of
    768 $\Delta$ UT1 may be determined from the following site in real time:
    769 
    770 \code{ftp://maia.usno.navy.mil/ser7/ser7.dat}
    771 
    772 In addition, the long-term values may be determined from the table
    773 found at: \code{ftp://maia.usno.navy.mil/ser7/finals.all}.  See also
    774 the web page \code{http://maia.usno.navy.mil/}.  The most significant
    775 accuracy requirements are for the current value when calculating the
    776 LST.  For this purpose, the table above (\code{ser7.dat}), which
    777 provides predictions over a 2 month period, must be made available
    778 locally to PSLib and updated regularly.
     932$2451545.0$ JD $= 51544.5$ MJD is equivalent to "2000-01-01T00:00:00".
     933
     934\begin{equation}
     935{\rm JD} = {\rm MJD} + 2400000.5
     936\end{equation}
     937
     938\paragraph{Terrestrial Dynamical Time (TDT)}
     939
     940Terrestrial Dynamical Time (TDT) is defined as a fixed offset from
     941TAI.  Its only purpose as far as we are concerned is for its utility
     942in obtaining the GMST.
     943
     944\begin{equation}
     945{\rm TDT} = {\rm TAI} + 32.184{\rm s}
     946\end{equation}
     947
     948\paragraph{TDT as Julian Centuries since J2000.0}
     949
     950The algorithm for calulating GMST requires TDT formated in Julian centruies
     951since the J2000.0 epoch.
     952
     953\begin{equation}
     954t_u = \frac{{\rm JD} - 2451545.0}{36525}
     955\end{equation}
     956
     957\paragraph{UT1 as Julian Centuries since J2000.0}
     958
     959The algorithm for calulating GMST requires UT1 be formated in Julian
     960centuries since the J2000.0 epoch.
     961
     962\begin{equation}
     963t = \frac{{\rm JD} - 2451545.0}{36525}
     964\end{equation}
     965
     966\paragraph{Greenwich Mean Sidereal Time (GMST)}
     967
     968Greenwich Mean Sidereal Time (GMST) is caclulated from UT1 and TDT.
     969This algorithm requires that both time inputs are expressed as Julian
     970centuries since J2000.0.
     971
     972Here $t_u$ is UT1 expressed in Julian centuries since J2000.0, and $t$
     973is TDT expressed in Julian centuries since J2000.0.
     974
     975\begin{eqnarray}
     976{\rm GMST00}(t_u, t) & = & UT1 + 24110.5493771\\
     977& & + 8639877.3173760\, t_u + 307.4771600\, t\\
     978& & + 0.0931118\, t^2 - 0.0000062\, t^3\\
     979& & + 0.0000013\, t^4
     980\end{eqnarray}
     981
     982Gives $GMST00$ in seconds.
     983
     984\paragraph{Longitude}
     985
     986Longitudes are often expressed in the form of decimal degrees while the
     987algorithm for calculating GMST outputs seconds.
     988
     989\begin{equation}
     9901\degree = 240s
     991\end{equation}
     992
     993\paragraph{Local Mean Sidereal Time (LMST)}
     994
     995Local Mean Sidereal Time (LMST) is Greenwich Mean Sideral Time (GMST)
     996plus the observer's location in East longitude. Calculating LMST
     997requires the input of Universal Time (UT1), Terrestrial Dynamical Time
     998(TDT) and a longitude (measured East of Greenwich).
     999
     1000\begin{equation}
     1001LMST = GMST00(t_u, t) + longitude
     1002\end{equation}
     1003
     1004Gives $LMST$ in seconds.
     1005
     1006\paragraph{Polar Coordinates}
     1007
     1008The polar coordinates, $x_p$ and $y_p$, required for \code{SLA_AOPPA}
     1009(and hence the \code{psGrommit}s), may be calculated in a similar
     1010manner as for the offset of UT1 from UTC (\S\ref{sec:ut1}).
    7791011
    7801012%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset for help on using the changeset viewer.