Changeset 3436 for trunk/doc/pslib/psLibADD.tex
- Timestamp:
- Mar 16, 2005, 3:36:07 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibADD.tex (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibADD.tex
r3430 r3436 1 %%% $Id: psLibADD.tex,v 1.6 6 2005-03-16 01:50:24jhoblitt Exp $1 %%% $Id: psLibADD.tex,v 1.67 2005-03-17 01:36:07 jhoblitt Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 … … 786 786 Correct time representation is \emph{critical} in astronomical software. PSLib 787 787 uses 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. 788 represents a time which consists of seconds and nanoseconds in a time 789 system defined by the \code{psTimeType} element \code{type}. All available 790 time-systems are defined in terms of the reference epoch 791 ``1970-01-01T00:00:00Z'' (Gregorian\footnote{Gregorian Calendar - 792 http://en.wikipedia.org/wiki/Gregorian\_calendar}), but with minor 793 modifications, as needed, for for features such as leap-seconds. The first 794 represenatation, 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 797 seconds of uniform length and leap-seconds as needed to adjust it to remain 798 within $0.9s$ of the Earth's rotation. It has a zero-point of exactly 799 ``1970-01-01T00:00:00Z'' UTC. 798 800 799 801 \paragraph{Coordinated Universal Time (UTC)} 800 802 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. 803 Coordinated Univeral Time (UTC) is defined by the International 804 Telecommunication Union (ITU)\footnote{ITU website - 805 http://www.itu.int/home/index.html}. It is a system of time with SI length 806 seconds but attempts to stay within $1s$ of UT1. This is done by the insertion 807 of a ``leap-second'' whenever $\lvert UTC-UT1 \rvert \ge 0.9s$. By 808 definition\footnote{UTC definition - 809 http://www.cl.cam.ac.uk/~mgk25/volatile/ITU-R-TF.460-4.pdf}, $UTC-TAI$ is an 810 integer number of seconds. UTC went into effect on ``1972-01-01T00:00:00Z'' 811 and 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. 808 813 809 814 \begin{equation} … … 811 816 \end{equation} 812 817 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. 818 Leap-seconds are declared by the International Earth Rotation and Reference 819 Systems Service (IERS)\footnote{IERS website - http://www.iers.org/}. 820 leap-seconds only occur in the UTC time system and cannot be accurately 821 predicted due to variations in the Earth's rotational period. To determine the 822 number of leap-second in a given UTC date a table of leap-seconds as annouced by 823 the IERS must be consulted. This table will have to be updated each time a new 824 leap-second occurs. 819 825 820 826 For 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.} 827 since 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 829 timezone is forbidden.} 823 830 824 831 \paragraph{International Atomic Time (TAI)} 825 832 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 leap seconds}833 International Atomic Time or Temps Atomique International (TAI) is a system of 834 time defined by the Bureau International des Poids et Mesures 835 (BIPM)\footnote{BIPM website - http://www.bipm.fr/} with SI length seconds as 836 measured at sea level. To convert from UTC to TAI add the base delta of $10s$ 837 and all of the accumulated leap-seconds since ``1972-01-01'' up until the UTC 838 date being converted. 839 840 \begin{equation} 841 {\rm TAI} = {\rm UTC} + 10{\rm s} + {\rm leap-seconds} 835 842 \end{equation} 836 843 837 844 For 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}845 seconds since the UNIX epoch of ``1970-01-01T00:00:00Z''. 846 847 \paragraph{Leap-seconds} 841 848 842 849 Leap seconds keep UTC within 0.9s of UT1. The offset between TAI and … … 874 881 file will be made configurable. 875 882 876 This data is available from 877 \code{ftp://maia.usno.navy.mil/ser7/tai-utc.dat} 883 This data is available from: \code{ftp://maia.usno.navy.mil/ser7/tai-utc.dat} 878 884 879 885 \paragraph{Gregorian dates to seconds} 880 886 881 The below algorithm converts from Gregorian-formatted dates to 882 seconds since the UNIX epoch. 883 887 The Perl code below, based on an algorithm described in the book ``Calendrical 888 Calculations''\footnote{Calendrical Calculations - 889 http://emr.cs.iit.edu/home/reingold/calendar-book/second-edition/} and modified 890 to return seconds, converts from Gregorian-formatted dates to seconds since the 891 UNIX epoch. 892 893 Given year, month, day as \code{$y, $m, $d}. 884 894 \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 ) 889 902 { 890 year -= ( temp = ( 14 - month ) / 12 )891 month += 12 * temp903 $y -= ( $adj = ( 14 - $m ) / 12 ); 904 $m += 12 * $adj; 892 905 } 893 els e if ( month> 14 )906 elsif ( $m > 14 ) 894 907 { 895 year += ( temp = ( month - 3 ) / 12 )896 month -= 12 * temp908 $y += ( $adj = ( $m - 3 ) / 12 ); 909 $m -= 12 * $adj; 897 910 } 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} 932 Outputs seconds as \code{$utc}. 933 934 To go the other way: 935 936 Given 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 898 942 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 ) 901 952 { 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; 904 956 } 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 ); 916 1003 \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}.) 1004 Outputs 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 - 1008 http://search.cpan.org/~drolsky/DateTime/} (C) 2003 Dave Rolsky. 1009 Please see the DateTime project website\footnote{DateTime project - 1010 http://datetime.perl.org} for further details.} 959 1011 960 1012 … … 978 1030 post-2003 definition. 979 1031 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 - 1032 UT1 is continuously measured by the International Earth Rotation Service, and 1033 tabulated values of the offset of UT1 from UTC are published at regular 1034 intervals, along with predicted future values. IERS Bulletin A gives ``rapid 1035 response'' 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 1037 final, definitive data reduction. An amalgam of Bulletin A and B values is 1038 published daily on the IERS website\footnote{IERS Bulletin A \& B - 988 1039 http://maia.usno.navy.mil/ser7/finals2000A.daily} along with a desciption of 989 1040 the format\footnote{IERS finals2000A.daily table format - … … 1003 1054 IERS publications references above, and should be interpolated in the same way. 1004 1055 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 1058 The follow definitions of Julian Date (JD) and Modified Julian Date (MJD) was 1059 taken from, ``RESOLUTION B1: ON THE USE OF JULIAN DATES'' of ``The XXIIIrd 1060 International Astronomical Union General Assembly''\footnote{RESOLUTION B1: ON 1061 THE USE OF JULIAN DATES - 1062 http://www.iers.org/iers/earth/resolutions/UAI\_b1.html}. 1063 1064 \subparagraph{Julian Date} 1065 1066 \begin{verbatim} 1067 1. Julian day number (JDN) 1068 1069 The Julian day number associated with the solar day is the number assigned to a 1070 day in a continuous count of days beginning with the Julian day number 0 1071 assigned to the day starting at Greenwich mean noon on 1 January 4713 BC, 1072 Julian proleptic calendar -4712. 1073 1074 2. Julian Date (JD) 1075 1076 The Julian Date (JD) of any instant is the Julian day number for the preceding 1077 noon plus the fraction of the day since that instant. A Julian Date begins at 1078 12h 0m 0s and is composed of 86400 seconds. To determine time intervals in a 1079 uniform time system it is necessary to express the JD in a uniform time scale. 1080 For that purpose it is recommended that JD be specified as SI seconds in 1081 Terrestrial Time (TT) where the length of day is 86,400 SI seconds. 1082 1083 In some cases it may be necessary to specify Julian Date using a different time 1084 scale. (See Seidelmann, 1992, for an explanation of the various time scales in 1085 use). The time scale used should be indicated when required such as JD(UT1). It 1086 should be noted that time intervals calculated from differences of Julian Dates 1087 specified in non-uniform time scales, such as UTC, may need to be corrected for 1088 changes 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 1095 midnight, the Modified Julian Date (equivalent to the Julian Date minus 2 400 1096 000.5) be used" 1097 \end{verbatim} 1098 1099 \subparagraph{JD and MJD conversion} 1100 1011 1101 Conversion between \code{psTime} values and MJD and JD are determined 1012 1102 from: 1013 1103 1104 Where \code{psTime} is a \code{PS_TIME_TAI}. 1014 1105 \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;1106 mjd = psTime.sec/86400.0 + psTime.nsec/86400000000000.0 + 40587.0; 1107 jd = psTime.sec/86400.0 + psTime.nsec/86400000000000.0 + 2440587.5; 1017 1108 \end{verbatim} 1018 1109 1019 $2451545.0$ JD $= 51544.5$ MJD is equivalent to ``2000-01-01T00:00:00Z''. 1110 For reference $2451545.0$ JD $= 51544.5$ MJD is equivalent to 1111 ``2000-01-01T00:00:00Z''. 1020 1112 1021 1113 \begin{equation}
Note:
See TracChangeset
for help on using the changeset viewer.
