def getEarthPosition(jd_tdb): """ The input time should be on the TDB time scale. TT - TDB is less than 2 milliseconds. Returns equatorial rectangular coordinates in AU referred to the ICRS. """ pos, _ = solsys.solarsystem(jd_tdb, 3, 1) return pos
def make_posn_plots(theta, MJDs, ras, decs, ra_errs, dec_errs, posepoch, psr, filebase=None): ra, dec, pmra, pmdec, px, Omega, inc = theta refpos = coords.SkyCoord(ra=ra*u.rad, dec=dec*u.rad, frame='icrs') modelMJDs = np.linspace(MJDs.min()-20.0, MJDs.max()+20.0, 100) model_eposns = [solsys.solarsystem(mjd+2400000.5, 3, 0)[0] \ for mjd in modelMJDs] model_nopsr = [posn_with_pmpx(ra*u.rad, dec*u.rad, pmra, pmdec, px, mjd, posepoch, ep, dRAother=0.0*u.rad, dDECother=0.0*u.rad) for mjd, ep in zip(modelMJDs, model_eposns)] # Compute the reflex motion from the outer orbit model_pdRAs, model_pdDECs = psr.reflex_motion(modelMJDs, inc, Omega, 1.0/px) pdRAs, pdDECs = psr.reflex_motion(baryMJDs, inc, Omega, 1.0/px) model_psr = [posn_with_pmpx(ra*u.rad, dec*u.rad, pmra, pmdec, px, mjd, posepoch, ep, dRAother=dra, dDECother=ddec) for mjd, ep, dra, ddec in \ zip(modelMJDs, model_eposns, model_pdRAs*u.mas, model_pdDECs*u.mas)] cosd = np.cos(refpos.dec) plt.plot(modelMJDs, [((x[0] - refpos.ra)*cosd).to(u.mas).value for x in model_nopsr], 'k-', label="No reflex motion") plt.plot(modelMJDs, [((x[0] - refpos.ra)*cosd).to(u.mas).value for x in model_psr], 'r-', label="With reflex motion") plt.errorbar(baryMJDs, ((ras - refpos.ra)*cosd).to(u.mas).value, yerr=ra_errs.to(u.mas).value, fmt='.', label="Measurements") plt.ylabel("RA - %s (mas)" % \ refpos.ra.to_string(unit=u.hour, sep='hms', format='latex', pad=True)) plt.xlabel("MJD") #plt.legend(loc=4) plt.legend() if filebase is not None: plt.savefig(filebase+"_RA.png") plt.close() else: plt.show() plt.plot(modelMJDs, [(x[1] - refpos.dec).to(u.mas).value for x in model_nopsr], 'k-', label="No reflex motion") plt.plot(modelMJDs, [(x[1] - refpos.dec).to(u.mas).value for x in model_psr], 'r-', label="With reflex motion") plt.errorbar(baryMJDs, (decs - refpos.dec).to(u.mas).value, yerr=dec_errs.to(u.mas).value, fmt='.', label="Measurements") plt.ylabel("DEC - %s (mas)" % \ refpos.dec.to_string(unit=u.deg, sep='dms', format='latex', pad=True)) plt.xlabel("MJD") #plt.legend(loc=1) plt.legend() if filebase is not None: plt.savefig(filebase+"_DEC.png") plt.close() else: plt.show()
def getEarthBaryPosition(jd_tdb): pos, _ = solsys.solarsystem(jd_tdb, 3, 0) return pos
ra = initvals['ra'] dec = initvals['dec'] posstring = ra + " " + dec except KeyError as e: print "Missing required key ", str(e), " in ", initsfile sys.exit() start_pos = coords.SkyCoord(posstring, unit=(u.hourangle, u.deg), frame='icrs') psr = bp.binary_psr(parfile) # Get the measurements and convert them to arrays of angles vlbiepoch, posns, ra_errs, dec_errs, baryMJDs = get_coords(pmparfile) # This is the Earth position in X, Y, Z (AU) in ICRS wrt SSB eposns = [solsys.solarsystem(mjd+2400000.5, 3, 0)[0] \ for mjd in baryMJDs] errs = np.concatenate((ra_errs.to(u.rad).value, dec_errs.to(u.rad).value)) # in radians ras = np.asarray([pos.ra.rad for pos in posns]) * u.rad decs = np.asarray([pos.dec.rad for pos in posns]) * u.rad meas = np.concatenate((ras, decs)) # in radians try: pmrasigma = float(initvals['pmra_sigma']) pmdecsigma = float(initvals['pmdec_sigma']) pxsigma = float(initvals['px_sigma']) Omegasigma = float(initvals['Omega_sigma']) incsigma = float(initvals['inc_sigma']) rasigma = (float(initvals['ra_sigma'])*u.mas).to(u.rad).value