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 in (approximate) us: 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')
ss = s.split() parname = ss[0] if s.startswith("DMXR"): irange = int(ss[0].split("_")[-1]) if not irange in dmxr: dmxr[irange] = [0., 0.] parval = float(ss[1].replace("D", "E")) if s.startswith("DMXR1"): dmxr[irange][0] = parval elif s.startswith("DMXR2"): dmxr[irange][1] = parval fpar.close() # read in the MJDs and INFO flags toas = tempo_utils.read_toa_file(timfile) # loop through the MJDs and INFO flags, # develop a list of INFO strings, # and accumulate the number of TOAs in # each DMX range segretaged by INFO string. infolist = [] orphans = [] norange = [] dmxn = {} for k in dmxr: dmxn[k] = [] for t in toas: