IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 22705


Ignore:
Timestamp:
Feb 26, 2009, 4:46:22 PM (17 years ago)
Author:
Paul Price
Message:

Convert all times to TAI before generating JD or MJD.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psTime.c

    r22684 r22705  
    12591259double psTimeToJD(const psTime *time)
    12601260{
    1261     psF64 jd = NAN;
    1262 
    12631261    // Error checks
    12641262    PS_ASSERT_PTR_NON_NULL(time,NAN);
    12651263    PS_ASSERT_INT_WITHIN_RANGE(time->nsec,0,(psU32)((1e9)-1),NAN);
    12661264
     1265    // ADD says that this formula works only for PS_TIME_TAI, so adding the following:
    12671266    psTime *time2 = psTimeCopy(time);
    1268     //XXX: ADD says that this formula works only for PS_TIME_TAI, so adding the following:
    1269     if (time->type == PS_TIME_UTC || time->type == PS_TIME_TT) {
    1270         psTimeConvert(time2, PS_TIME_TAI);
    1271     }
    1272 
    1273     // Julian date conversion
     1267    psTimeConvert(time2, PS_TIME_TAI);
     1268
     1269    double jd;                          // Julian date, to return
    12741270    if (time2->sec < 0) {
    12751271        // psTime earlier than epoch
     
    12791275        jd = time2->sec / SEC_PER_DAY + time2->nsec / NSEC_PER_DAY + JD_EPOCH_OFFSET;
    12801276    }
    1281 
    12821277    psFree(time2);
     1278
    12831279    return jd;
    12841280}
     
    12861282double psTimeToMJD(const psTime *time)
    12871283{
    1288     psF64 mjd = NAN;
    1289 
    12901284    // Error checks
    12911285    PS_ASSERT_PTR_NON_NULL(time,NAN);
    12921286    PS_ASSERT_INT_WITHIN_RANGE(time->nsec,0,(psU32)((1e9)-1),NAN);
     1287
     1288    // ADD says that this formula works only for PS_TIME_TAI, so adding the following:
    12931289    psTime *time2 = psTimeCopy(time);
    1294     //XXX: ADD says that this formula works only for PS_TIME_TAI, so adding the following:
    1295     if (time->type == PS_TIME_UTC || time->type == PS_TIME_TT) {
    1296         psTimeConvert(time2, PS_TIME_TAI);
    1297     }
    1298 
    1299     // Modified Julian date conversion
     1290    psTimeConvert(time2, PS_TIME_TAI);
     1291
     1292    double mjd;                         // Modified Julian Date, to return
    13001293    if (time2->sec < 0) {
    13011294        // psTime earlier than epoch
     
    13061299    }
    13071300    psFree(time2);
     1301
    13081302    return mjd;
    13091303}
Note: See TracChangeset for help on using the changeset viewer.