def get_tempo_result(parfile, timfile): """This function is to get the results from tempo and write them to a file. Parameter --------- parfile : str The file to read parameters. timfile : str The file to read toas. Return ---------- A file named as parfile name ends with '.tempo_test' stored residuals in the first column """ t1_toas = t1u.read_toa_file(timfile) t1u.run_tempo(t1_toas, parfile) t1_resids = t1_toas.get_resids(units='phase') outfile = parfile + '.tempo_test' f = open(outfile, 'w') outstr = 'residuals_phase ' outstr += '\n' f.write(outstr) for res in t1_resids: outstr = longdouble2string(res) + '\n' f.write(outstr) f.close()
resids_us = resids / float(m.F0.value) * 1e6 sys.stderr.write("RMS PINT residuals are %.3f us\n" % resids_us.std()) # Get some general2 stuff tempo2_vals = tempo2_utils.general2(parfile, timfile, ['tt2tb', 'roemer', 'post_phase', 'shapiro', 'shapiroJ']) t2_resids = tempo2_vals['post_phase'] / float(m.F0.value) * 1e6 diff_t2 = resids_us - t2_resids diff_t2 -= diff_t2.mean() # run tempo1 also, if the tempo_utils module is available try: import tempo_utils t1_toas = tempo_utils.read_toa_file(timfile) tempo_utils.run_tempo(t1_toas, t1_parfile) t1_resids = t1_toas.get_resids(units='phase') / float(m.F0.value) * 1e6 diff_t1 = resids_us - t1_resids diff_t1 -= diff_t1.mean() diff_t2_t1 = t2_resids - t1_resids diff_t2_t1 -= diff_t2_t1.mean() except: pass def do_plot(): plt.clf() plt.subplot(211) plt.hold(False) plt.errorbar(mjds,resids_us,errs,fmt=None,label='PINT') plt.title("J1744-1134 GBT/GASP timing")
resids_us = resids / float(m.F0.value) * 1e6 sys.stderr.write("RMS PINT residuals are %.3f us\n" % resids_us.std()) # Get some general2 stuff tempo2_vals = tempo2_utils.general2( parfile, timfile, ['tt2tb', 'roemer', 'post_phase', 'shapiro', 'shapiroJ']) t2_resids = tempo2_vals['post_phase'] / float(m.F0.value) * 1e6 diff_t2 = resids_us - t2_resids diff_t2 -= diff_t2.mean() # run tempo1 also, if the tempo_utils module is available try: import tempo_utils t1_toas = tempo_utils.read_toa_file(timfile) tempo_utils.run_tempo(t1_toas, t1_parfile) t1_resids = t1_toas.get_resids(units='phase') / float(m.F0.value) * 1e6 diff_t1 = resids_us - t1_resids diff_t1 -= diff_t1.mean() diff_t2_t1 = t2_resids - t1_resids diff_t2_t1 -= diff_t2_t1.mean() except: pass def do_plot(): plt.clf() plt.subplot(211) plt.hold(False) plt.errorbar(mjds, resids_us, errs, fmt=None, label='PINT') plt.title("J1744-1134 GBT/GASP timing")