Changeset 1614 for trunk/psLib/src/astro/psTime.h
- Timestamp:
- Aug 24, 2004, 3:37:45 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psTime.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psTime.h
r1529 r1614 1 2 1 /** @file psTime.h 3 2 * … … 7 6 * A collection of functions are required by psLib to manipulate time data. These functions primarily consist 8 7 * of conversions between specific time formats. PSLib currently uses the UNIX timeval time system as the 9 * base upon which International Atomic Time (TAI) time is calculated. All time conversion functions within 10 * psLib, except those noted, are calculated in terms of TAI time, which is approxinmately 32 seconds faster 11 * than UTC/timeval. 8 * base upon which International Atomic Time (TAI) and Universal Time Coordinated (UTC) are calculated. TAI 9 * time varies over time due to the earth's rotation and the movement of the continental plates. It is 10 * currentls 32 seconds faster than UTC/timeval time. The conversion between TAI and UTC time for other dates 11 * is given in the table below, which comes from: 12 * 13 * ftp://maia.usno.navy.mil/ser7/tai-utc.dat 14 * 15 * This table is placed into a static array and used by the psTime functions for conversions. 16 * 17 * 1961 JAN 1 =JD 2437300.5 TAI-UTC= 1.4228180 S + (MJD - 37300.) X 0.001296 S 18 * 1961 AUG 1 =JD 2437512.5 TAI-UTC= 1.3728180 S + (MJD - 37300.) X 0.001296 S 19 * 1962 JAN 1 =JD 2437665.5 TAI-UTC= 1.8458580 S + (MJD - 37665.) X 0.0011232S 20 * 1963 NOV 1 =JD 2438334.5 TAI-UTC= 1.9458580 S + (MJD - 37665.) X 0.0011232S 21 * 1964 JAN 1 =JD 2438395.5 TAI-UTC= 3.2401300 S + (MJD - 38761.) X 0.001296 S 22 * 1964 APR 1 =JD 2438486.5 TAI-UTC= 3.3401300 S + (MJD - 38761.) X 0.001296 S 23 * 1964 SEP 1 =JD 2438639.5 TAI-UTC= 3.4401300 S + (MJD - 38761.) X 0.001296 S 24 * 1965 JAN 1 =JD 2438761.5 TAI-UTC= 3.5401300 S + (MJD - 38761.) X 0.001296 S 25 * 1965 MAR 1 =JD 2438820.5 TAI-UTC= 3.6401300 S + (MJD - 38761.) X 0.001296 S 26 * 1965 JUL 1 =JD 2438942.5 TAI-UTC= 3.7401300 S + (MJD - 38761.) X 0.001296 S 27 * 1965 SEP 1 =JD 2439004.5 TAI-UTC= 3.8401300 S + (MJD - 38761.) X 0.001296 S 28 * 1966 JAN 1 =JD 2439126.5 TAI-UTC= 4.3131700 S + (MJD - 39126.) X 0.002592 S 29 * 1968 FEB 1 =JD 2439887.5 TAI-UTC= 4.2131700 S + (MJD - 39126.) X 0.002592 S 30 * 1972 JAN 1 =JD 2441317.5 TAI-UTC= 10.0 S + (MJD - 41317.) X 0.0 S 31 * 1972 JUL 1 =JD 2441499.5 TAI-UTC= 11.0 S + (MJD - 41317.) X 0.0 S 32 * 1973 JAN 1 =JD 2441683.5 TAI-UTC= 12.0 S + (MJD - 41317.) X 0.0 S 33 * 1974 JAN 1 =JD 2442048.5 TAI-UTC= 13.0 S + (MJD - 41317.) X 0.0 S 34 * 1975 JAN 1 =JD 2442413.5 TAI-UTC= 14.0 S + (MJD - 41317.) X 0.0 S 35 * 1976 JAN 1 =JD 2442778.5 TAI-UTC= 15.0 S + (MJD - 41317.) X 0.0 S 36 * 1977 JAN 1 =JD 2443144.5 TAI-UTC= 16.0 S + (MJD - 41317.) X 0.0 S 37 * 1978 JAN 1 =JD 2443509.5 TAI-UTC= 17.0 S + (MJD - 41317.) X 0.0 S 38 * 1979 JAN 1 =JD 2443874.5 TAI-UTC= 18.0 S + (MJD - 41317.) X 0.0 S 39 * 1980 JAN 1 =JD 2444239.5 TAI-UTC= 19.0 S + (MJD - 41317.) X 0.0 S 40 * 1981 JUL 1 =JD 2444786.5 TAI-UTC= 20.0 S + (MJD - 41317.) X 0.0 S 41 * 1982 JUL 1 =JD 2445151.5 TAI-UTC= 21.0 S + (MJD - 41317.) X 0.0 S 42 * 1983 JUL 1 =JD 2445516.5 TAI-UTC= 22.0 S + (MJD - 41317.) X 0.0 S 43 * 1985 JUL 1 =JD 2446247.5 TAI-UTC= 23.0 S + (MJD - 41317.) X 0.0 S 44 * 1988 JAN 1 =JD 2447161.5 TAI-UTC= 24.0 S + (MJD - 41317.) X 0.0 S 45 * 1990 JAN 1 =JD 2447892.5 TAI-UTC= 25.0 S + (MJD - 41317.) X 0.0 S 46 * 1991 JAN 1 =JD 2448257.5 TAI-UTC= 26.0 S + (MJD - 41317.) X 0.0 S 47 * 1992 JUL 1 =JD 2448804.5 TAI-UTC= 27.0 S + (MJD - 41317.) X 0.0 S 48 * 1993 JUL 1 =JD 2449169.5 TAI-UTC= 28.0 S + (MJD - 41317.) X 0.0 S 49 * 1994 JUL 1 =JD 2449534.5 TAI-UTC= 29.0 S + (MJD - 41317.) X 0.0 S 50 * 1996 JAN 1 =JD 2450083.5 TAI-UTC= 30.0 S + (MJD - 41317.) X 0.0 S 51 * 1997 JUL 1 =JD 2450630.5 TAI-UTC= 31.0 S + (MJD - 41317.) X 0.0 S 52 * 1999 JAN 1 =JD 2451179.5 TAI-UTC= 32.0 S + (MJD - 41317.) X 0.0 S 12 53 * 13 54 * @author Ross Harman, MHPCC 14 55 * 15 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $16 * @date $Date: 2004-08- 13 22:08:51$56 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 57 * @date $Date: 2004-08-25 01:37:45 $ 17 58 * 18 59 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 72 /// @{ 32 73 33 /******************************************************************************/ 34 35 /* TYPE DEFINITIONS */ 36 37 /******************************************************************************/ 74 75 /** Time type. 76 * 77 * Enumeration for psTime types, TAI or UTC time. 78 */ 79 typedef enum { 80 PS_TIME_TAI, ///< Temps Atomique International (TAI) time (time with leapseconds). 81 PS_TIME_UTC, ///< Universal Time Coordinated (UTC) time (time without leapseconds). 82 } psTimeType; 38 83 39 84 /** Definition of psTime. 40 85 * 41 * The psTime struct is used by psLib to represent time values critical to 42 * astronomical calculations. This structure represents a time which is 43 * equivalent to TAI (International Atomic Time) and is measured in both 86 * The psTime struct is used by psLib to represent time values critical to 87 * astronomical calculations. This structure represents a time which is 88 * equivalent to TAI (International Atomic Time) and is measured in both 44 89 * seconds and microseconds. 45 90 */ 46 typedef struct timeval psTime; 47 48 /*****************************************************************************/ 49 50 /* FUNCTION PROTOTYPES */ 51 52 /*****************************************************************************/ 53 54 /** Get current TAI time. 55 * 56 * Gets current time from the system clock in correct TAI units. 57 * 58 * @return psTime: Struct with current time. 59 */ 60 61 psTime psTimeGetTime(void); 62 63 /** Convert psTime to ISO time in TAI units. 64 * 65 * Converts psTime to a null terminated string in the form of: 66 * YYYY/MM/DD,HH:MM:SS.SSS. This function assumes the input time already is 67 * in TAI time and does not add or subtract leapseconds. 91 typedef struct psTime 92 { 93 psS64 sec; ///< Seconds since epoch, Jan 1, 1970. 94 psU32 usec; ///< Microseconds since last second. 95 psTimeType type; ///< Type of time. 96 } 97 psTime; 98 99 /** Get current time. 100 * 101 * Gets current time from the system clock. User must specify the psTimeType (PS_TIME_TAI or PS_TIME_UTC) in 102 * the argument. 103 * 104 * @return psTime*: Struct with current time. 105 */ 106 psTime* psTimeGetTime( 107 psTimeType type ///< Type of time to get (UTC or TAI). 108 ); 109 110 111 /** Convert psTime to UTC or TAI time. 112 * 113 * Converts psTime to UTC or TAI time based on the psTimeType argument. 114 * 115 * @return psTime*: Pointer to psTime. 116 */ 117 psTime* psTimeConvert( 118 psTime *time, 119 psTimeType type 120 ); 121 122 /** Convert psTime to Local Mean Sidereal Time (LST). 123 * 124 * Converts psTime at the given longitude to LST time. If the input time is not in UTC format, then it is 125 * converted. 126 * 127 * @return double: LST Time. 128 */ 129 double psTimeToLST( 130 psTime *time, ///< psTime to be converted. 131 double longitude ///< Longitude. 132 ); 133 134 /** Convert Local Mean Sidereal Time (LST) to psTime. 135 * 136 * Converts LST time to psTime. 137 * 138 * @return psTime*: Pointer to psTime. 139 */ 140 psTime* psLSTToTime( 141 double time, ///< LST time to be converted. 142 double longitude ///< Longitude. 143 ); 144 145 /** Determine UT1 - UTC from table lookup. 146 * 147 * This function is necessary to for various SLALIB functions. 148 * 149 * @return double: Time difference. 150 */ 151 double psGetUT1Delta( 152 psTime *time ///< psTime to be looked up. 153 ); 154 155 /** Determine TAI - UTC from table lookup. 156 * 157 * This function is necessary to for various psTime functions. 158 * 159 * @return double: Time difference. 160 */ 161 double psGetTAIDelta( 162 psTime *time ///< psTime to be looked up. 163 ); 164 165 /** Determine polar coordinates at a given time. 166 * 167 * Determines the orientation of the polar axis at the given time. 168 * 169 * @return psSphere*: Spherical coordinates of Earth's polar axias. 170 */ 171 /*psSphere* psGetPoleCoords( 172 psTime *time ///< psTime determine polar orientation. 173 );*/ 174 175 /** Convert psTime to Julian date time. 176 * 177 * Converts psTime to Julian date (JD) time. This function does not add or subtract leapseconds. 178 * 179 * @return double: Julian Date (JD) time. 180 */ 181 double psTimeToJD( 182 psTime *time ///< Input time to be converted. 183 ); 184 /** Convert psTime to modified Julian date time. 185 * 186 * Converts psTime to modified Julian date (MJD) time. This function does not add or subtract leapseconds. 187 * 188 * @return double: Modified Julian Days (MJD) time. 189 */ 190 double psTimeToMJD( 191 psTime *time ///< Input time to be converted. 192 ); 193 194 /** Convert psTime to ISO8601 formatted string. 195 * 196 * Converts psTime to a null terminated string in the form of YYYY-MM-DDThh:mm:ss.sss. This function does not 197 * add or subtract leapseconds. 68 198 * 69 199 * @return char*: Pointer null terminated array of chars in ISO time. 70 200 */ 71 72 char *psTimeToISO( 73 psTime time ///< Input time to be converted. 74 ); 75 76 /** Convert psTime to UTC time. 77 * 78 * Converts psTime to UTC time in double precision floating point notation. 79 * The input to this must already be int TAI time. The result from this 80 * function is not in TAI units, but that of UTC, which does not contain 81 * leapseconds. 82 * 83 * @return psTime: UTC time psTime format. 84 */ 85 86 psTime psTimeToUTC( 87 psTime time ///< Input time to be converted. 88 ); 89 90 /** Convert psTime to modified Julian date time. 91 * 92 * Converts psTime to modified Julian date (MJD) time. This function assumes 93 * the input time already is in TAI time and does not add or subtract 94 * leapseconds. 95 * 96 * @return double: Modified Julian Days (MJD) time. 97 */ 98 double psTimeToMJD( 99 psTime time ///< Input time to be converted. 100 ); 101 102 /** Convert psTime to Julian date time. 103 * 104 * Converts psTime to Julian date (JD) time. This function assumes the input 105 * time already is in TAI time and does not add or subtract leapseconds. 106 * 107 * @return double: Julian Date (JD) time. 108 */ 109 double psTimeToJD( 110 psTime time ///< Input time to be converted. 201 char* psTimeToISO( 202 psTime *time ///< Input time to be converted. 111 203 ); 112 204 113 205 /** Convert psTime to timeval time. 114 206 * 115 * Converts psTime to timeval time. This function assumes the input time 116 * already is in TAI time and does not add or subtract leapseconds. 207 * Converts psTime to timeval time. This function does not add or subtract leapseconds. 117 208 * 118 209 * @return timeval: timeval struct time. 119 210 */ 120 211 struct timeval psTimeToTimeval( 121 psTime time ///< Input time to be converted.212 psTime *time ///< Input time to be converted. 122 213 ); 123 214 124 215 /** Convert psTime to tm time. 125 216 * 126 * Converts psTime to tm time. This function assumes the input time already is in TAI time and does not add or 127 * subtract leapseconds. 217 * Converts psTime to tm time. This function does not add or subtract leapseconds. 128 218 * 129 219 * @return tm: tm struct time. 130 220 */ 131 struct tm *psTimeToTM(132 psTime time ///< Input time to be converted.221 struct tm* psTimeToTM( 222 psTime *time ///< Input time to be converted. 133 223 ); 134 224 225 /** Convert JD to psTime. 226 * 227 * Converts JD time to psTime. This function does not add or subtract leapseconds. 228 * 229 * @return psTime: time. 230 */ 231 psTime* psJDToTime( 232 double time ///< Input time to be converted. 233 ); 234 235 /** Convert MJD to psTime. 236 * 237 * Converts MJD time to psTime. This function does not add or subtract leapseconds. 238 * 239 * @return psTime: time. 240 */ 241 psTime* psMJDToTime( 242 double time ///< Input time to be converted. 243 ); 244 135 245 /** Convert ISO to psTime. 136 246 * 137 * Converts ISO time to psTime. This function assumes the input time already 138 * is in TAI time and does not add or subtract leapseconds. 139 * 140 * @return psTime: time 141 */ 142 psTime psISOToTime( 247 * Converts ISO time to psTime. This function does not add or subtract leapseconds. 248 * 249 * @return psTime*: time 250 */ 251 psTime* psISOToTime( 143 252 char *time ///< Input time to be converted. 144 253 ); 145 254 146 /** Convert UTC to psTime.147 *148 * Converts UTC time to psTime. This function assumes the input time already149 * is in TAI time and add or subtracts the necessary leapseconds.150 *151 * @return psTime: time in TAI units.152 */153 psTime psUTCToTime(154 psTime time ///< Input time to be converted.155 );156 157 /** Convert MJD to psTime.158 *159 * Converts MJD time to psTime. This function assumes the input time already160 * is in TAI time and does not add or subtract leapseconds.161 *162 * @return psTime: time.163 */164 psTime psMJDToTime(165 double time ///< Input time to be converted.166 );167 168 /** Convert JD to psTime.169 *170 * Converts JD time to psTime. This function assumes the input time already171 * is in TAI time and does not add or subtract leapseconds.172 *173 * @return psTime: time.174 */175 psTime psJDToTime(176 double time ///< Input time to be converted.177 );178 179 255 /** Convert timeval to psTime. 180 256 * 181 * Converts timeval time to psTime. This function assumes the input time 182 * already is in TAI time and does not add or subtract leapseconds. 183 * 184 * @return psTime: time. 185 */ 186 psTime psTimevalToTime( 187 struct timeval *time ///< Input time to be converted. 257 * Converts timeval time to psTime. This function does not add or subtract leapseconds. 258 * 259 * @return psTime*: time. 260 */ 261 psTime* psTimevalToTime( 262 struct timeval *time ///< Input time to be converted. 188 263 ); 189 264 190 265 /** Convert tm time to psTime. 191 266 * 192 * Converts tm time to psTime. This function assumes the input time already 193 * is in TAI time and does not add or subtract leapseconds. 194 * 195 * @return psTime: time. 196 */ 197 psTime psTMToTime( 267 * Converts tm time to psTime. This function does not add or subtract leapseconds. 268 * 269 * @return psTime*: time. 270 */ 271 psTime* psTMToTime( 198 272 struct tm *time ///< Input time to be converted. 199 273 ); 200 274 275 /** Add two TAI times. 276 * 277 * Adds two TAI times. This function does not add or subtract leapseconds. 278 * 279 * @return psTime*: time. 280 */ 281 psTime* psTAIAdd( 282 psTime *tai1, ///< First TAI time. 283 psTime *tai2 ///< Second TAI time. 284 ); 285 286 /** Subtract two TAI times. 287 * 288 * Subtracts two TAI times. This function does not add or subtract leapseconds. 289 * 290 * @return psTime*: time. 291 */ 292 psTime* psTAISub( 293 psTime *tai1, ///< First TAI time. 294 psTime *tai2 ///< Second TAI time. 295 ); 296 297 298 /** Find delta of two TAI times. 299 * 300 * Finds the absolute difference of two TAI times. This function does not add or subtract leapseconds. 301 * 302 * @return psTime*: time. 303 */ 304 psTime* psTAIDelta( 305 psTime *tai1, ///< First TAI time. 306 psTime *tai2 ///< Second TAI time. 307 ); 201 308 /// @} 202 309
Note:
See TracChangeset
for help on using the changeset viewer.
