Changeset 2048
- Timestamp:
- Oct 11, 2004, 3:34:09 PM (22 years ago)
- Location:
- trunk/psLib
- Files:
-
- 11 edited
-
src/astro/psCoord.h (modified) (2 diffs)
-
src/astro/psTime.c (modified) (41 diffs)
-
src/astro/psTime.h (modified) (19 diffs)
-
src/astronomy/psAstrometry.c (modified) (3 diffs)
-
src/astronomy/psAstrometry.h (modified) (3 diffs)
-
src/astronomy/psCoord.h (modified) (2 diffs)
-
src/astronomy/psTime.c (modified) (41 diffs)
-
src/astronomy/psTime.h (modified) (19 diffs)
-
test/astronomy/tst_psAstrometry.c (modified) (5 diffs)
-
test/astronomy/tst_psTime_01.c (modified) (8 diffs)
-
test/astronomy/tst_psTime_02.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psCoord.h
r1496 r2048 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2004- 08-12 01:23:20$13 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-12 01:34:09 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 53 53 * 54 54 */ 55 typedef struct 55 typedef struct psSphere 56 56 { 57 57 double r; ///< RA -
trunk/psLib/src/astro/psTime.c
r2032 r2048 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 0$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-10- 09 00:17:14$13 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-12 01:34:09 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 27 #include "psAbort.h" 28 28 #include "psImage.h" 29 #include "psCoord.h" 29 30 30 31 #include "psAstronomyErrors.h" 32 33 #ifndef SER7_FILE 34 #define SER7_FILE "../../data/ser7.dat" 35 #endif 36 37 #ifndef TAIUTC_FILE 38 #define TAIUTC_FILE "../../data/tai-utc.dat" 39 #endif 31 40 32 41 /** Sidereal angular conversion from seconds to radians for GMST in seconds (i.e. pi/(180*240)) */ … … 61 70 62 71 /** Preprocessor macro to check for null psTime struct */ 63 #define CHECK_NULL_TIME(TIME,RETURN) \64 if(TIME == NULL) { \65 psError(__func__,"NULL value not allowed"); \66 return RETURN; \72 #define CHECK_NULL_TIME(TIME,RETURN) \ 73 if(TIME == NULL) { \ 74 psError(__func__,"NULL value not allowed"); \ 75 return RETURN; \ 67 76 } 68 77 69 78 /** Preprocessor macro to allocate psTime struct */ 70 #define ALLOC_TIME(TIME) \71 TIME = (psTime*)psAlloc(sizeof(psTime)); \72 if (TIME == NULL) { \73 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__); \74 } \75 TIME->sec = 0; \76 TIME->usec = 0; \79 #define ALLOC_TIME(TIME) \ 80 TIME = (psTime*)psAlloc(sizeof(psTime)); \ 81 if (TIME == NULL) { \ 82 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__); \ 83 } \ 84 TIME->sec = 0; \ 85 TIME->usec = 0; \ 77 86 TIME->type = PS_TIME_TAI; 78 87 79 80 psImage* readTaiUtcFile(char *fileName) 88 /** Read TAI/UTC data file. 89 * 90 * Reads TAI/UTC data file. 91 * 92 * @return psImage*: Two-dimensional array with table data. 93 */ 94 static psImage* readTaiUtcFile( 95 const char *fileName ///< Name of file to read. 96 ); 97 98 99 /** Read SER7 data file. 100 * 101 * Reads SER7 data file. 102 * 103 * @return psImage*: Two-dimensional array with table data. 104 */ 105 static psImage* readSer7File( 106 const char *fileName ///< Name of file to read. 107 ); 108 109 110 /** Read finals data file. 111 * 112 * Reads finals data file. 113 * 114 * @return psImage*: Two-dimensional array with table data. 115 */ 116 /* not yet used 117 static psImage* readFinalsFile( 118 char *fileName ///< Name of file to read. 119 ); 120 */ 121 122 /** Read EOPC data file. 123 * 124 * Reads EOPC data file. 125 * 126 * @return psImage*: Two-dimensional array with table data. 127 */ 128 /* not yet used 129 static psImage* readEopcFile( 130 char *fileName ///< Name of file to read. 131 ); 132 */ 133 134 /** Lookup and interpolate TAI-UTC data 135 * 136 * Interpolates TAI-UTC data, given time in MJD format. 137 * 138 * @return double: Interpolated value. 139 */ 140 static double lookupTaiUtcTable( 141 const psTime *time ///< time to lookup. 142 ); 143 144 /** Lookup and interpolate polar or UT1-UTC data 145 * 146 * Interpolates TAI-UT1 or polar coordinate data, given time in MJD format. 147 * 148 * @return double: Interpolated value. 149 */ 150 static double lookupSer7Table( 151 const psTime *time, ///< time to lookup. 152 int col ///< Column to lookup. 153 ); 154 155 static psImage* readTaiUtcFile(const char *fileName) 81 156 { 82 157 char line[LINESIZE]; … … 113 188 *(unsigned int *)&table->numRows = j; 114 189 190 p_psMemSetPersistent(table,true); 191 p_psMemSetPersistent(table->data.V,true); 192 p_psMemSetPersistent(table->rawDataBuffer,true); 193 115 194 return table; 116 195 } 117 196 118 psImage* readSer7File(char *fileName)197 static psImage* readSer7File(const char *fileName) 119 198 { 120 199 bool beginRecord = false; … … 160 239 *(unsigned int *)&table->numRows = j; 161 240 241 p_psMemSetPersistent(table,true); 242 p_psMemSetPersistent(table->data.V,true); 243 p_psMemSetPersistent(table->rawDataBuffer,true); 244 162 245 return table; 163 246 } 164 247 165 psImage* readEopcFile(char *fileName) 248 /* Not yet used... 249 static psImage* readEopcFile(char *fileName) 166 250 { 167 251 char line[LINESIZE]; … … 171 255 psImage *table = NULL; 172 256 FILE *fd = NULL; 173 174 257 258 175 259 fd=fopen(fileName, "r"); 176 260 if(fd==NULL) { … … 178 262 return NULL ; 179 263 } 180 264 181 265 // Table shouldn't be larger than 2500 rows. All columns are read. 182 266 table = psImageAlloc(11, maxLines, PS_TYPE_F64); … … 186 270 } 187 271 } 188 272 189 273 while(fgets(line, LINESIZE, fd) != NULL) { 190 274 if(j>=maxLines) { … … 197 281 ptr, ptr+1, ptr+2, ptr+3, ptr+4, ptr+5, ptr+6, ptr+7, ptr+8, ptr+9, ptr+10); 198 282 } 199 283 200 284 *(unsigned int *)&table->numRows = j; 201 285 202 286 return table; 203 287 } 204 205 psImage* readFinalsFile(char *fileName)288 289 static psImage* readFinalsFile(char *fileName) 206 290 { 207 291 char line[LINESIZE]; … … 210 294 psImage *table = NULL; 211 295 FILE *fd = NULL; 212 213 296 297 214 298 fd=fopen(fileName, "r"); 215 299 if(fd==NULL) { … … 217 301 return NULL ; 218 302 } 219 303 220 304 // Table shouldn't be larger than 15000 rows. Select columns are read. 221 305 table = psImageAlloc(6, maxLines, PS_TYPE_F64); … … 226 310 psFree(table); 227 311 } 228 312 229 313 psF64 *ptr = table->data.F64[j++]; 230 314 ptr = table->data.F64[j++]; 231 315 232 316 // Sometimes there are blank entries in this table, so check for a space to determine if there is no entry 233 317 if(*(line+7) == ' ') { // MJD … … 236 320 *ptr = atof(line+7); 237 321 } 238 322 239 323 if(*(line+18) == ' ') { // Polar motion X 240 324 *(ptr+1) = 0.0; … … 242 326 *(ptr+1) = atof(line+18); 243 327 } 244 328 245 329 if(*(line+27) == ' ') { // Polar motion X error 246 330 *(ptr+2) = 0.0; … … 248 332 *(ptr+2) = atof(line+27); 249 333 } 250 334 251 335 if(*(line+37) == ' ') { // Polar motion Y 252 336 *(ptr+3) = 0.0; … … 254 338 *(ptr+3) = atof(line+37); 255 339 } 256 340 257 341 if(*(line+46) == ' ') { // Polar motion Y error 258 342 *(ptr+4) = 0.0; … … 260 344 *(ptr+4) = atof(line+46); 261 345 } 262 346 263 347 if(*(line+58) == ' ') { // UT1-UTC 264 348 *(ptr+5) = 0.0; … … 267 351 } 268 352 } 269 353 270 354 *(unsigned int *)&table->numRows = j; 271 355 272 356 return table; 273 357 } 274 275 276 double lookupTaiUtcTable(psImage *table,psTime *time)358 */ 359 360 static double lookupTaiUtcTable(const psTime *time) 277 361 { 278 362 int hiIdx = 0; … … 286 370 double const2 = 0.0; 287 371 double const3 = 0.0; 288 372 static psImage* table = NULL; 373 374 if (table == NULL) { 375 table = readTaiUtcFile(TAIUTC_FILE); 376 if (table == NULL) { 377 psAbort(__func__,"Failed to read tai-utc.dat file"); 378 } 379 } 289 380 290 381 // Number of rows is the number of rows of data read from the data file … … 337 428 } 338 429 339 double lookupSer7Table(psImage *table,psTime *time, int col)430 static double lookupSer7Table(const psTime *time, int col) 340 431 { 341 432 int hiIdx = 0; … … 345 436 double denom = 0.0; 346 437 double mjdUtc = 0.0; 347 438 static psImage* table = NULL; 439 440 if (table == NULL) { 441 table = readSer7File(SER7_FILE); 442 if (table == NULL) { 443 psAbort(__func__,"Failed to read the ser7.dat file."); 444 } 445 } 348 446 349 447 // Number of rows is the number of rows of data read from the data file … … 404 502 // Add most leapseconds to UTC time to get TAI time if necessary 405 503 if(type == PS_TIME_TAI) { 406 time->sec += ps GetTAIDelta(time);504 time->sec += psTimeGetTAIDelta(time); 407 505 } 408 506 … … 420 518 } 421 519 422 delta = ps GetTAIDelta(time);520 delta = psTimeGetTAIDelta(time); 423 521 424 522 if(type == PS_TIME_UTC) { … … 461 559 taiTime = psMemIncrRefCounter(time); 462 560 ALLOC_TIME(utcTime); 463 utcTime->sec = taiTime->sec - ps GetTAIDelta(time);561 utcTime->sec = taiTime->sec - psTimeGetTAIDelta(time); 464 562 utcTime->usec = taiTime->usec; 465 563 utcTime->type = PS_TIME_UTC; … … 467 565 utcTime = psMemIncrRefCounter(time); 468 566 ALLOC_TIME(taiTime); 469 taiTime->sec = utcTime->sec + ps GetTAIDelta(time);567 taiTime->sec = utcTime->sec + psTimeGetTAIDelta(time); 470 568 taiTime->usec = utcTime->usec; 471 569 taiTime->type = PS_TIME_TAI; … … 475 573 ALLOC_TIME(ut1UtcDelta); 476 574 ut1UtcDelta->type = PS_TIME_UTC; 477 ut1UtcDelta->usec = ps GetUT1Delta(utcTime)*1e6;575 ut1UtcDelta->usec = psTimeGetUT1Delta(utcTime)*1e6; 478 576 ut1Time = psTimeAdd(utcTime, ut1UtcDelta); 479 577 … … 516 614 } 517 615 518 double psGetUT1Delta(psTime *time) 519 { 520 static psImage* iersTable = NULL; 521 double ut1UtcDeltaUsec = 0.0; 522 523 524 if (iersTable == NULL) { 525 iersTable = readSer7File("../../data/ser7.dat"); 526 p_psMemSetPersistent(iersTable,true); 527 p_psMemSetPersistent(iersTable->data.V,true); 528 p_psMemSetPersistent(iersTable->rawDataBuffer,true); 529 } 530 531 ut1UtcDeltaUsec = lookupSer7Table(iersTable, time, 6)*1.0e6; 532 533 return ut1UtcDeltaUsec; 534 } 535 536 double psGetTAIDelta(psTime *time) 537 { 538 double delta = 0.0; 539 static psImage* taiUtcTable = NULL; 540 541 542 if (taiUtcTable == NULL) { 543 taiUtcTable = readTaiUtcFile("../../data/tai-utc.dat"); 544 p_psMemSetPersistent(taiUtcTable,true); 545 p_psMemSetPersistent(taiUtcTable->data.V,true); 546 p_psMemSetPersistent(taiUtcTable->rawDataBuffer,true); 547 } 548 delta = lookupTaiUtcTable(taiUtcTable, time); 549 550 return delta; 551 } 552 553 psF64 psTimeLeapseconds(const psTime *time1, const psTime *time2) 554 { 555 psF64 diff = 0.0; 616 double psTimeGetUT1Delta(const psTime *time) 617 { 618 return lookupSer7Table(time, 6); 619 } 620 621 struct psSphere* psTimeGetPoleCoords(const psTime* time) 622 { 623 624 double x = lookupSer7Table((psTime*)time, 4); 625 double y = lookupSer7Table((psTime*)time, 5); 626 627 struct psSphere* output = psAlloc(sizeof(psSphere)); 628 output->r = x * M_PI / 648000.0; // x in arcsec converted to radians, i.e., x/60/60*M_PI/180 629 output->d = y * M_PI / 648000.0; 630 631 return output; 632 } 633 634 double psTimeGetTAIDelta(const psTime *time) 635 { 636 return lookupTaiUtcTable(time); 637 } 638 639 long psTimeLeapseconds(const psTime *time1, const psTime *time2) 640 { 641 long diff = 0; 556 642 557 643 // NULL error checks … … 559 645 CHECK_NULL_TIME(time2,0); 560 646 561 diff = fabs(psGetTAIDelta((psTime*)time1)-psGetTAIDelta((psTime*)time2));647 diff = abs(psTimeGetTAIDelta((psTime*)time1)-psTimeGetTAIDelta((psTime*)time2)); 562 648 563 649 return diff; 564 650 } 565 651 566 double psTimeToJD( psTime *time)652 double psTimeToJD(const psTime *time) 567 653 { 568 654 double jd = 0.0; … … 582 668 } 583 669 584 double psTimeToMJD( psTime *time)670 double psTimeToMJD(const psTime *time) 585 671 { 586 672 double mjd = 0.0; … … 600 686 } 601 687 602 char* psTimeToISO (psTime *time)688 char* psTimeToISOTime(const psTime *time) 603 689 { 604 690 int ms = 0; … … 634 720 } 635 721 636 struct timeval psTimeToTimeval( psTime *time)722 struct timeval psTimeToTimeval(const psTime *time) 637 723 { 638 724 struct timeval timevalTime; … … 648 734 } 649 735 650 struct tm* psTimeToTM( psTime *time)736 struct tm* psTimeToTM(const psTime *time) 651 737 { 652 738 long cent = 0; … … 711 797 } 712 798 713 psTime* ps JDToTime(double time)799 psTime* psTimeFromJD(double time) 714 800 { 715 801 double days = 0.0; … … 734 820 } 735 821 736 psTime* ps MJDToTime(double time)822 psTime* psTimeFromMJD(double time) 737 823 { 738 824 double days = 0.0; … … 757 843 } 758 844 759 psTime* ps ISOToTime(char *time)845 psTime* psTimeFromISOTime(const char *time) 760 846 { 761 847 char tempString[MAX_TIME_STRING_LENGTH]; … … 826 912 827 913 // Convert tm time to psTime 828 outTime = psT MToTime(&tmTime);914 outTime = psTimeFromTM(&tmTime); 829 915 outTime->usec = millisecond * 1000; 830 916 … … 832 918 } 833 919 834 psTime* psTime valToTime(struct timeval *time)920 psTime* psTimeFromTimeval(const struct timeval *time) 835 921 { 836 922 psTime *outTime = NULL; … … 850 936 } 851 937 852 psTime* psT MToTime(struct tm* time)938 psTime* psTimeFromTM(const struct tm* time) 853 939 { 854 940 long year; … … 905 991 } 906 992 907 psTime* psTimeAdd( psTime *tai1,psTime *tai2)993 psTime* psTimeAdd(const psTime *tai1, const psTime *tai2) 908 994 { 909 995 psTime *outTime = NULL; … … 929 1015 } 930 1016 931 psTime* psTimeSub (psTime *tai1,psTime *tai2)1017 psTime* psTimeSubtract(const psTime *tai1, const psTime *tai2) 932 1018 { 933 1019 psTime *outTime = NULL; … … 953 1039 } 954 1040 955 psTime* psTimeDelta( psTime *tai1,psTime *tai2)1041 psTime* psTimeDelta(const psTime *tai1, const psTime *tai2) 956 1042 { 957 1043 psTime *outTime = NULL; -
trunk/psLib/src/astro/psTime.h
r1788 r2048 54 54 * @author Ross Harman, MHPCC 55 55 * 56 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $57 * @date $Date: 2004- 09-11 00:55:13$56 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 57 * @date $Date: 2004-10-12 01:34:09 $ 58 58 * 59 59 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 69 69 #include "psType.h" 70 70 #include "psImage.h" 71 72 struct psSphere; 71 73 72 74 /// @addtogroup Time … … 138 140 * @return double: Time difference. 139 141 */ 140 double ps GetUT1Delta(141 psTime *time///< psTime to be looked up.142 double psTimeGetUT1Delta( 143 const psTime *time ///< psTime to be looked up. 142 144 ); 143 145 … … 148 150 * @return double: Time difference. 149 151 */ 150 double ps GetTAIDelta(151 psTime *time///< psTime to be looked up.152 double psTimeGetTAIDelta( 153 const psTime *time ///< psTime to be looked up. 152 154 ); 153 155 … … 158 160 * @return psSphere*: Spherical coordinates of Earth's polar axias. 159 161 */ 160 /*psSphere* psGetPoleCoords(161 psTime *time///< psTime determine polar orientation.162 );*/ 162 struct psSphere* psTimeGetPoleCoords( 163 const psTime *time ///< psTime determine polar orientation. 164 ); 163 165 164 166 /** Calculate the number of leapseconds between two times. … … 166 168 * Calculates the number of leapseconds between two times. 167 169 * 168 * @return psSphere*: Spherical coordinates of Earth's polar axias.169 */ 170 psF64psTimeLeapseconds(171 const psTime *time1, ///< First input time.172 const psTime *time2 ///< Second input time.170 * @return long: leapseconds added between given times 171 */ 172 long psTimeLeapseconds( 173 const psTime* time1, ///< First input time. 174 const psTime* time2 ///< Second input time. 173 175 ); 174 176 … … 180 182 */ 181 183 double psTimeToJD( 182 psTime *time///< Input time to be converted.184 const psTime* time ///< Input time to be converted. 183 185 ); 184 186 /** Convert psTime to modified Julian date time. … … 189 191 */ 190 192 double psTimeToMJD( 191 psTime *time///< Input time to be converted.193 const psTime* time ///< Input time to be converted. 192 194 ); 193 195 … … 199 201 * @return char*: Pointer null terminated array of chars in ISO time. 200 202 */ 201 char* psTimeToISO (202 psTime *time///< Input time to be converted.203 char* psTimeToISOTime( 204 const psTime* time ///< Input time to be converted. 203 205 ); 204 206 … … 210 212 */ 211 213 struct timeval psTimeToTimeval( 212 psTime *time///< Input time to be converted.214 const psTime* time ///< Input time to be converted. 213 215 ); 214 216 … … 221 223 */ 222 224 struct tm* psTimeToTM( 223 psTime *time///< Input time to be converted.225 const psTime *time ///< Input time to be converted. 224 226 ); 225 227 … … 230 232 * @return psTime: time. 231 233 */ 232 psTime* ps JDToTime(234 psTime* psTimeFromJD( 233 235 double time ///< Input time to be converted. 234 236 ); … … 240 242 * @return psTime: time. 241 243 */ 242 psTime* ps MJDToTime(244 psTime* psTimeFromMJD( 243 245 double time ///< Input time to be converted. 244 246 ); … … 250 252 * @return psTime*: time 251 253 */ 252 psTime* ps ISOToTime(253 c har *time///< Input time to be converted.254 psTime* psTimeFromISOTime( 255 const char* time ///< Input time to be converted. 254 256 ); 255 257 … … 260 262 * @return psTime*: time. 261 263 */ 262 psTime* psTime valToTime(263 struct timeval *time///< Input time to be converted.264 psTime* psTimeFromTimeval( 265 const struct timeval *time ///< Input time to be converted. 264 266 ); 265 267 … … 271 273 * @return psTime*: time. 272 274 */ 273 psTime* psT MToTime(274 struct tm *time///< Input time to be converted.275 psTime* psTimeFromTM( 276 const struct tm *time ///< Input time to be converted. 275 277 ); 276 278 … … 282 284 */ 283 285 psTime* psTimeAdd( 284 psTime *tai1,///< First TAI time.285 psTime *tai2///< Second TAI time.286 const psTime *tai1, ///< First TAI time. 287 const psTime *tai2 ///< Second TAI time. 286 288 ); 287 289 … … 292 294 * @return psTime*: time. 293 295 */ 294 psTime* psTimeSub (295 psTime *tai1,///< First TAI time.296 psTime *tai2///< Second TAI time.296 psTime* psTimeSubtract( 297 const psTime *tai1, ///< First TAI time. 298 const psTime *tai2 ///< Second TAI time. 297 299 ); 298 300 … … 305 307 */ 306 308 psTime* psTimeDelta( 307 psTime *tai1, ///< First TAI time. 308 psTime *tai2 ///< Second TAI time. 309 ); 310 311 312 /** Read TAI/UTC data file. 313 * 314 * Reads TAI/UTC data file. 315 * 316 * @return psImage*: Two-dimensional array with table data. 317 */ 318 psImage* readTaiUtcFile( 319 char *fileName ///< Name of file to read. 320 ); 321 322 323 /** Read SER7 data file. 324 * 325 * Reads SER7 data file. 326 * 327 * @return psImage*: Two-dimensional array with table data. 328 */ 329 psImage* readSer7File( 330 char *fileName ///< Name of file to read. 331 ); 332 333 /** Read finals data file. 334 * 335 * Reads finals data file. 336 * 337 * @return psImage*: Two-dimensional array with table data. 338 */ 339 psImage* readFinalsFile( 340 char *fileName ///< Name of file to read. 341 ); 342 343 /** Read EOPC data file. 344 * 345 * Reads EOPC data file. 346 * 347 * @return psImage*: Two-dimensional array with table data. 348 */ 349 psImage* readEopcFile( 350 char *fileName ///< Name of file to read. 351 ); 352 353 /** Lookup and interpolate TAI-UTC data 354 * 355 * Interpolates TAI-UTC data, given time in MJD format. 356 * 357 * @return double: Interpolated value. 358 */ 359 double lookupTaiUtcTable( 360 psImage *table, ///< Table with data. 361 psTime *time ///< time to lookup. 362 ); 363 364 /** Lookup and interpolate polar or UT1-UTC data 365 * 366 * Interpolates TAI-UT1 or polar coordinate data, given time in MJD format. 367 * 368 * @return double: Interpolated value. 369 */ 370 double lookupSer7Table( 371 psImage *table, ///< Table with data. 372 psTime *time, ///< time to lookup. 373 int col ///< Column to lookup. 374 ); 309 const psTime *tai1, ///< First TAI time. 310 const psTime *tai2 ///< Second TAI time. 311 ); 312 375 313 /// @} 376 314 -
trunk/psLib/src/astronomy/psAstrometry.c
r2001 r2048 8 8 * @author George Gusciora, MHPCC 9 9 * 10 * @version $Revision: 1.3 2$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-10- 07 19:16:46$10 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-10-12 01:34:09 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 455 455 psGrommit* psGrommitAlloc(const psExposure* exp) 456 456 { 457 double* AOPRMS = psAlloc(sizeof(double)*14); 458 457 459 if (exp == NULL) { 458 460 psAbort(__func__, "the 'exp' parameter is NULL\n"); 459 461 } 460 462 461 double date = TBD; // XXX: "mjd" in psExposure will become a psTime 462 // from which it will be possible to get UTC. 463 double dut = 0.0; 464 double elongm = TBD; // XXX 465 double phim = TBD; // XXX 466 double hm = TBD; // XXX 467 double xp = 0.0; 468 double yp = 0.0; 463 double date = psTimeToMJD(exp->time); 464 double dut = psTimeGetUT1Delta(exp->time); 465 double elongm = exp->observatory->longitude; 466 double phim = exp->observatory->latitude; 467 double hm = exp->observatory->height; 468 469 psSphere* polarMotion = psTimeGetPoleCoords(exp->time); 470 double xp = polarMotion->r; 471 double yp = polarMotion->d; 472 psFree(polarMotion); 473 469 474 double tdk = exp->temperature; 470 475 double pmb = exp->pressure; 471 476 double rh = exp->humidity; 472 477 double wl = exp->wavelength; 473 double tlr = TBD; // XXX 474 double *AOPRMS = NULL; 478 double tlr = exp->observatory->tlr; 475 479 476 480 slaAoppa(date, dut, elongm, phim, hm, xp, yp, … … 493 497 *(double *)&grommit->siderealTime = AOPRMS[13]; 494 498 499 psFree(AOPRMS); 500 495 501 return (grommit); 496 502 } -
trunk/psLib/src/astronomy/psAstrometry.h
r2001 r2048 8 8 * @author George Gusciora, MHPCC 9 9 * 10 * @version $Revision: 1.2 7$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-10- 07 19:16:46$10 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-10-12 01:34:09 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 192 192 { 193 193 const char* name; ///< Name of observatory 194 const double latitude; ///< Latitude of observatory, east positive 195 const double longitude; ///< Longitude of observatory 196 const double height; ///< Height of observatory 194 const double latitude; ///< Latitude of observatory, east positive (degrees?) 195 const double longitude; ///< Longitude of observatory (degrees?) 196 const double height; ///< Height of observatory in meters 197 197 const double tlr; ///< Tropospheric Lapse Rate 198 198 } … … 214 214 const double azimuth; ///< Azimuth 215 215 const psTime* time; ///< Time of observation 216 const float rotAngle; ///< Rotator position angle 217 const float temperature; ///< Air temperature , for estimating refraction218 const float pressure; ///< Air pressure , for calculating refraction216 const float rotAngle; ///< Rotator position angle in degrees? XXX: see bug#209 217 const float temperature; ///< Air temperature in Kelvin 218 const float pressure; ///< Air pressure in mB 219 219 const float humidity; ///< Relative humidity, for refraction 220 220 const float exposureTime; ///< Exposure time 221 const float wavelength; ///< Wavelength 221 const float wavelength; ///< Wavelength in microns 222 222 const psObservatory* observatory; ///< Observatory data 223 223 -
trunk/psLib/src/astronomy/psCoord.h
r1496 r2048 11 11 * @author George Gusciora, MHPCC 12 12 * 13 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2004- 08-12 01:23:20$13 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-12 01:34:09 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 53 53 * 54 54 */ 55 typedef struct 55 typedef struct psSphere 56 56 { 57 57 double r; ///< RA -
trunk/psLib/src/astronomy/psTime.c
r2032 r2048 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.3 0$ $Name: not supported by cvs2svn $14 * @date $Date: 2004-10- 09 00:17:14$13 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2004-10-12 01:34:09 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 27 #include "psAbort.h" 28 28 #include "psImage.h" 29 #include "psCoord.h" 29 30 30 31 #include "psAstronomyErrors.h" 32 33 #ifndef SER7_FILE 34 #define SER7_FILE "../../data/ser7.dat" 35 #endif 36 37 #ifndef TAIUTC_FILE 38 #define TAIUTC_FILE "../../data/tai-utc.dat" 39 #endif 31 40 32 41 /** Sidereal angular conversion from seconds to radians for GMST in seconds (i.e. pi/(180*240)) */ … … 61 70 62 71 /** Preprocessor macro to check for null psTime struct */ 63 #define CHECK_NULL_TIME(TIME,RETURN) \64 if(TIME == NULL) { \65 psError(__func__,"NULL value not allowed"); \66 return RETURN; \72 #define CHECK_NULL_TIME(TIME,RETURN) \ 73 if(TIME == NULL) { \ 74 psError(__func__,"NULL value not allowed"); \ 75 return RETURN; \ 67 76 } 68 77 69 78 /** Preprocessor macro to allocate psTime struct */ 70 #define ALLOC_TIME(TIME) \71 TIME = (psTime*)psAlloc(sizeof(psTime)); \72 if (TIME == NULL) { \73 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__); \74 } \75 TIME->sec = 0; \76 TIME->usec = 0; \79 #define ALLOC_TIME(TIME) \ 80 TIME = (psTime*)psAlloc(sizeof(psTime)); \ 81 if (TIME == NULL) { \ 82 psAbort(__func__, " : Line %d - Failed to allocate memory", __LINE__); \ 83 } \ 84 TIME->sec = 0; \ 85 TIME->usec = 0; \ 77 86 TIME->type = PS_TIME_TAI; 78 87 79 80 psImage* readTaiUtcFile(char *fileName) 88 /** Read TAI/UTC data file. 89 * 90 * Reads TAI/UTC data file. 91 * 92 * @return psImage*: Two-dimensional array with table data. 93 */ 94 static psImage* readTaiUtcFile( 95 const char *fileName ///< Name of file to read. 96 ); 97 98 99 /** Read SER7 data file. 100 * 101 * Reads SER7 data file. 102 * 103 * @return psImage*: Two-dimensional array with table data. 104 */ 105 static psImage* readSer7File( 106 const char *fileName ///< Name of file to read. 107 ); 108 109 110 /** Read finals data file. 111 * 112 * Reads finals data file. 113 * 114 * @return psImage*: Two-dimensional array with table data. 115 */ 116 /* not yet used 117 static psImage* readFinalsFile( 118 char *fileName ///< Name of file to read. 119 ); 120 */ 121 122 /** Read EOPC data file. 123 * 124 * Reads EOPC data file. 125 * 126 * @return psImage*: Two-dimensional array with table data. 127 */ 128 /* not yet used 129 static psImage* readEopcFile( 130 char *fileName ///< Name of file to read. 131 ); 132 */ 133 134 /** Lookup and interpolate TAI-UTC data 135 * 136 * Interpolates TAI-UTC data, given time in MJD format. 137 * 138 * @return double: Interpolated value. 139 */ 140 static double lookupTaiUtcTable( 141 const psTime *time ///< time to lookup. 142 ); 143 144 /** Lookup and interpolate polar or UT1-UTC data 145 * 146 * Interpolates TAI-UT1 or polar coordinate data, given time in MJD format. 147 * 148 * @return double: Interpolated value. 149 */ 150 static double lookupSer7Table( 151 const psTime *time, ///< time to lookup. 152 int col ///< Column to lookup. 153 ); 154 155 static psImage* readTaiUtcFile(const char *fileName) 81 156 { 82 157 char line[LINESIZE]; … … 113 188 *(unsigned int *)&table->numRows = j; 114 189 190 p_psMemSetPersistent(table,true); 191 p_psMemSetPersistent(table->data.V,true); 192 p_psMemSetPersistent(table->rawDataBuffer,true); 193 115 194 return table; 116 195 } 117 196 118 psImage* readSer7File(char *fileName)197 static psImage* readSer7File(const char *fileName) 119 198 { 120 199 bool beginRecord = false; … … 160 239 *(unsigned int *)&table->numRows = j; 161 240 241 p_psMemSetPersistent(table,true); 242 p_psMemSetPersistent(table->data.V,true); 243 p_psMemSetPersistent(table->rawDataBuffer,true); 244 162 245 return table; 163 246 } 164 247 165 psImage* readEopcFile(char *fileName) 248 /* Not yet used... 249 static psImage* readEopcFile(char *fileName) 166 250 { 167 251 char line[LINESIZE]; … … 171 255 psImage *table = NULL; 172 256 FILE *fd = NULL; 173 174 257 258 175 259 fd=fopen(fileName, "r"); 176 260 if(fd==NULL) { … … 178 262 return NULL ; 179 263 } 180 264 181 265 // Table shouldn't be larger than 2500 rows. All columns are read. 182 266 table = psImageAlloc(11, maxLines, PS_TYPE_F64); … … 186 270 } 187 271 } 188 272 189 273 while(fgets(line, LINESIZE, fd) != NULL) { 190 274 if(j>=maxLines) { … … 197 281 ptr, ptr+1, ptr+2, ptr+3, ptr+4, ptr+5, ptr+6, ptr+7, ptr+8, ptr+9, ptr+10); 198 282 } 199 283 200 284 *(unsigned int *)&table->numRows = j; 201 285 202 286 return table; 203 287 } 204 205 psImage* readFinalsFile(char *fileName)288 289 static psImage* readFinalsFile(char *fileName) 206 290 { 207 291 char line[LINESIZE]; … … 210 294 psImage *table = NULL; 211 295 FILE *fd = NULL; 212 213 296 297 214 298 fd=fopen(fileName, "r"); 215 299 if(fd==NULL) { … … 217 301 return NULL ; 218 302 } 219 303 220 304 // Table shouldn't be larger than 15000 rows. Select columns are read. 221 305 table = psImageAlloc(6, maxLines, PS_TYPE_F64); … … 226 310 psFree(table); 227 311 } 228 312 229 313 psF64 *ptr = table->data.F64[j++]; 230 314 ptr = table->data.F64[j++]; 231 315 232 316 // Sometimes there are blank entries in this table, so check for a space to determine if there is no entry 233 317 if(*(line+7) == ' ') { // MJD … … 236 320 *ptr = atof(line+7); 237 321 } 238 322 239 323 if(*(line+18) == ' ') { // Polar motion X 240 324 *(ptr+1) = 0.0; … … 242 326 *(ptr+1) = atof(line+18); 243 327 } 244 328 245 329 if(*(line+27) == ' ') { // Polar motion X error 246 330 *(ptr+2) = 0.0; … … 248 332 *(ptr+2) = atof(line+27); 249 333 } 250 334 251 335 if(*(line+37) == ' ') { // Polar motion Y 252 336 *(ptr+3) = 0.0; … … 254 338 *(ptr+3) = atof(line+37); 255 339 } 256 340 257 341 if(*(line+46) == ' ') { // Polar motion Y error 258 342 *(ptr+4) = 0.0; … … 260 344 *(ptr+4) = atof(line+46); 261 345 } 262 346 263 347 if(*(line+58) == ' ') { // UT1-UTC 264 348 *(ptr+5) = 0.0; … … 267 351 } 268 352 } 269 353 270 354 *(unsigned int *)&table->numRows = j; 271 355 272 356 return table; 273 357 } 274 275 276 double lookupTaiUtcTable(psImage *table,psTime *time)358 */ 359 360 static double lookupTaiUtcTable(const psTime *time) 277 361 { 278 362 int hiIdx = 0; … … 286 370 double const2 = 0.0; 287 371 double const3 = 0.0; 288 372 static psImage* table = NULL; 373 374 if (table == NULL) { 375 table = readTaiUtcFile(TAIUTC_FILE); 376 if (table == NULL) { 377 psAbort(__func__,"Failed to read tai-utc.dat file"); 378 } 379 } 289 380 290 381 // Number of rows is the number of rows of data read from the data file … … 337 428 } 338 429 339 double lookupSer7Table(psImage *table,psTime *time, int col)430 static double lookupSer7Table(const psTime *time, int col) 340 431 { 341 432 int hiIdx = 0; … … 345 436 double denom = 0.0; 346 437 double mjdUtc = 0.0; 347 438 static psImage* table = NULL; 439 440 if (table == NULL) { 441 table = readSer7File(SER7_FILE); 442 if (table == NULL) { 443 psAbort(__func__,"Failed to read the ser7.dat file."); 444 } 445 } 348 446 349 447 // Number of rows is the number of rows of data read from the data file … … 404 502 // Add most leapseconds to UTC time to get TAI time if necessary 405 503 if(type == PS_TIME_TAI) { 406 time->sec += ps GetTAIDelta(time);504 time->sec += psTimeGetTAIDelta(time); 407 505 } 408 506 … … 420 518 } 421 519 422 delta = ps GetTAIDelta(time);520 delta = psTimeGetTAIDelta(time); 423 521 424 522 if(type == PS_TIME_UTC) { … … 461 559 taiTime = psMemIncrRefCounter(time); 462 560 ALLOC_TIME(utcTime); 463 utcTime->sec = taiTime->sec - ps GetTAIDelta(time);561 utcTime->sec = taiTime->sec - psTimeGetTAIDelta(time); 464 562 utcTime->usec = taiTime->usec; 465 563 utcTime->type = PS_TIME_UTC; … … 467 565 utcTime = psMemIncrRefCounter(time); 468 566 ALLOC_TIME(taiTime); 469 taiTime->sec = utcTime->sec + ps GetTAIDelta(time);567 taiTime->sec = utcTime->sec + psTimeGetTAIDelta(time); 470 568 taiTime->usec = utcTime->usec; 471 569 taiTime->type = PS_TIME_TAI; … … 475 573 ALLOC_TIME(ut1UtcDelta); 476 574 ut1UtcDelta->type = PS_TIME_UTC; 477 ut1UtcDelta->usec = ps GetUT1Delta(utcTime)*1e6;575 ut1UtcDelta->usec = psTimeGetUT1Delta(utcTime)*1e6; 478 576 ut1Time = psTimeAdd(utcTime, ut1UtcDelta); 479 577 … … 516 614 } 517 615 518 double psGetUT1Delta(psTime *time) 519 { 520 static psImage* iersTable = NULL; 521 double ut1UtcDeltaUsec = 0.0; 522 523 524 if (iersTable == NULL) { 525 iersTable = readSer7File("../../data/ser7.dat"); 526 p_psMemSetPersistent(iersTable,true); 527 p_psMemSetPersistent(iersTable->data.V,true); 528 p_psMemSetPersistent(iersTable->rawDataBuffer,true); 529 } 530 531 ut1UtcDeltaUsec = lookupSer7Table(iersTable, time, 6)*1.0e6; 532 533 return ut1UtcDeltaUsec; 534 } 535 536 double psGetTAIDelta(psTime *time) 537 { 538 double delta = 0.0; 539 static psImage* taiUtcTable = NULL; 540 541 542 if (taiUtcTable == NULL) { 543 taiUtcTable = readTaiUtcFile("../../data/tai-utc.dat"); 544 p_psMemSetPersistent(taiUtcTable,true); 545 p_psMemSetPersistent(taiUtcTable->data.V,true); 546 p_psMemSetPersistent(taiUtcTable->rawDataBuffer,true); 547 } 548 delta = lookupTaiUtcTable(taiUtcTable, time); 549 550 return delta; 551 } 552 553 psF64 psTimeLeapseconds(const psTime *time1, const psTime *time2) 554 { 555 psF64 diff = 0.0; 616 double psTimeGetUT1Delta(const psTime *time) 617 { 618 return lookupSer7Table(time, 6); 619 } 620 621 struct psSphere* psTimeGetPoleCoords(const psTime* time) 622 { 623 624 double x = lookupSer7Table((psTime*)time, 4); 625 double y = lookupSer7Table((psTime*)time, 5); 626 627 struct psSphere* output = psAlloc(sizeof(psSphere)); 628 output->r = x * M_PI / 648000.0; // x in arcsec converted to radians, i.e., x/60/60*M_PI/180 629 output->d = y * M_PI / 648000.0; 630 631 return output; 632 } 633 634 double psTimeGetTAIDelta(const psTime *time) 635 { 636 return lookupTaiUtcTable(time); 637 } 638 639 long psTimeLeapseconds(const psTime *time1, const psTime *time2) 640 { 641 long diff = 0; 556 642 557 643 // NULL error checks … … 559 645 CHECK_NULL_TIME(time2,0); 560 646 561 diff = fabs(psGetTAIDelta((psTime*)time1)-psGetTAIDelta((psTime*)time2));647 diff = abs(psTimeGetTAIDelta((psTime*)time1)-psTimeGetTAIDelta((psTime*)time2)); 562 648 563 649 return diff; 564 650 } 565 651 566 double psTimeToJD( psTime *time)652 double psTimeToJD(const psTime *time) 567 653 { 568 654 double jd = 0.0; … … 582 668 } 583 669 584 double psTimeToMJD( psTime *time)670 double psTimeToMJD(const psTime *time) 585 671 { 586 672 double mjd = 0.0; … … 600 686 } 601 687 602 char* psTimeToISO (psTime *time)688 char* psTimeToISOTime(const psTime *time) 603 689 { 604 690 int ms = 0; … … 634 720 } 635 721 636 struct timeval psTimeToTimeval( psTime *time)722 struct timeval psTimeToTimeval(const psTime *time) 637 723 { 638 724 struct timeval timevalTime; … … 648 734 } 649 735 650 struct tm* psTimeToTM( psTime *time)736 struct tm* psTimeToTM(const psTime *time) 651 737 { 652 738 long cent = 0; … … 711 797 } 712 798 713 psTime* ps JDToTime(double time)799 psTime* psTimeFromJD(double time) 714 800 { 715 801 double days = 0.0; … … 734 820 } 735 821 736 psTime* ps MJDToTime(double time)822 psTime* psTimeFromMJD(double time) 737 823 { 738 824 double days = 0.0; … … 757 843 } 758 844 759 psTime* ps ISOToTime(char *time)845 psTime* psTimeFromISOTime(const char *time) 760 846 { 761 847 char tempString[MAX_TIME_STRING_LENGTH]; … … 826 912 827 913 // Convert tm time to psTime 828 outTime = psT MToTime(&tmTime);914 outTime = psTimeFromTM(&tmTime); 829 915 outTime->usec = millisecond * 1000; 830 916 … … 832 918 } 833 919 834 psTime* psTime valToTime(struct timeval *time)920 psTime* psTimeFromTimeval(const struct timeval *time) 835 921 { 836 922 psTime *outTime = NULL; … … 850 936 } 851 937 852 psTime* psT MToTime(struct tm* time)938 psTime* psTimeFromTM(const struct tm* time) 853 939 { 854 940 long year; … … 905 991 } 906 992 907 psTime* psTimeAdd( psTime *tai1,psTime *tai2)993 psTime* psTimeAdd(const psTime *tai1, const psTime *tai2) 908 994 { 909 995 psTime *outTime = NULL; … … 929 1015 } 930 1016 931 psTime* psTimeSub (psTime *tai1,psTime *tai2)1017 psTime* psTimeSubtract(const psTime *tai1, const psTime *tai2) 932 1018 { 933 1019 psTime *outTime = NULL; … … 953 1039 } 954 1040 955 psTime* psTimeDelta( psTime *tai1,psTime *tai2)1041 psTime* psTimeDelta(const psTime *tai1, const psTime *tai2) 956 1042 { 957 1043 psTime *outTime = NULL; -
trunk/psLib/src/astronomy/psTime.h
r1788 r2048 54 54 * @author Ross Harman, MHPCC 55 55 * 56 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $57 * @date $Date: 2004- 09-11 00:55:13$56 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 57 * @date $Date: 2004-10-12 01:34:09 $ 58 58 * 59 59 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 69 69 #include "psType.h" 70 70 #include "psImage.h" 71 72 struct psSphere; 71 73 72 74 /// @addtogroup Time … … 138 140 * @return double: Time difference. 139 141 */ 140 double ps GetUT1Delta(141 psTime *time///< psTime to be looked up.142 double psTimeGetUT1Delta( 143 const psTime *time ///< psTime to be looked up. 142 144 ); 143 145 … … 148 150 * @return double: Time difference. 149 151 */ 150 double ps GetTAIDelta(151 psTime *time///< psTime to be looked up.152 double psTimeGetTAIDelta( 153 const psTime *time ///< psTime to be looked up. 152 154 ); 153 155 … … 158 160 * @return psSphere*: Spherical coordinates of Earth's polar axias. 159 161 */ 160 /*psSphere* psGetPoleCoords(161 psTime *time///< psTime determine polar orientation.162 );*/ 162 struct psSphere* psTimeGetPoleCoords( 163 const psTime *time ///< psTime determine polar orientation. 164 ); 163 165 164 166 /** Calculate the number of leapseconds between two times. … … 166 168 * Calculates the number of leapseconds between two times. 167 169 * 168 * @return psSphere*: Spherical coordinates of Earth's polar axias.169 */ 170 psF64psTimeLeapseconds(171 const psTime *time1, ///< First input time.172 const psTime *time2 ///< Second input time.170 * @return long: leapseconds added between given times 171 */ 172 long psTimeLeapseconds( 173 const psTime* time1, ///< First input time. 174 const psTime* time2 ///< Second input time. 173 175 ); 174 176 … … 180 182 */ 181 183 double psTimeToJD( 182 psTime *time///< Input time to be converted.184 const psTime* time ///< Input time to be converted. 183 185 ); 184 186 /** Convert psTime to modified Julian date time. … … 189 191 */ 190 192 double psTimeToMJD( 191 psTime *time///< Input time to be converted.193 const psTime* time ///< Input time to be converted. 192 194 ); 193 195 … … 199 201 * @return char*: Pointer null terminated array of chars in ISO time. 200 202 */ 201 char* psTimeToISO (202 psTime *time///< Input time to be converted.203 char* psTimeToISOTime( 204 const psTime* time ///< Input time to be converted. 203 205 ); 204 206 … … 210 212 */ 211 213 struct timeval psTimeToTimeval( 212 psTime *time///< Input time to be converted.214 const psTime* time ///< Input time to be converted. 213 215 ); 214 216 … … 221 223 */ 222 224 struct tm* psTimeToTM( 223 psTime *time///< Input time to be converted.225 const psTime *time ///< Input time to be converted. 224 226 ); 225 227 … … 230 232 * @return psTime: time. 231 233 */ 232 psTime* ps JDToTime(234 psTime* psTimeFromJD( 233 235 double time ///< Input time to be converted. 234 236 ); … … 240 242 * @return psTime: time. 241 243 */ 242 psTime* ps MJDToTime(244 psTime* psTimeFromMJD( 243 245 double time ///< Input time to be converted. 244 246 ); … … 250 252 * @return psTime*: time 251 253 */ 252 psTime* ps ISOToTime(253 c har *time///< Input time to be converted.254 psTime* psTimeFromISOTime( 255 const char* time ///< Input time to be converted. 254 256 ); 255 257 … … 260 262 * @return psTime*: time. 261 263 */ 262 psTime* psTime valToTime(263 struct timeval *time///< Input time to be converted.264 psTime* psTimeFromTimeval( 265 const struct timeval *time ///< Input time to be converted. 264 266 ); 265 267 … … 271 273 * @return psTime*: time. 272 274 */ 273 psTime* psT MToTime(274 struct tm *time///< Input time to be converted.275 psTime* psTimeFromTM( 276 const struct tm *time ///< Input time to be converted. 275 277 ); 276 278 … … 282 284 */ 283 285 psTime* psTimeAdd( 284 psTime *tai1,///< First TAI time.285 psTime *tai2///< Second TAI time.286 const psTime *tai1, ///< First TAI time. 287 const psTime *tai2 ///< Second TAI time. 286 288 ); 287 289 … … 292 294 * @return psTime*: time. 293 295 */ 294 psTime* psTimeSub (295 psTime *tai1,///< First TAI time.296 psTime *tai2///< Second TAI time.296 psTime* psTimeSubtract( 297 const psTime *tai1, ///< First TAI time. 298 const psTime *tai2 ///< Second TAI time. 297 299 ); 298 300 … … 305 307 */ 306 308 psTime* psTimeDelta( 307 psTime *tai1, ///< First TAI time. 308 psTime *tai2 ///< Second TAI time. 309 ); 310 311 312 /** Read TAI/UTC data file. 313 * 314 * Reads TAI/UTC data file. 315 * 316 * @return psImage*: Two-dimensional array with table data. 317 */ 318 psImage* readTaiUtcFile( 319 char *fileName ///< Name of file to read. 320 ); 321 322 323 /** Read SER7 data file. 324 * 325 * Reads SER7 data file. 326 * 327 * @return psImage*: Two-dimensional array with table data. 328 */ 329 psImage* readSer7File( 330 char *fileName ///< Name of file to read. 331 ); 332 333 /** Read finals data file. 334 * 335 * Reads finals data file. 336 * 337 * @return psImage*: Two-dimensional array with table data. 338 */ 339 psImage* readFinalsFile( 340 char *fileName ///< Name of file to read. 341 ); 342 343 /** Read EOPC data file. 344 * 345 * Reads EOPC data file. 346 * 347 * @return psImage*: Two-dimensional array with table data. 348 */ 349 psImage* readEopcFile( 350 char *fileName ///< Name of file to read. 351 ); 352 353 /** Lookup and interpolate TAI-UTC data 354 * 355 * Interpolates TAI-UTC data, given time in MJD format. 356 * 357 * @return double: Interpolated value. 358 */ 359 double lookupTaiUtcTable( 360 psImage *table, ///< Table with data. 361 psTime *time ///< time to lookup. 362 ); 363 364 /** Lookup and interpolate polar or UT1-UTC data 365 * 366 * Interpolates TAI-UT1 or polar coordinate data, given time in MJD format. 367 * 368 * @return double: Interpolated value. 369 */ 370 double lookupSer7Table( 371 psImage *table, ///< Table with data. 372 psTime *time, ///< time to lookup. 373 int col ///< Column to lookup. 374 ); 309 const psTime *tai1, ///< First TAI time. 310 const psTime *tai2 ///< Second TAI time. 311 ); 312 375 313 /// @} 376 314 -
trunk/psLib/test/astronomy/tst_psAstrometry.c
r2006 r2048 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-10- 07 19:51:30$7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-10-12 01:34:09 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 19 19 static int testExposureAlloc(void); 20 20 static int testObservatoryAlloc(void); 21 static int testFPAAlloc(void); 22 // static int testGrommitAlloc(void); 21 23 22 24 testDescription tests[] = { 23 25 {testExposureAlloc,735,"psExposureAlloc",0,false}, 24 26 {testObservatoryAlloc,736,"psObservatoryAlloc",0,false}, 27 {testFPAAlloc,739,"psFPAAlloc",0,false}, 25 28 {NULL} 26 29 }; … … 119 122 char* name = "The Kaiser Royal Observatory"; 120 123 psObservatory* obs = psObservatoryAlloc(name, 121 20.7 , 156.3, 3055.0, 9.0);122 123 if (fabs(obs->latitude - 20.7 ) > DBL_EPSILON) {124 20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 9.0); 125 126 if (fabs(obs->latitude - 20.7*M_PI/180.0) > DBL_EPSILON) { 124 127 psLogMsg(__func__,PS_LOG_ERROR,"psObservatoryAlloc did not set latitude."); 125 128 return 1; 126 129 } 127 130 128 if (fabs(obs->longitude - 156.3 ) > DBL_EPSILON) {131 if (fabs(obs->longitude - 156.3*M_PI/180.0) > DBL_EPSILON) { 129 132 psLogMsg(__func__,PS_LOG_ERROR,"psObservatoryAlloc did not set longitude."); 130 133 return 2; … … 152 155 153 156 psObservatory* obs2 = psObservatoryAlloc(NULL, 154 20.7 , 156.3, 3055.0, 9.0);157 20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 9.0); 155 158 156 159 if (obs2->name != NULL) { … … 164 167 return 0; 165 168 } 169 170 static int testFPAAlloc(void) 171 { 172 173 psTime* now = psTimeGetTime(PS_TIME_UTC); 174 char* name = "The Kaiser Royal Observatory"; 175 176 psObservatory* obs = psObservatoryAlloc(name, 177 20.7*M_PI/180.0, 156.3*M_PI/180.0, 3055.0, 0.0065f); 178 179 psExposure* exp = psExposureAlloc(1.0, 2.0, 3.0, 4.0, 5.0, 180 now, 6.0f, 260.0f, 1013.0f, 0.7f, 10.0f, 0.650f, obs); 181 182 /* 183 1. Call psFPAAlloc with nChips > 0 and a non-NULL psExposure. 184 a) Verify that the psExposure reference is: 1. is set in struct as 185 exposure; 2. its reference count is incremented. 186 b) Verify that the chip attribute is of the size specified by the 187 parameter nChips and that the chips array elements are all NULL. 188 c) verify that all other references in the struct is NULL. 189 */ 190 191 psFPA* fpa = psFPAAlloc(8, exp); 192 193 if (fpa == NULL) { 194 psLogMsg(__func__,PS_LOG_ERROR, 195 "psFPAAlloc returned a NULL."); 196 return 1; 197 } 198 199 if (fpa->exposure != exp) { 200 psLogMsg(__func__,PS_LOG_ERROR, 201 "psFPAAlloc did not set the exposure."); 202 return 2; 203 } 204 205 if (psMemGetRefCounter(exp) != 2) { 206 psLogMsg(__func__,PS_LOG_ERROR, 207 "psFPAAlloc did not increment reference counter for exposure."); 208 return 3; 209 } 210 211 if (fpa->chips->n != 8) { 212 psLogMsg(__func__,PS_LOG_ERROR, 213 "psFPAAlloc did not set the number of chips properly."); 214 return 4; 215 } 216 217 for (int lcv=0; lcv < 8; lcv++) { 218 if (fpa->chips->data[lcv] != NULL) { 219 psLogMsg(__func__,PS_LOG_ERROR, 220 "psFPAAlloc did not set chip %d to NULL.", lcv); 221 return 5; 222 } 223 } 224 225 if (fpa->metadata != NULL) { 226 psLogMsg(__func__,PS_LOG_ERROR, 227 "psFPAAlloc did not set metadata to NULL."); 228 return 6; 229 } 230 231 if (fpa->fromTangentPlane != NULL) { 232 psLogMsg(__func__,PS_LOG_ERROR, 233 "psFPAAlloc did not set fromTangentPlane to NULL."); 234 return 7; 235 } 236 237 if (fpa->toTangentPlane != NULL) { 238 psLogMsg(__func__,PS_LOG_ERROR, 239 "psFPAAlloc did not set toTangentPlane to NULL."); 240 return 8; 241 } 242 243 if (fpa->pattern != NULL) { 244 psLogMsg(__func__,PS_LOG_ERROR, 245 "psFPAAlloc did not set pattern to NULL."); 246 return 9; 247 } 248 249 if (fpa->grommit == NULL) { 250 psLogMsg(__func__,PS_LOG_ERROR, 251 "psFPAAlloc did not set grommit using given exposure."); 252 return 10; 253 } 254 255 if (fpa->colorPlus != NULL) { 256 psLogMsg(__func__,PS_LOG_ERROR, 257 "psFPAAlloc did not set colorPlus to NULL."); 258 return 11; 259 } 260 261 if (fpa->colorMinus != NULL) { 262 psLogMsg(__func__,PS_LOG_ERROR, 263 "psFPAAlloc did not set colorMinus to NULL."); 264 return 12; 265 } 266 267 if (fpa->projection != NULL) { 268 psLogMsg(__func__,PS_LOG_ERROR, 269 "psFPAAlloc did not set projection to NULL."); 270 return 13; 271 } 272 273 /* 274 2. Call psFPAAlloc with nChips = 0. Verify that the chips array is 275 zero in size and the program execution does not stop. 276 */ 277 278 psFPA* fpa2 = psFPAAlloc(0,exp); 279 280 if (fpa2->chips->n != 0) { 281 psLogMsg(__func__,PS_LOG_ERROR, 282 "psFPAAlloc did not set the number of chips properly."); 283 return 14; 284 } 285 286 /* 287 3. Call psFPAAlloc with a NULL psExposure. Verify that the program 288 execution doe not stop and the exposure attribute is NULL. 289 */ 290 291 psFPA* fpa3 = psFPAAlloc(4,NULL); 292 if (fpa3->exposure != NULL) { 293 psLogMsg(__func__,PS_LOG_ERROR, 294 "psFPAAlloc did not set the exposure to NULL given NULL parameter."); 295 return 15; 296 } 297 298 /* 299 4. Call psFPAAlloc and set all references in the struct to a memory 300 buffer. Verify that psFree cleans up all the buffers referenced in 301 the struct, i.e., there is no memory leaks generated. 302 */ 303 304 for (int lcv=0; lcv < 8; lcv++) { 305 fpa->chips->data[lcv] = psAlloc(4); 306 } 307 308 fpa->metadata = psAlloc(4); 309 fpa->fromTangentPlane = psAlloc(4); 310 fpa->toTangentPlane = psAlloc(4); 311 fpa->pattern = psAlloc(4); 312 fpa->colorPlus = psAlloc(4); 313 fpa->colorMinus = psAlloc(4); 314 fpa->projection = psAlloc(4); 315 316 psFree(fpa3); 317 psFree(fpa2); 318 psFree(fpa); 319 psFree(exp); 320 psFree(obs); 321 322 return 0; 323 } -
trunk/psLib/test/astronomy/tst_psTime_01.c
r2030 r2048 23 23 * @author Ross Harman, MHPCC 24 24 * 25 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $26 * @date $Date: 2004-10- 08 23:30:47$25 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 26 * @date $Date: 2004-10-12 01:34:09 $ 27 27 * 28 28 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 62 62 printPositiveTestHeader(stdout,"psTime", "Convert psTime to ISO time"); 63 63 char *isoString; 64 isoString = psTimeToISO (testTime);64 isoString = psTimeToISOTime(testTime); 65 65 printf("%s\n", isoString); 66 66 if(strncmp(isoString, testString, 256)) { … … 74 74 printPositiveTestHeader(stdout,"psTime", "Convert ISO time to psTime"); 75 75 psTime *timeD = NULL; 76 timeD = ps ISOToTime(isoString);76 timeD = psTimeFromISOTime(isoString); 77 77 printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeD->sec, (psU32)timeD->usec); 78 78 psFree(isoString); … … 118 118 printPositiveTestHeader(stdout,"psTime", "Convert MJD time to psTime"); 119 119 psTime *timeH = NULL; 120 timeH = ps MJDToTime(mjdTime);120 timeH = psTimeFromMJD(mjdTime); 121 121 printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeH->sec, (psU32)timeH->usec); 122 122 psFree(timeH); … … 135 135 printPositiveTestHeader(stdout,"psTime", "Convert JD time to psTime"); 136 136 psTime *timeJ = NULL; 137 timeJ = ps JDToTime(jdTime);137 timeJ = psTimeFromJD(jdTime); 138 138 printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeJ->sec, (psU32)timeJ->usec); 139 139 psFree(timeJ); … … 152 152 printPositiveTestHeader(stdout,"psTime", "Convert timeval time to psTime"); 153 153 psTime *timeL = NULL; 154 timeL = psTime valToTime(&timevalTime);154 timeL = psTimeFromTimeval(&timevalTime); 155 155 printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeL->sec, (psU32)timeL->usec); 156 156 psFree(timeL); … … 175 175 printPositiveTestHeader(stdout, "psTime", "Convert tm time to psTime"); 176 176 psTime *timeN = NULL; 177 timeN = psT MToTime(tmTime);177 timeN = psTimeFromTM(tmTime); 178 178 printf("psTime: Seconds = %ld Microseconds = %d\n", (long)timeN->sec, (psU32)timeN->usec); 179 179 psFree(timeN); … … 186 186 char *testString2 = "2004-09-10T1:00:00.00Z"; 187 187 psTime* testTime2 = NULL; 188 testTime2 = ps ISOToTime(testString2);188 testTime2 = psTimeFromISOTime(testString2); 189 189 double dblTime = psTimeToLST(testTime2, 1); 190 190 printf("LST (rad): %lf\n", dblTime); -
trunk/psLib/test/astronomy/tst_psTime_02.c
r2024 r2048 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-10- 08 22:58:47$11 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-10-12 01:34:09 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 // Test A - Incorrect ISO time data 25 25 printNegativeTestHeader(stdout,"psTime", "Incorrect ISO time data", "Time not allowed", 0); 26 ps ISOToTime("2004-99-21T18:22:24.272Z");27 ps ISOToTime("2004-07-99T18:22:24.272Z");28 ps ISOToTime("2004-07-21T99:22:24.272Z");29 ps ISOToTime("2004-07-21T18:99:24.272Z");30 ps ISOToTime("2004-07-21T18:22:99.272Z");31 ps ISOToTime("2004-07-21T18:22:24.-999Z");26 psTimeFromISOTime("2004-99-21T18:22:24.272Z"); 27 psTimeFromISOTime("2004-07-99T18:22:24.272Z"); 28 psTimeFromISOTime("2004-07-21T99:22:24.272Z"); 29 psTimeFromISOTime("2004-07-21T18:99:24.272Z"); 30 psTimeFromISOTime("2004-07-21T18:22:99.272Z"); 31 psTimeFromISOTime("2004-07-21T18:22:24.-999Z"); 32 32 printFooter(stdout, "psTime", "Incorrect ISO time data", true); 33 33 … … 36 36 printNegativeTestHeader(stdout,"psTime", "Attempt to use null timeval", 37 37 "Null value for timeval arg not allowed", 0); 38 psTime valToTime(NULL);38 psTimeFromTimeval(NULL); 39 39 printFooter(stdout, "psTime", "Attempt to use null timeval", true); 40 40
Note:
See TracChangeset
for help on using the changeset viewer.
