IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1554


Ignore:
Timestamp:
Aug 16, 2004, 3:56:41 PM (22 years ago)
Author:
eugene
Message:

cleaned up time handling

Location:
trunk/doc/pslib
Files:
2 edited

Legend:

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

    r1548 r1554  
    1 %%% $Id: psLibADD.tex,v 1.24 2004-08-16 19:12:54 eugene Exp $
     1%%% $Id: psLibADD.tex,v 1.25 2004-08-17 01:56:41 eugene Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    644644
    645645Correct time representation is critical in astronomical software.
    646 PSLib uses the \code{psTime} structure to represent all time
    647 values.  This structure represents a time which is equivalent to TAI
    648 (International Atomic Time) and has the following properties:
    649 \begin{itemize}
    650 \item it represents both seconds and microseconds
    651 \item the seconds are continuous (no leap seconds)
    652 \item the zero reference point is \tbd{1970/01/01,00:00:10} UTC.
    653 \end{itemize}
     646PSLib uses the \code{psTime} structure to represent all time values.
     647This structure represents a time which is consists of seconds and
     648fractions of seconds in a time system defined by the \code{psTimeType}
     649element \code{type}.  Two possible time systems are currently
     650available: TAI and UTC.  Both are defined in terms of the reference
     651epoch 1970-01-01T00:00:00Z, but with minor modifications for
     652leap-seconds as needed.  The first represenatation, TAI (International
     653Atomic Time), has seconds of uniform length and no leap seconds.  The
     654exact zero reference is 1970/01/01,00:00:10 UTC.  The second
     655representations is UTC, which has seconds of uniform length and
     656leap-seconds as needed to adjust it to remain within 0.9 seconds of
     657the Earth's rotation.  It has a zero-point of exactly
     6581970/01/01,00:00:00 UTC.
    654659
    655660Julian Day (JD) and Modified Julian Day (MJD) are both continuous time
     
    708713\end{verbatim}
    709714
     715The conversion from a time and longitude to local mean sidereal time
     716is performed using the SLA Lib function \code{sla_GMST}.  This
     717function requires the value $\Delta$ UT1 = UTC - UT1.  The value of
     718$\Delta$ UT1 may be determined from the following site in real time:
     719
     720\code{ftp://maia.usno.navy.mil/ser7/ser7.dat}
     721
     722In addition, the long-term values may be determined from the table
     723found at: \code{ftp://maia.usno.navy.mil/ser7/finals.all}.  See also
     724the web page \code{http://maia.usno.navy.mil/}.  The most significant
     725accuracy requirements are for the current value when calculating the
     726LST.  For this purpose, the table above (\code{ser7.dat}), which
     727provides predictions over a 2 month period, must be made available
     728locally to PSLib and updated regularly.
     729
    710730%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    711731
     
    842862\subsubsection{Projections}
    843863
    844 We implement three types of projections, {\em zenithal} and {\em
    845 cylindrical} and {\em pseudocylindrical} projections.  These three
    846 require slightly different handling.  Our representations are based on
    847 the treatment of projections presented by
     864We implement three types of projections: {\em zenithal}, {\em
     865cylindrical} and {\em pseudocylindrical}, each requiring slightly
     866different handling.  Our representations are based on the treatment of
     867projections presented by
    848868\href{http://www.cv.nrao.edu/fits/documents/wcs/wcs.all.ps}{Greisen \&
    849 Calabretta (1995, ADASS, 4, 233)}.
     869Calabretta (1995, ADASS, 4, 233)}.  In all of these projections, we
     870are converting from a spherical coordinate $\alpha,\delta$ to a linear
     871(2-D) coordinate $x_p,y_p$.  The projection is defined by the
     872projection type, the projection center ($\alpha_p, \delta_p$) and the
     873the plate scales in the $x_p$ and $y_p$ directions ($\rho_x,\rho_y$).
     874
     875In the structure, \code{psProjection}, the projection type is defined
     876by the element \code{type}, the projection center $\alpha_p,\delta_p$
     877is defined by the elements \code{R,D}, and the plate scales,
     878$\rho_x,\rho_y$, are defined by the elements \code{Xs,Ys}.  The plate
     879scales are applied independently to the $x$ and $y$ coordinates to
     880convert them to the corresponding linear units (ie, pixels):
     881%
     882\begin{eqnarray}
     883x_p & = & \rho_x x \\
     884y_p & = & \rho_y y \\
     885\end{eqnarray}
     886%
     887In the discussions below, we ignore this last step (or first step,
     888depending on the direction of the conversion).
    850889
    851890\paragraph{Zenithal Projections}
    852891
    853892The {\em zenithal} projections are defined relative to a set of
    854 spherical coordinates whose pole is the center of the projection
    855 ($\alpha_p, \delta_p$, or \code{psProjection.R, psProjection.D}).  In
     893spherical coordinates with pole at the center of the projection
     894($\alpha_p, \delta_p$), and which thus represents a coordinate system
     895rotated relative to the coordinate system of $\alpha, \delta$.  In
    856896this spherical coordinate system, the coordinate of longitude is
    857897labeled $\phi$, and has domain of $-\pi < \phi \le \pi$, while the
     
    859899$0 \le \theta \le \pi$.
    860900
    861 For zenithal projections (e.g.\ Gnomonic and Orthographic) the
    862 following hold:
    863 %
    864 \begin{eqnarray}
    865 x & = & R_\theta \sin \phi \\
    866 y & = & -R_\theta \cos \phi
    867 \end{eqnarray}
    868 %
    869 and
    870 %
    871 \begin{eqnarray}
    872 R_\theta & = & \sqrt{x^2 + y^2} \\
    873 \phi     & = & {\rm arg} (-y,x)
    874 \end{eqnarray}
    875 %
    876 The coordinates $x,y$ above are defined to be in angular units (ie,
    877 radians).  The plate scales ($\rho_x, \rho_y$ = \code{psProjection.Xs,
    878 psProjection.Ys}) are applied independently to the $x$ and $y$
    879 coordinates to convert them to the corresponding linear units (ie,
    880 pixels):
    881 %
    882 \begin{eqnarray}
    883 x_p & = & \rho_x x \\
    884 y_p & = & \rho_y y \\
    885 \end{eqnarray}
    886 
    887901For an arbitrary projection center, it is necessary to convert the
    888902spherical coordinates to be projected ($\alpha,\delta$) to the
    889 projection spherical coordinate system coordinates ($\phi, \theta$)
    890 from which $x,y$ may be calculated using the relationships above,
    891 given a prescription for $R_\theta$.  In practice, we construct the
    892 following useful trigonometric relationships between $\phi$ and
    893 $\theta$ which may be employed in the equations of $x,y$ above:
     903projection spherical coordinate system coordinates ($\phi, \theta$).
     904In practice, we construct the following useful trigonometric
     905relationships between $\phi$ and $\theta$ which may be employed in the
     906equations of $x,y$ below:
    894907%
    895908\begin{eqnarray}
     
    907920\end{eqnarray}
    908921%
     922For zenithal projections, the linear coordinates are related to
     923$\phi,\theta$ by:
     924%
     925\begin{eqnarray}
     926x & = & R_\theta \sin \phi \\
     927y & = & -R_\theta \cos \phi
     928\end{eqnarray}
     929%
     930and the inverse:
     931%
     932\begin{eqnarray}
     933R_\theta & = & \sqrt{x^2 + y^2} \\
     934\phi     & = & {\rm arg} (-y,x)
     935\end{eqnarray}
     936%
     937The coordinates $x,y$ above are defined to be in angular units (ie,
     938radians). 
     939
    909940From these relationships, we can calculate $\alpha, \delta$ as:
    910941%
    911942\begin{eqnarray}
    912 \alpha - \alpha_p & = & arg (\sin \alpha, \cos \alpha) \\
    913 \delta            & = & arcsin (sin \delta) \\
    914 \end{eqnarray}
    915 %
    916 The necessary relationships for $\phi$ are equivalent for all zenithal projections:
    917 %
    918 \begin{eqnarray}
    919 R_\theta  & = & \sqrt{x^2 + y^2} \\
    920 \sin \phi & = & x / R_\theta \\
    921 \cos \phi & = & -y / R_\theta \\
     943\alpha - \alpha_p & = & \arctan (\sin \alpha, \cos \alpha) \\
     944\delta            & = & \arcsin (\sin \delta) \\
    922945\end{eqnarray}
    923946%
     
    933956x           & = & \frac{\cos \theta \sin \phi}{\sin \theta} \\
    934957y           & = & \frac{-\cos \theta \cos \phi}{\sin \theta} \\
    935 \sin \theta & = & \zeta / \sqrt (1 + \zeta^2) \\
    936 \cos \theta & = & 1 / \sqrt (1 + \zeta^2) \\
     958\sin \theta & = & \zeta / \sqrt{1 + \zeta^2} \\
     959\cos \theta & = & 1 / \sqrt{1 + \zeta^2} \\
    937960\end{eqnarray}
    938961
     
    958981coincident with the pole of the spherical coordinates.  These
    959982projections are particularly used for full-sky representations, and
    960 are only defined for projection centers with $\delta_c = 0$.  In this
     983are only defined for projection centers with $\delta_p = 0$.  In this
    961984spherical coordinate system, the coordinate of longitude is labeled
    962985$\phi$, and has domain of $-\pi < \phi \le \pi$, while the latitude,
    963986measured from the pole, is labeled $\theta$ and has domain $0 \le
    964 \theta \le \pi$.  The projection center longitude, $\alpha_c$
     987\theta \le \pi$.  The projection center longitude, $\alpha_p$
    965988corresponds to $\phi = 0$, thus the value of $\phi$ is determined as
    966 $\alpha - \alpha_c$ for all such projections.  The terms
    967 $\alpha_c,\delta_c$ are equivalent to the elements
    968 \code{psProjection.R} and \code{psProjection.D}.
     989$\alpha - \alpha_p$ for all such projections.
    969990
    970991\subparagraph{Cartesian}
    971992
    972 The Cartesian projection (``CAR'') is a very simple cylindrical with
    973 the following relationships between $x,y$ and $\phi,\theta$:
     993The Cartesian projection (``CAR'') is a very simple cylindrical
     994projection with the following relationships between $x,y$ and
     995$\phi,\theta$:
    974996
    975997\begin{eqnarray}
     
    9851007x & = & \phi \\
    9861008y & = & \ln \left( \tan (\pi/4 + \theta/2) \right) \\
    987 {\rm and}\hspace{1cm} \theta & = & 2 \arctan \left( e^y \right) - \pi/2^\circ
     1009{\rm and}\hspace{1cm} \theta & = & 2 \arctan \left( e^y \right) - \pi/2
    9881010\end{eqnarray}
    9891011
    9901012\subparagraph{Hammer-Aitoff}
    9911013
    992 The Hammer-Aitoff projection is a pseudocylindrical projection, and is defined:
    993 
    994 \begin{eqnarray}
    995 x & = & 2 \alpha \cos \theta \sin \frac{\phi}{2} \\
    996 y & = & \alpha \sin \theta \\
    997 {\rm where}\hspace{1cm} \alpha^{-1} & \equiv & \sqrt{\frac{1}{2}\left(1 + \cos \theta \cos \frac{\phi}{2} \right)}
     1014The Hammer-Aitoff projection(``AIT'') is a pseudocylindrical projection, and is defined:
     1015
     1016\begin{eqnarray}
     1017x & = & 2 \zeta \cos \theta \sin \frac{\phi}{2} \\
     1018y & = & \zeta \sin \theta \\
     1019{\rm where}\hspace{1cm} \zeta^{-1} & \equiv & \sqrt{\frac{1}{2}\left(1 + \cos \theta \cos \frac{\phi}{2} \right)}
    9981020\end{eqnarray}
    9991021
     
    10011023
    10021024\begin{eqnarray}
    1003 \phi & = & 2 {\rm arg} (2z^2 - 1, x z) \\
     1025\phi & = & 2 {\rm \arctan} (2z^2 - 1, x z) \\
    10041026\theta & = & \arcsin (yz) \\
    10051027{\rm where}\hspace{1cm} z & \equiv & \sqrt{1 - (x/2)^2 - y^2}
  • trunk/doc/pslib/psLibSDRS.tex

    r1539 r1554  
    1 %%% $Id: psLibSDRS.tex,v 1.72 2004-08-14 00:58:46 jhoblitt Exp $
     1%%% $Id: psLibSDRS.tex,v 1.73 2004-08-17 01:56:41 eugene Exp $
    22\documentclass[panstarrs,spec]{panstarrs}
    33
     
    30313031\subsubsection{Overview}
    30323032
    3033 We require a collection of functions to manipulate time data.  These operations
    3034 primarily consist of conversions between specific time formats.  Internally,
    3035 PSLib handles times as struct similar to the POSIX \code{struct timeval} which
    3036 has been extended to track the time system being represented.
    3037 
    3038 Conversion from one time system to another is achived by converting first to
    3039 TAI and then to the destination type.  This allows arbitarily many time system
    3040 to be supported by merely add functions to convert to and from TAI.
    3041 
    3042 \subsubsection{Generic Data Structures}
     3033We require a collection of functions to manipulate time data.  These
     3034operations primarily consist of conversions between specific time
     3035formats.  Internally, PSLib handles times as a structure similar to
     3036the POSIX \code{timeval} which has been extended to track the time
     3037system being represented. 
    30433038
    30443039\begin{verbatim}
     
    30463041    PS_TIME_TAI,                    ///< seconds since 1970-01-01T00:00:00Z (Gregorian)
    30473042    PS_TIME_UTC,                    ///< seconds since 1970-01-01T00:00:00Z (Gregorian)
    3048     PS_TIME_UT1,                    ///< seconds since 1970-01-01T00:00:00Z (Gregorian)
    3049     PS_TIME_LST,                    ///< seconds since 1970-01-01T00:00:00Z (Gregorian)
    30503043} psTimeType;
    30513044
    30523045typedef struct {
    30533046    psU64            sec;           ///< seconds
    3054     psU32            nsec;          ///< nanoseconds
     3047    psU32            usec;          ///< microseconds
    30553048    psTimeType       type;          ///< type of time
    30563049} psTime;
     
    30593052\subsubsection{Current Date and Time}
    30603053
    3061 A number of functions are provided to get the current time in a particular time
    3062 system.
    3063 
    3064 \begin{verbatim}
    3065 psTime *psGetTAI(void);
    3066 psTime *psGetUTC(void);
    3067 psTime *psGetUT1(void);
    3068 psTime *psGetLST(psF64 longitude);
    3069 psF64 *psGetJD(void);
    3070 psF64 *psGetMJD(void);
    3071 \end{verbatim}
    3072 
    3073 \subsubsection{Automatic Date and Time Type Conversion}
    3074 
    3075 When converting to a time system the source time system is automaticaly
    3076 converted to TAI and then from TAI to the destination type.
    3077 
    3078 \begin{verbatim}
    3079 bool psTimeToTAI(psTimeType type, psTime *time);
    3080 bool psTimeToUTC(psTimeType type, psTime *time);
    3081 bool psTimeToUT1(psTimeType type, psTime *time);
    3082 bool psTimeToLST(psTimeType type, psTime *time);
     3054Get the current time (in given system):
     3055
     3056\begin{verbatim}
     3057psTime *psTimeGetTime(psTimeType);
     3058\end{verbatim}
     3059
     3060\subsubsection{Time Conversion}
     3061
     3062Converting between the \code{psTime} time systems is done with:
     3063\begin{verbatim}
     3064psTime *psTimeConvert(psTime *time, psTimeType type);
     3065\end{verbatim}
     3066This function may be used to convert between \code{PS_TIME_TAI} and
     3067\code{PS_TIME_UTC} time representations. 
     3068
     3069To convert to or from Local Mean Sidereal Time, it is necessary to
     3070provide the local longitude as well:
     3071%
     3072\begin{verbatim}
     3073psTime *psTimeToLST(psTime *time, double longitude);
     3074psTime *psLSTToTime(psTime *time, double longitude);
     3075\end{verbatim}
     3076%
     3077The functions may accept either \code{psTimeType}.  Note that this
     3078function must supply the value UT1-UTC, which is available externally
     3079The value UT1-UTC is necessary for this an various other SLALIB
     3080functions.  The following utility function encapsulates the PSLib
     3081mechanism to extract the value of UT1-UTC:
     3082\begin{verbatim}
     3083double psGetUT1Delta(psTime *time);
     3084\end{verbatim}
     3085
     3086\subsubsection{External Date and Time Formats}
     3087
     3088A collection of functions convert from the \code{psTime} types to various
     3089external formats.  Note that ISO8601 format is "YYYY-MM-DDThh:mm:ss,sZ"
     3090
     3091\begin{verbatim}
    30833092psF64 psTimeToJD(psTime *time);
    30843093psF64 psTimeToMJD(psTime *time);
    3085 \end{verbatim}
    3086 
    3087 \subsubsection{Date and Time Formatting}
    3088 
    3089 A collection of functions convert from the \code{psTime} types to various
    3090 external formats.  Note that ISO8601 format is "YYYY-MM-DDThh:mm:ss,sZ"
    3091 
    3092 \begin{verbatim}
    3093 char *psFormatISO8601(psTime *time);
    3094 struct timeval *psFormatTimeval(psTime *time);
     3094char *psTimeToISOTime(psTime *time);
     3095struct timeval *psTimeToTimeval(psTime *time);
    30953096\end{verbatim}
    30963097
     
    31013102
    31023103\begin{verbatim}
    3103 psTime *psParseISO8601(psTimeType type, char *input);
    3104 psTime *psParseTimeval(psTimeType type, struct timeval *input);
    3105 \end{verbatim}
    3106 
    3107 \subsubsection{Date and Time System Support}
    3108 
    3109 All \code{psTime} types must be able to be converted to to the TAI type.
    3110 Conversion from one \code{psTime} type to another is achieved by first
    3111 converting to TAI and then to the target type.
    3112 
    3113 \begin{verbatim}
    3114 psTime *psTAIToUTC(psTime *time);
    3115 psTime *psUTCToTAI(psTime *time);
    3116 \end{verbatim}
    3117 
    3118 A utility function provides the current time from the system clock, in correct TAI units:
    3119 
    3120 \begin{verbatim}
    3121 psTime *psTAIToUT1(psTime *time);
    3122 psTime *psUT1ToTAI(psTime *time);
    3123 \end{verbatim}
    3124 
    3125 \begin{verbatim}
    3126 psTime *psTAIToLST(psTime *time, double longitude);
    3127 psTime *psLSTToTAI(psTime *time, double longitude);
    3128 \end{verbatim}
    3129 
    3130 \subsubsection{Utility Functions}
    3131 
    3132 A number of utility functions is needed for type conversion.
    3133 
    3134 \begin{verbatim}
    3135 psTime *psUT1ToGMST00(psTime *time);
    3136 psTime *psGMST00ToUT1(psTime *time);
    3137 \end{verbatim}
    3138 
    3139 \begin{verbatim}
    3140 psTime *psGMST00ToLST(psTime *time, double longitude);
    3141 psTime *psLSTToGMST00(psTime *time, double longitude);
    3142 \end{verbatim}
    3143 
    3144 Conversions to/from Julian Centuries.
    3145 
    3146 \begin{verbatim}
    3147 psF64 psJDToJC(psF64 time);
    3148 psF64 psJCToJD(psF64 time);
    3149 \end{verbatim}
    3150 
    3151 \begin{verbatim}
    3152 psF64 psMJDToJC(psF64 time);
    3153 psF64 psJCToMJD(psF64 time);
    3154 \end{verbatim}
    3155 
    3156 \begin{verbatim}
    3157 unsigned int psGetLeapSeconds(psTime *utc);
    3158 \end{verbatim}
    3159 
    3160 \begin{verbatim}
    3161 double psGetUT1Delta(psTime *tai);
     3104psTime *psJDToTime(psF64 input);
     3105psTime *psMJDToTime(psF64 input);
     3106psTime *psISOTimeToTime(char *input);
     3107psTime *psTimevalToTime(struct timeval *input);
    31623108\end{verbatim}
    31633109
     
    37103656    PS_PROJ_AIT,                        ///< Aitoff projection
    37113657    PS_PROJ_PAR,                        ///< Par projection
    3712     PS_PROJ_GLS,                        ///< GLS projection
    37133658    PS_PROJ_NTYPE                       ///< Number of types; must be last
    37143659} psProjectionType;
Note: See TracChangeset for help on using the changeset viewer.