def read_bestprof(proffile): prof = profdat() infile = open(proffile) for line in infile.readlines(): startline = line[:22] if (startline == "# Epoch_topo = "): if not (line[22:25] == "N/A"): profdat.MJD_topo = float(line[22:]) elif (startline == "# Epoch_bary (MJD) = "): if not (line[22:25] == "N/A"): profdat.MJD_bary = float(line[22:]) elif (startline == "# T_sample = "): profdat.dt = float(line[22:]) elif (startline == "# Data Folded = "): profdat.N = int(line[22:]) elif (startline == "# Profile Bins = "): profdat.proflen = int(line[22:]) elif (startline == "# Profile Avg = "): profdat.profavg = float(line[22:]) elif (startline == "# Profile StdDev = "): profdat.profstd = float(line[22:]) elif (startline == "# P_topo (ms) = "): if not (line[22:25] == "N/A"): profdat.p_topo = float(line[22:40]) / 1000.0 profdat.p_topo_err = float(line[43:]) / 1000.0 elif (startline == "# P'_topo (s/s) = "): if not (line[22:25] == "N/A"): profdat.pd_topo = float(line[22:40]) profdat.pd_topo_err = float(line[43:]) elif (startline == "# P_bary (ms) = "): if not (line[22:25] == "N/A"): profdat.p_bary = float(line[22:40]) / 1000.0 profdat.p_bary_err = float(line[43:]) / 1000.0 elif (startline == "# P'_bary (s/s) = "): if not (line[22:25] == "N/A"): profdat.pd_bary = float(line[22:40]) profdat.pd_bary_err = float(line[43:]) elif (startline == "# P_orb (s) = "): if not (line[22:25] == "N/A"): profdat.porb = float(line[22:]) elif (startline == "# asin(i)/c (s) = "): if not (line[22:25] == "N/A"): profdat.xorb = float(line[22:]) elif (startline == "# eccentricity = "): if not (line[22:25] == "N/A"): profdat.eorb = float(line[22:]) elif (startline == "# w (rad) = "): if not (line[22:25] == "N/A"): profdat.worb = float(line[22:]) elif (startline == "# T_peri = "): if not (line[22:25] == "N/A"): profdat.torb = float(line[22:]) elif (startline == "######################"): break infile.close() profdat.profile = readColumns(proffile, "#")[1] return profdat
def read_bestprof(proffile): prof = profdat() infile = open(proffile) for line in infile.readlines(): startline = line[:22] if (startline == "# Epoch_topo = "): if not (line[22:25] == "N/A"): profdat.MJD_topo = float(line[22:]) elif (startline == "# Epoch_bary (MJD) = "): if not (line[22:25] == "N/A"): profdat.MJD_bary = float(line[22:]) elif (startline == "# T_sample = "): profdat.dt = float(line[22:]) elif (startline == "# Data Folded = "): profdat.N = int(line[22:]) elif (startline == "# Profile Bins = "): profdat.proflen = int(line[22:]) elif (startline == "# Profile Avg = "): profdat.profavg = float(line[22:]) elif (startline == "# Profile StdDev = "): profdat.profstd = float(line[22:]) elif (startline == "# P_topo (ms) = "): if not (line[22:25] == "N/A"): profdat.p_topo = float(line[22:40])/1000.0 profdat.p_topo_err = float(line[43:])/1000.0 elif (startline == "# P'_topo (s/s) = "): if not (line[22:25] == "N/A"): profdat.pd_topo = float(line[22:40]) profdat.pd_topo_err = float(line[43:]) elif (startline == "# P_bary (ms) = "): if not (line[22:25] == "N/A"): profdat.p_bary = float(line[22:40])/1000.0 profdat.p_bary_err = float(line[43:])/1000.0 elif (startline == "# P'_bary (s/s) = "): if not (line[22:25] == "N/A"): profdat.pd_bary = float(line[22:40]) profdat.pd_bary_err = float(line[43:]) elif (startline == "# P_orb (s) = "): if not (line[22:25] == "N/A"): profdat.porb = float(line[22:]) elif (startline == "# asin(i)/c (s) = "): if not (line[22:25] == "N/A"): profdat.xorb = float(line[22:]) elif (startline == "# eccentricity = "): if not (line[22:25] == "N/A"): profdat.eorb = float(line[22:]) elif (startline == "# w (rad) = "): if not (line[22:25] == "N/A"): profdat.worb = float(line[22:]) elif (startline == "# T_peri = "): if not (line[22:25] == "N/A"): profdat.torb = float(line[22:]) elif (startline == "######################"): break infile.close() profdat.profile = readColumns(proffile, "#")[1] return profdat
from TableIO import readColumns from presto import spectralpower from periodogram import * from time import clock file = 'rosat_crab_3k.toa' toas = ravel(readColumns(file, '#')) toas = (toas - toas[0]) * 86400.0 T = toas[-1] - toas[0] df = 1.0 / (10.0 * T) p0 = 0.033468239225/2 numf = 100000 lof = 1.0 / p0 - df * numf / 2.0 freqs = arange(numf) * df + lof beg = clock() mypows = spectralpower(toafft(toas, len(toas), lof, df, numf)) end = clock() print ' TOAFFT took ', end-beg, ' sec. (%d freqs/sec)' % (numf/(end-beg)) beg = clock() pows = periodogram(ones(len(toas), 'd'), toas, len(toas), lof, df, numf) end = clock() print 'periodogram took ', end-beg, ' sec. (%d freqs/sec)' % (numf/(end-beg)) def toafft(toas, freqs, days=0): if days: toas = (toas - toas[0]) * 86400.0 else: toas = toas - toas[0] twid = zeros(len(freqs), 'D') twid.imag = -2.0 * pi * freqs