IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 16, 2005, 3:36:07 PM (21 years ago)
Author:
jhoblitt
Message:

Changes to the Time section:
added references
updated definitions of UTC, UT1, JD, MJD
misc formatting
verbatim Perl code for YMD->sec and sec->YMD conversion

File:
1 edited

Legend:

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

    r3430 r3436  
    1 %%% $Id: psLibADD.tex,v 1.66 2005-03-16 01:50:24 jhoblitt Exp $
     1%%% $Id: psLibADD.tex,v 1.67 2005-03-17 01:36:07 jhoblitt Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    786786Correct time representation is \emph{critical} in astronomical software.  PSLib
    787787uses the \code{psTime} structure to represent time values.  This structure
    788 represents a time which is consists of seconds and fractions of seconds in a
    789 time system defined by the \code{psTimeType} element \code{type}.  Two possible
    790 time systems are currently available: TAI and UTC.  Both are defined in terms
    791 of the reference epoch ``1970-01-01T00:00:00Z'', but with minor modifications
    792 for leap seconds as needed.  The first represenatation, TAI (International
    793 Atomic Time), has seconds of uniform length (SI seconds) and no leap seconds.
    794 The exact zero reference is ``1970-01-01T00:00:10Z'' UTC.  The second
    795 representation is UTC, which has seconds of uniform length and leap seconds as
    796 needed to adjust it to remain within 0.9 seconds of the Earth's rotation.  It
    797 has a zero-point of exactly ``1970-01-01T00:00:00Z'' UTC.
     788represents a time which consists of seconds and nanoseconds in a time
     789system defined by the \code{psTimeType} element \code{type}.  All available
     790time-systems are defined in terms of the reference epoch
     791``1970-01-01T00:00:00Z'' (Gregorian\footnote{Gregorian Calendar -
     792http://en.wikipedia.org/wiki/Gregorian\_calendar}), but with minor
     793modifications, as needed, for for features such as leap-seconds.  The first
     794represenatation, TAI (International Atomic Time), has seconds of uniform length
     795(SI seconds) and no leap-seconds.  The exact zero reference is
     796``1970-01-01T00:00:10Z'' UTC.  The second representation is UTC, which has
     797seconds of uniform length and leap-seconds as needed to adjust it to remain
     798within $0.9s$ of the Earth's rotation.  It has a zero-point of exactly
     799``1970-01-01T00:00:00Z'' UTC.
    798800
    799801\paragraph{Coordinated Universal Time (UTC)}
    800802
    801 Coordinated Univeral Time (UTC) is a system of time with SI length
    802 seconds but attempts to stay within 1s of UT1.  This is done by the
    803 insertion of leap second whenever UTC-UT1 $\ge$ 0.9s.  By definition
    804 UTC-TAI is an integer number of seconds.  UTC went into effect on
    805 ``1972-01-01T00:00:00Z'' and is defined as being TAI-UTC = 10s on that
    806 date.  For dates prior to 1972-01-01 a fixed offset of 10s relative
    807 to TAI will be assumed.
     803Coordinated Univeral Time (UTC) is defined by the International
     804Telecommunication Union (ITU)\footnote{ITU website -
     805http://www.itu.int/home/index.html}.  It is a system of time with SI length
     806seconds but attempts to stay within $1s$ of UT1.  This is done by the insertion
     807of a ``leap-second'' whenever $\lvert UTC-UT1 \rvert \ge 0.9s$.  By
     808definition\footnote{UTC definition -
     809http://www.cl.cam.ac.uk/~mgk25/volatile/ITU-R-TF.460-4.pdf}, $UTC-TAI$ is an
     810integer number of seconds.  UTC went into effect on ``1972-01-01T00:00:00Z''
     811and is defined as being $TAI-UTC = 10s$ on that date.  For dates prior to
     812``1972-01-01'' a fixed offset of 10s relative to TAI will be assumed.
    808813
    809814\begin{equation}
     
    811816\end{equation}
    812817
    813 Leapseconds are declared by the International Earth Rotation and Reference
    814 Systems Service (IERS).  Leapseconds only occur in the UTC time system and
    815 cannot be accurately predicted due to variations in the Earth's rotational
    816 period.  To determine the number of leapsecond in a given UTC date a table of
    817 leapseconds as annouced by the IERS must be consulted.  This table will have to
    818 be updated each time a new leapsecond occurs.
     818Leap-seconds are declared by the International Earth Rotation and Reference
     819Systems Service (IERS)\footnote{IERS website - http://www.iers.org/}.
     820leap-seconds only occur in the UTC time system and cannot be accurately
     821predicted due to variations in the Earth's rotational period.  To determine the
     822number of leap-second in a given UTC date a table of leap-seconds as annouced by
     823the IERS must be consulted.  This table will have to be updated each time a new
     824leap-second occurs.
    819825
    820826For ease of conversion, UTC should be represented as the number of seconds
    821 since the UNIX epoch of ``1970-01-01T00:00:00Z''.  \emph{Times will always be
    822 expressed in the 'UTC' timezone.  Use of the local timezone is forbidden.}
     827since the UNIX epoch of ``1970-01-01T00:00:00Z'', non-inclusive of leap-seconds.
     828\emph{Times will always be expressed in the 'UTC timezone'.  Use of the local
     829timezone is forbidden.}
    823830
    824831\paragraph{International Atomic Time (TAI)}
    825832
    826 International Atomic Time or Temps Atomique International (TAI) is a
    827 system of time defined by the Bureau International des Poids et
    828 Mesures (BIPM) with SI length seconds as measured at sea level.  To
    829 convert from UTC to TAI add the base delta of $10s$ and all of
    830 the accumulated leapsecons since 1972-01-01 up until the UTC date
    831 being converted.
    832 
    833 \begin{equation}
    834 {\rm TAI} = {\rm UTC} + 10{\rm s} + {\rm leapseconds}
     833International Atomic Time or Temps Atomique International (TAI) is a system of
     834time defined by the Bureau International des Poids et Mesures
     835(BIPM)\footnote{BIPM website - http://www.bipm.fr/} with SI length seconds as
     836measured at sea level.  To convert from UTC to TAI add the base delta of $10s$
     837and all of the accumulated leap-seconds since ``1972-01-01'' up until the UTC
     838date being converted.
     839
     840\begin{equation}
     841{\rm TAI} = {\rm UTC} + 10{\rm s} + {\rm leap-seconds}
    835842\end{equation}
    836843
    837844For ease of conversion, TAI should be represented as the number of
    838 seconds since the UNIX epoch of "1970-01-01T00:00:00".
    839 
    840 \paragraph{Leap seconds}
     845seconds since the UNIX epoch of ``1970-01-01T00:00:00Z''.
     846
     847\paragraph{Leap-seconds}
    841848
    842849Leap seconds keep UTC within 0.9s of UT1.  The offset between TAI and
     
    874881file will be made configurable.
    875882
    876 This data is available from
    877 \code{ftp://maia.usno.navy.mil/ser7/tai-utc.dat}
     883This data is available from: \code{ftp://maia.usno.navy.mil/ser7/tai-utc.dat}
    878884
    879885\paragraph{Gregorian dates to seconds}
    880886
    881 The below algorithm converts from Gregorian-formatted dates to
    882 seconds since the UNIX epoch.
    883 
     887The Perl code below, based on an algorithm described in the book ``Calendrical
     888Calculations''\footnote{Calendrical Calculations -
     889http://emr.cs.iit.edu/home/reingold/calendar-book/second-edition/} and modified
     890to return seconds, converts from Gregorian-formatted dates to seconds since the
     891UNIX epoch.
     892
     893Given year, month, day as \code{$y, $m, $d}.
    884894\begin{verbatim}
    885     Given year, month, day.
    886 
    887     ### Make month in range 3..14 (treat Jan & Feb as months 13..14 of prev year):
    888     if ( month <= 2 )
     895    use integer;
     896
     897    my $adj;
     898
     899    # make month in range 3..14 (treat Jan & Feb as months 13..14 of
     900    # prev year)
     901    if ( $m <= 2 )
    889902    {
    890         year -= ( temp = ( 14 - month ) / 12 )
    891         month += 12 * temp
     903        $y -= ( $adj = ( 14 - $m ) / 12 );
     904        $m += 12 * $adj;
    892905    }
    893     else if ( month > 14 )
     906    elsif ( $m > 14 )
    894907    {
    895         year += ( temp = ( month - 3 ) / 12 )
    896         month -= 12 * temp
     908        $y += ( $adj = ( $m - 3 ) / 12 );
     909        $m -= 12 * $adj;
    897910    }
     911
     912    # make year positive (oh, for a use integer 'sane_div'!)
     913    if ( $y < 0 )
     914    {
     915        $d -= 146097 * ( $adj = ( 399 - $y ) / 400 );
     916        $y += 400 * $adj;
     917    }
     918
     919    # add: day of month, days of previous 0-11 month period that began
     920    # w/March, days of previous 0-399 year period that began w/March
     921    # of a 400-multiple year), days of any 400-year periods before
     922    # that, and 306 days to adjust from Mar 1, year 0-relative to Jan
     923    # 1, year 1-relative (whew)
     924
     925    $d += ( $m * 367 - 1094 ) / 12 + $y % 100 * 1461 / 4 +
     926          ( $y / 100 * 36524 + $y / 400 ) - 306;
     927
     928    # convert from count of days to seconds since the UNIX epoch
     929    $unix = ( ( $d - 1 ) * 86400 ) - 62135596800;
     930    $utc = $unix - leapseconds($unix);
     931\end{verbatim}
     932Outputs seconds as \code{$utc}.
     933
     934To go the other way:
     935
     936Given the number of seconds since the UNIX epoch as \code{$utc}.
     937\begin{verbatim}
     938    use integer;
     939
     940    my $unix = $utc + leapseconds( $utc )
     941    $d = ( unix + 62135596800 ) / 86400
    898942 
    899     ### make year positive
    900     if ( year < 0 )
     943    my $rd = $d;
     944
     945    my $yadj = 0;
     946    my ( $c, $y, $m );
     947
     948    # add 306 days to make relative to Mar 1, 0; also adjust $d to be
     949    # within a range (1..2**28-1) where our calculations will work
     950    # with 32bit ints
     951    if ( $d > 2**28 - 307 )
    901952    {
    902         day -= 146097 * ( temp = ( 399 - year ) / 400 )
    903         year += 400 * temp
     953        # avoid overflow if $d close to maxint
     954        $yadj = ( $d - 146097 + 306 ) / 146097 + 1;
     955        $d -= $yadj * 146097 - 306;
    904956    }
    905  
    906     ### add: day of month, days of previous 0-11 month period that began
    907     ### w/March, days of previous 0-399 year period that began w/March
    908     ### of a 400-multiple year), days of any 400-year periods before
    909     ### that, and 306 days to adjust from Mar 1, year 0-relative to Jan
    910     ### 1, year 1-relative
    911     day += ( month * 367 - 1094 ) / 12 + year % 100 * 1461 / 4 +
    912           ( year / 100 * 36524 + year / 400 ) - 306
    913 
    914     unix = ( ( day - 1 ) * 86400 ) - 62135596800
    915     utc = unix - leapseconds(unix)
     957    elsif ( ( $d += 306 ) <= 0 )
     958    {
     959        $yadj =
     960          -( -$d / 146097 + 1 );    # avoid ambiguity in C division of negatives        $d -= $yadj * 146097;
     961    }
     962
     963    $c = ( $d * 4 - 1 ) / 146097;   # calc # of centuries $d is after 29 Feb of yr 0
     964    $d -= $c * 146097 / 4;          # (4 centuries = 146097 days)
     965    $y = ( $d * 4 - 1 ) / 1461;     # calc number of years into the century,
     966    $d -= $y * 1461 / 4;            # again March-based (4 yrs =~ 146[01] days)
     967    $m = ( $d * 12 + 1093 ) / 367;  # get the month (3..14 represent March through
     968    $d -= ( $m * 367 - 1094 ) / 12; # February of following year)
     969    $y += $c * 100 + $yadj * 400;   # get the real year, which is off by
     970    ++$y, $m -= 12 if $m > 12;      # one if month is January or February
     971
     972    if ( $_[0] )
     973    {
     974        my $dow;
     975
     976        if ( $rd < -6 )
     977        {
     978            $dow = ( $rd + 6 ) % 7;
     979            $dow += $dow ? 8 : 1;
     980        }
     981        else
     982        {
     983            $dow = ( ( $rd + 6 ) % 7 ) + 1;
     984        }
     985
     986        my $doy =
     987            $class->_end_of_last_month_day_of_year( $y, $m );
     988
     989        $doy += $d;
     990
     991        my $quarter;
     992        {
     993            no integer;
     994            $quarter = int( ( 1 / 3.1 ) * $m ) + 1;
     995        }
     996
     997        my $qm = ( 3 * $quarter ) - 2;
     998
     999        my $doq =
     1000            ( $doy -
     1001              $class->_end_of_last_month_day_of_year( $y, $qm )
     1002            );
    9161003\end{verbatim}
    917 
    918 To go the other way:
    919 
    920 \begin{verbatim}
    921     unix = utc + leapseconds(utc)
    922     day = ( unix + 62135596800 ) / 86400
    923     temp = 0
    924  
    925     ### add 306 days to make relative to Mar 1, 0; also adjust day to be
    926     ### within a range (1..2**28-1) where our calculations will work
    927     ### with 32bit ints
    928     if ( day > 2**28 - 307 )
    929     {
    930         ### avoid overflow if day close to maxint
    931         temp = ( day - 146097 + 306 ) / 146097 + 1
    932         day -= temp * 146097 - 306
    933     }
    934     else if ( ( day += 306 ) <= 0 )
    935     {
    936         temp = -( -day / 146097 + 1 )  ### avoid ambiguity in C division of negatives
    937         day -= temp * 146097
    938     }
    939  
    940     cent = ( day * 4 - 1 ) / 146097    ### calc number of centuries day is after 29 Feb of yr 0
    941     day -= cent * 146097 / 4           ### (4 centuries = 146097 days)
    942     year = ( day * 4 - 1 ) / 1461      ### calc number of years into the century,
    943     day -= year * 1461 / 4             ### again March-based (4 yrs =~ 146[01] days)
    944     month = ( day * 12 + 1093 ) / 367  ### get the month (3..14 represent March through
    945     day -= ( month * 367 - 1094 ) / 12 ### February of following year)
    946     year += cent * 100 + temp * 400    ### get the real year, which is off by
    947     if ( month > 12 )                  ### one if month is January or February
    948     {
    949         year++
    950         month -= 12
    951     }
    952 
    953 
    954     Output year, month, day.
    955 \end{verbatim}
    956 
    957 (Above taken from \code{DateTime.pm} (C) 2003 Dave Rolsky, available
    958 from \code{datetime.perl.org}.)
     1004Outputs year, month, day as \code{$y, $m, $d}.
     1005
     1006\emph{The above code was taken [and slightly altered] from
     1007\code{DateTime.pm}\footnote{DateTime.pm -
     1008http://search.cpan.org/~drolsky/DateTime/} (C)  2003 Dave Rolsky.
     1009Please see the DateTime project website\footnote{DateTime project -
     1010http://datetime.perl.org} for further details.}
    9591011
    9601012
     
    9781030post-2003 definition.
    9791031
    980 UT1 is continuously measured by the International Earth Rotation
    981 Service\footnote{IERS - http://maia.usno.navy.mil/}, and tabulated values of the
    982 offset of UT1 from UTC are published at regular intervals, along with predicted
    983 future values.  IERS Bulletin A gives "rapid response" values necessary for
    984 real-time and near real-time data analysis (such as Pan-STARRS Otis and IPP
    985 subsystems). Bulletin B gives the results of a final, definitive data
    986 reduction.  An amalgam of Bulletin A and B values is published daily on the
    987 IERS website\footnote{IERS Bulletin A \& B -
     1032UT1 is continuously measured by the International Earth Rotation Service, and
     1033tabulated values of the offset of UT1 from UTC are published at regular
     1034intervals, along with predicted future values.  IERS Bulletin A gives ``rapid
     1035response'' values necessary for real-time and near real-time data analysis
     1036(such as Pan-STARRS Otis and IPP subsystems). Bulletin B gives the results of a
     1037final, definitive data reduction.  An amalgam of Bulletin A and B values is
     1038published daily on the IERS website\footnote{IERS Bulletin A \& B -
    9881039http://maia.usno.navy.mil/ser7/finals2000A.daily} along with a desciption of
    9891040the format\footnote{IERS finals2000A.daily table format -
     
    10031054IERS publications references above, and should be interpolated in the same way.
    10041055
    1005 \paragraph{Julian Day and Modified Julian Day}
    1006 
    1007 Julian Day (JD) and Modified Julian Day (MJD) are both continuous time
    1008 representations, with one julian day interval having a length of 86400
    1009 TAI seconds.  MJD is equal to JD - 2400000.5 and has a zero point
    1010 equal to that of TAI, while JD has a zero point 0.5 off of TAI.
     1056\paragraph{Julian Date and Modified Julian Date}
     1057
     1058The follow definitions of Julian Date (JD) and Modified Julian Date (MJD) was
     1059taken from, ``RESOLUTION B1: ON THE USE OF JULIAN DATES'' of ``The XXIIIrd
     1060International Astronomical Union General Assembly''\footnote{RESOLUTION B1: ON
     1061THE USE OF JULIAN DATES -
     1062http://www.iers.org/iers/earth/resolutions/UAI\_b1.html}.
     1063
     1064\subparagraph{Julian Date}
     1065
     1066\begin{verbatim}
     10671. Julian day number (JDN)
     1068
     1069The Julian day number associated with the solar day is the number assigned to a
     1070day in a continuous count of days beginning with the Julian day number 0
     1071assigned to the day starting at Greenwich mean noon on 1 January 4713 BC,
     1072Julian proleptic calendar -4712.
     1073
     10742. Julian Date (JD)
     1075
     1076The Julian Date (JD) of any instant is the Julian day number for the preceding
     1077noon plus the fraction of the day since that instant. A Julian Date begins at
     107812h 0m 0s and is composed of 86400 seconds. To determine time intervals in a
     1079uniform time system it is necessary to express the JD in a uniform time scale.
     1080For that purpose it is recommended that JD be specified as SI seconds in
     1081Terrestrial Time (TT) where the length of day is 86,400 SI seconds.
     1082
     1083In some cases it may be necessary to specify Julian Date using a different time
     1084scale. (See Seidelmann, 1992, for an explanation of the various time scales in
     1085use). The time scale used should be indicated when required such as JD(UT1). It
     1086should be noted that time intervals calculated from differences of Julian Dates
     1087specified in non-uniform time scales, such as UTC, may need to be corrected for
     1088changes in time scales (e.g. leap seconds).
     1089\end{verbatim}
     1090
     1091\subparagraph{Modified Julian Date}
     1092
     1093\begin{verbatim}
     1094"that for those cases where it is convenient to employ a day beginning at
     1095midnight, the Modified Julian Date (equivalent to the Julian Date minus 2 400
     1096000.5) be used"
     1097\end{verbatim}
     1098
     1099\subparagraph{JD and MJD conversion}
     1100
    10111101Conversion between \code{psTime} values and MJD and JD are determined
    10121102from:
    10131103
     1104Where \code{psTime} is a \code{PS_TIME_TAI}.
    10141105\begin{verbatim}
    1015 mjd = psTime.sec/86400.0 + psTime.usec/86400000000.0 + 40587.0;
    1016  jd = psTime.sec/86400.0 + psTime.usec/86400000000.0 + 2440587.5;
     1106mjd = psTime.sec/86400.0 + psTime.nsec/86400000000000.0 + 40587.0;
     1107 jd = psTime.sec/86400.0 + psTime.nsec/86400000000000.0 + 2440587.5;
    10171108\end{verbatim}
    10181109
    1019 $2451545.0$ JD $= 51544.5$ MJD is equivalent to ``2000-01-01T00:00:00Z''.
     1110For reference $2451545.0$ JD $= 51544.5$ MJD is equivalent to
     1111``2000-01-01T00:00:00Z''.
    10201112
    10211113\begin{equation}
Note: See TracChangeset for help on using the changeset viewer.