def load_pfds(dir=SAMPLE_FILES_DIR): SAMPLE_FILES = glob.glob(dir + '*.pfd') pfds = [] for f in SAMPLE_FILES: pf = pfd(f) pfds.append(pf) return pfds
def load_pfds(dir=SAMPLE_FILES_DIR): SAMPLE_FILES = glob.glob(dir+'*.pfd') pfds = [] for f in SAMPLE_FILES: pf = pfd(f) pfds.append(pf) return pfds
pfdfile = glob.glob('ubc_AI/pfd_files/*.pfd') + glob.glob('ubc_AI/pfd_files/*.ar') + glob.glob('ubc_AI/pfd_files/*.ar2') + glob.glob('ubc_AI/pfd_files/*.spd') timeout = time.time() + 60*15 # 15 minutes from now data = '' i=0 while True: if time.time() > timeout: break line = sys.stdin.readline() if line.strip() != 'eof': data += line continue else: with open('/dev/shm/test.pfd', 'wb') as f: f.write(data) data = '' Metadata = pfd('/dev/shm/test.pfd') print 'Name:',os.path.basename(os.path.normpath(pfdfile[i])) print 'Telescope:',Metadata.telescope print 'Barycentric Epoch:',Metadata.bepoch print 'Topocentric Epoch:',Metadata.tepoch print 'DM:',Metadata.bestdm print 'Period (topo):',Metadata.topo_p1 print 'Pdot (topo):',Metadata.topo_p2 print 'P\'\'(topo):',Metadata.topo_p3 print 'Period (bary):',Metadata.bary_p1 print 'Pdot (bary):',Metadata.bary_p2 print 'Eccentricity:',Metadata.orb_e print 'Orbital period:',Metadata.orb_p print ' ' sys.stdout.flush() time.sleep(1)
import matplotlib.pyplot as plt from scipy.interpolate import RectBivariateSpline as interp from scipy import ndimage, array, ogrid, mgrid import sys,os if __name__ == '__main__': f1 = sys.argv[1] f2 = sys.argv[2] if not (f1.endswith('pfd')): print 'file name %s not end with pfd ' % (f1) sys.exit(1) pfdfile = pfd(f1) pfdfile.dedisperse() profs = pfdfile.profs pshape = profs.shape x, y, z = profs.shape data = profs.reshape((-1,1)) del pfdfile mean = np.mean(data) var = np.std(data) data = (data-mean)/var profs = data.reshape(pshape) X, Y, Z = ogrid[0:1:x,0:1:y,0:1:z] coords = array([X, Y, Z]) coeffs = ndimage.spline_filter(profs ) X, Y, Z = mgrid[0:1:8j,0:1:8j,0:1:8j]