Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psTime.h

Go to the documentation of this file.
00001 /** @file  psTime.h
00002  *
00003  *  @brief Definitions for time, time utilities, and conversion functions for use with psLib astronomy
00004  *  functions.
00005  *
00006  *  A collection of functions are required by psLib to manipulate time data. These functions primarily consist
00007  *  of conversions between specific time formats.  They use the UNIX timeval time system as the
00008  *  base upon which International Atomic Time (TAI) and Universal Time Coordinated (UTC) are calculated.
00009  *
00010  *  @author Ross Harman, MHPCC
00011  *
00012  *  @version $Revision: 1.22 $ $Name: rel5_0 $
00013  *  @date $Date: 2005/02/17 19:26:23 $
00014  *
00015  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00016  */
00017 
00018 
00019 #ifndef PSTIME_H
00020 #define PSTIME_H
00021 
00022 #include <time.h>
00023 #include <sys/types.h>
00024 #include <sys/time.h>
00025 
00026 #include "psType.h"
00027 #include "psImage.h"
00028 
00029 struct psSphere;
00030 
00031 /// @addtogroup Time
00032 /// @{
00033 
00034 
00035 /** Time type.
00036  *
00037  * Enumeration for psTime types, TAI or UTC time.
00038  */
00039 typedef enum {
00040     PS_TIME_TAI,        ///< Temps Atomique International (TAI) time (time with leapseconds).
00041     PS_TIME_UTC,        ///< Universal Time Coordinated (UTC) time (time without leapseconds).
00042 } psTimeType;
00043 
00044 /** Definition of psTime.
00045  *
00046  *  The psTime struct is used by psLib to represent time values critical to
00047  *  astronomical calculations.  This structure represents a time which is
00048  *  equivalent to TAI (International Atomic Time) and is measured in both
00049  *  seconds and microseconds.
00050  */
00051 typedef struct psTime
00052 {
00053     psS64 sec;          ///< Seconds since epoch, Jan 1, 1970.
00054     psU32 usec;         ///< Microseconds since last second.
00055     psTimeType type;    ///< Type of time.
00056 }
00057 psTime;
00058 
00059 
00060 /** Initialize time data.
00061  *
00062  * Reads config and data files associated with various time conversions.
00063  *
00064  * @return  bool: True for success, false for failure.
00065  */
00066 psBool p_psTimeInit(const char *fileName);
00067 
00068 /** Free memory persistant time data.
00069  *
00070  * Frees time data to be held in memory until the end of successful program execution.
00071  *
00072  * @return  void: void.
00073  */
00074 psBool p_psTimeFinalize(void);
00075 
00076 /** Allocate time struct.
00077  *
00078  * Allocates an empty time struct. User must specify the psTimeType (PS_TIME_TAI or PS_TIME_UTC) in the argument.
00079  * The seconds and microseconds members of the struct are set to zero.
00080  *
00081  * @return  psTime*: Struct with empty time.
00082  */
00083 psTime* psTimeAlloc(
00084     psTimeType type                     ///< Type of time to create (UTC or TAI).
00085 );
00086 
00087 /** Get current time.
00088  *
00089  * Gets current time from the system clock. User must specify the psTimeType (PS_TIME_TAI or PS_TIME_UTC) in
00090  * the argument.
00091  *
00092  *  @return  psTime*: Struct with current time.
00093  */
00094 psTime* psTimeGetTime(
00095     psTimeType type                     ///< Type of time to get (UTC or TAI).
00096 );
00097 
00098 /** Convert psTime to UTC or TAI time.
00099  *
00100  *  Converts psTime to UTC or TAI time based on the psTimeType argument.
00101  *
00102  *  @return  psTime*: Pointer to psTime.
00103  */
00104 psTime* psTimeConvert(
00105     psTime *time,                       ///< Time to be converted.
00106     psTimeType type                     ///< Type to be converted to.
00107 );
00108 
00109 /** Convert psTime to Local Mean Sidereal Time (LST).
00110  *
00111  *  Converts psTime at the given longitude to LST time. If the input time is not in UTC format, then it is
00112  *  converted.
00113  *
00114  *  @return  double: LST Time.
00115  */
00116 double psTimeToLST(
00117     psTime *time,                       ///< psTime to be converted.
00118     double longitude                    ///< Longitude.
00119 );
00120 
00121 /** Determine UT1 - UTC from table lookup.
00122  *
00123  *  This function is necessary to for various SLALIB functions.
00124  *
00125  *  @return  double: Time difference.
00126  */
00127 double psTimeGetUT1Delta(
00128     const psTime *time                  ///< psTime to be looked up.
00129 );
00130 
00131 /** Determine TAI - UTC from table lookup.
00132  *
00133  *  This function is necessary to for various psTime functions.
00134  *
00135  *  @return  double: Time difference.
00136  */
00137 double psTimeGetTAIDelta(
00138     const psTime *time                  ///< psTime to be looked up.
00139 );
00140 
00141 /** Determine polar coordinates at a given time.
00142  *
00143  *  Determines the orientation of the polar axis at the given time.
00144  *
00145  *  @return  psSphere*: Spherical coordinates of Earth's polar axias.
00146  */
00147 struct psSphere* psTimeGetPoleCoords(
00148                 const psTime *time                  ///< psTime determine polar orientation.
00149             );
00150 
00151 /** Calculate the number of leapseconds between two times.
00152  *
00153  *  Calculates the number of leapseconds between two times.
00154  *
00155  *  @return  psS64: leapseconds added between given times
00156  */
00157 psS64 psTimeLeapseconds(
00158     const psTime* time1,                ///< First input time.
00159     const psTime* time2                 ///< Second input time.
00160 );
00161 
00162 /** Convert psTime to Julian date time.
00163  *
00164  *  Converts psTime to Julian date (JD) time. This function does not add or subtract leapseconds.
00165  *
00166  *  @return  double: Julian Date (JD) time.
00167  */
00168 double psTimeToJD(
00169     const psTime* time                  ///< Input time to be converted.
00170 );
00171 /** Convert psTime to modified Julian date time.
00172  *
00173  *  Converts psTime to modified Julian date (MJD) time. This function does not add or subtract leapseconds.
00174  *
00175  *  @return  double: Modified Julian Days (MJD) time.
00176  */
00177 double psTimeToMJD(
00178     const psTime* time                  ///< Input time to be converted.
00179 );
00180 
00181 /** Convert psTime to ISO8601 formatted string.
00182  *
00183  *  Converts psTime to a null terminated string in the form of YYYY-MM-DDThh:mm:ss.sss. This function does not
00184  *  add or subtract leapseconds.
00185  *
00186  *  @return  char*: Pointer null terminated array of chars in ISO time.
00187  */
00188 char* psTimeToISOTime(
00189     const psTime* time                  ///< Input time to be converted.
00190 );
00191 
00192 /** Convert psTime to timeval time.
00193  *
00194  *  Converts psTime to timeval time. This function does not add or subtract leapseconds.
00195  *
00196  *  @return  timeval: timeval struct time.
00197  */
00198 struct timeval psTimeToTimeval(
00199                 const psTime* time                  ///< Input time to be converted.
00200             );
00201 
00202 /** Convert psTime to tm time.
00203  *
00204  * Converts psTime to tm time. This function is based on a Perl algorithm availble in the Pan-STARRS Image
00205  * processing Algorithm Design Description (ADD). This function does not add or subtract leapseconds.
00206  *
00207  *  @return  tm: tm struct time.
00208  */
00209 struct tm* psTimeToTM(
00210                 const psTime *time                  ///< Input time to be converted.
00211             );
00212 
00213 /** Convert JD to psTime.
00214  *
00215  *  Converts JD time to psTime. This function does not add or subtract leapseconds.
00216  *
00217  *  @return  psTime: time.
00218  */
00219 psTime* psTimeFromJD(
00220     double time                         ///< Input time to be converted.
00221 );
00222 
00223 /** Convert MJD to psTime.
00224  *
00225  *  Converts MJD time to psTime. This function does not add or subtract leapseconds.
00226  *
00227  *  @return  psTime: time.
00228  */
00229 psTime* psTimeFromMJD(
00230     double time                         ///< Input time to be converted.
00231 );
00232 
00233 /** Convert ISO to psTime.
00234  *
00235  *  Converts ISO time to psTime. This function does not add or subtract leapseconds.
00236  *
00237  *  @return  psTime*: time
00238  */
00239 psTime* psTimeFromISOTime(
00240     const char* time                    ///< Input time to be converted.
00241 );
00242 
00243 /** Convert timeval to psTime.
00244  *
00245  *  Converts timeval time to psTime. This function does not add or subtract leapseconds.
00246  *
00247  *  @return  psTime*: time.
00248  */
00249 psTime* psTimeFromTimeval(
00250     const struct timeval *time          ///< Input time to be converted.
00251 );
00252 
00253 /** Convert tm time to psTime.
00254  *
00255  *  Converts tm time to psTime. This function is based on a Perl algorithm availble in the Pan-STARRS Image
00256  * processing Algorithm Design Description (ADD). This function does not add or subtract leapseconds.
00257  *
00258  *  @return  psTime*: time.
00259  */
00260 psTime* psTimeFromTM(
00261     const struct tm *time               ///< Input time to be converted.
00262 );
00263 
00264 /** Adds delta to time. Result is in TAI time.
00265  *
00266  *  Adds delta to time. Input time is converted to TAI format if necessary.
00267  *
00268  *  @return  psTime*: time.
00269  */
00270 psTime* psTimeMath(
00271     const psTime *time,                 ///< Time.
00272     psF64 delta                         ///< Time delta.
00273 );
00274 
00275 /** Determine difference between two times. Result is in TAI time.
00276  *
00277  *  Determine difference between two times. Input times are converted to TAI format if necessary.
00278  *
00279  *  @return psF64: Time difference.
00280  */
00281 psF64 psTimeDelta(
00282     const psTime *time1,                ///< First time.
00283     const psTime *time2                 ///< Second time.
00284 );
00285 
00286 /** Get the filename of the psLib configuration file.
00287  *
00288  *  @return char*          If a PS_CONFIG_FILE environment variable exists,
00289  *                         that is returned, otherwise the default location
00290  *                         dependent on the installation location.
00291  */
00292 char* p_psGetConfigFileName();
00293 
00294 /// @}
00295 
00296 #endif

Generated on Mon Apr 4 18:24:45 2005 for Pan-STARRS Foundation Library by  doxygen 1.3.9.1