def parse_eph(filenm): global period, time suffix = filenm.split(".")[-1] if suffix == "bestprof": x = bestprof.bestprof(filenm) fs = pu.p_to_f(x.p0_bary, x.p1_bary, x.p2_bary) epoch = x.epochi_bary + x.epochf_bary T = x.T elif suffix == "par": x = parfile.psr_par(filenm) # Try to see how many freq derivs we have fs = [x.F0] for ii in range(1, 20): # hopefully 20 is an upper limit! attrib = "F%d" % ii if hasattr(x, attrib): fs.append(getattr(x, attrib)) else: break epoch = x.PEPOCH T = (x.FINISH - x.START) * 86400.0 else: print("I don't recognize the file type for", filenm) sys.exit() newts = epoch + num.arange(int(T / 10.0 + 0.5), dtype=num.float) / 8640.0 time = num.concatenate((time, newts)) newps = 1.0 / pu.calc_freq(newts, epoch, *fs) period = num.concatenate((period, newps)) print("%13.7f (%0.1f sec): " % (epoch, T), fs)
def plot_file_panel(in_file, params): period = [] time = [] if in_file.endswith('.par'): (epoch, T, fs) = read_par(in_file) for minute in arange(int(T / 60.0 + 0.5)): t = minute / 1440.0 time.append(t) period.append(1.0 / psr_utils.calc_freq(epoch + t, epoch, *fs)) else: (epoch, T, p0, p1, p2) = read_bestprof(in_file) for minute in arange(int(T / 60.0 + 0.5)): t = minute * 60.0 time.append(minute / 1440.0) period.append(p0 + t * (p1 + 0.5 * t * p2)) print("Plotting: file, epoch, Tobs", in_file, epoch, T) period = asarray(period) time = asarray(time) plot(time, period * 1000.0, 'o') xlabel('Time (s)') ylabel('Period (ms)') title("%.3f" % (epoch, )) model_time = arange(epoch - 0.1, epoch + max(time) + 0.1, 0.001) plot(model_time - epoch, doppler_period(params, model_time) * 1000.0, 'r')
pepochs = [] p0s = [] p1s = [] # get the observed periods and times from the .bestprof files for in_file in in_files: if in_file.endswith('.par'): (epoch, T, fs) = read_par(in_file) if (fs[1] != 0.0): p0tmp, p1tmp = psr_utils.p_to_f(fs[0], fs[1]) p0s.append(p0tmp) p1s.append(p1tmp) pepochs.append(epoch) for minute in arange(int(T / 60.0 + 0.5)): t = epoch + minute / 1440.0 time.append(t) period.append(1.0 / psr_utils.calc_freq(t, epoch, *fs)) else: (epoch, T, p0, p1, p2) = read_bestprof(in_file) for minute in arange(int(T / 60.0 + 0.5)): t = minute * 60.0 time.append(epoch + minute / 1440.0) period.append(p0 + t * (p1 + 0.5 * t * p2)) if p1 != 0.0: p0s.append(p0) p1s.append(p1) pepochs.append(epoch) Torb = min(time) period = asarray(period) time = asarray(time) p0s = asarray(p0s)
# # Calculate the TOAs # if t2format: print("FORMAT 1") for ii in range(numtoas): # The .pfd file was generated using -nosearch and a specified # folding period, p-dot, and p-dotdot (or f, f-dot, and f-dotdot). if (pcs is None): # Time at the middle of the interval in question midtime = fold.epoch + (ii+0.5)*timestep_day p = 1.0/psr_utils.calc_freq(midtime, fold.epoch, fold.f0, fold.f1, fold.f2) t0 = psr_utils.calc_t0(midtime, fold.epoch, fold.f0, fold.f1, fold.f2) t0i= int(t0 + 1e-9) t0f = t0 - t0i # The .pfd file was folded using polycos else: # Time at the middle of the interval in question mjdf = fold.epochf + (ii+0.5)*timestep_day (phs, f0) = pcs.get_phs_and_freq(fold.epochi, mjdf) phs -= fold.phs0 p = 1.0/f0 if (phs < 0.0): phs += 1.0 # Consistent with pat t0f = mjdf - phs*p/SECPERDAY t0i = fold.epochi for jj in range(numsubbands):