Example #1
0
def datetime2mjd_tdb(date, obsvr_long, obsvr_lat, obsvr_hgt, dbg=False):

    auinkm = 149597870.691
    # Compute MJD_UTC from passed datetime
    mjd_utc = datetime2mjd_utc(date)
    if mjd_utc == None:
        return None

    # Compute MJD_TT
    mjd_tt = mjd_utc2mjd_tt(mjd_utc, dbg)

    # Compute TT->TDB

    # Convert geodetic position to geocentric distance from spin axis (r) and from
    # equatorial plane (z)
    (r, z) = S.sla_geoc(obsvr_lat, obsvr_hgt)

    ut1 = compute_ut1(mjd_utc, dbg)
    if dbg:
        print "UT1=", ut1

    # Compute relativistic clock correction TDB->TT
    tdb_tt = S.sla_rcc(mjd_tt, ut1, -obsvr_long, r * auinkm, z * auinkm)
    if dbg:
        print "(TDB-TT)=", tdb_tt
    if dbg:
        print "(CT-UT)=", S.sla_dtt(mjd_utc) + tdb_tt

    mjd_tdb = mjd_tt + (tdb_tt / 86400.0)

    return mjd_tdb
Example #2
0
hdrs_needed = obtain_hdrpars(prihdr, debug)

# Compute TT midpoint of the exposure (in MJD)
hdrs_needed = compute_tt_mid(hdrs_needed, debug)

# Compute UT1
hdrs_needed = compute_ut1(hdrs_needed)
if debug: print hdrs_needed

# Need *geocentric* position of the observatory for the TDB clock 
# correction so we have to convert from the geodetic position given
# by a GPS.
(r,z) = sla_geoc_iers2003(hdrs_needed['OBS_LAT'], hdrs_needed['OBS_HGT'])

# Calculate relativistic clock correction (TDB-TT) and put into dictionary
tdb_tt = S.sla_rcc(hdrs_needed['MJD_TT_mid'], hdrs_needed['UT1'], 
    -hdrs_needed['OBS_ELONG'], r, z)
tdb_utc = hdrs_needed['TT-UTC'] + tdb_tt
if debug: print 'TDB-TT(RCC)=', tdb_tt
if debug: print 'TDB-UTC    =', tdb_utc
new_dict = { 'MJD_TDB_mid' : hdrs_needed['MJD_TT_mid'] + (tdb_tt/86400.0) }
hdrs_needed.update(new_dict)

#  Compute star-independent parameters in preparation for
#  conversions between mean place and geocentric apparent place.
amprms = S.sla_mappa(2000.0, hdrs_needed['MJD_TT_mid'])

# Reform into precession/nutation matrix
irmat = amprms[12:21].reshape(3,3)

# Earth's barycentric position (in AU) from sla_evp (max error 6900 km ~=23ms)
#pos_earth_bary = array([amprms[1],amprms[2],amprms[3]])