コード例 #1
0
ファイル: sum_profiles.py プロジェクト: ariofrio/presto
def measure_phase(profile, template):
    """
    measure_phase(profile, template):
        Call FFTFIT on the profile and template to determine the
            following parameters: shift,eshift,snr,esnr,b,errb,ngood
            (returned as a tuple).  These are defined as in Taylor's
            talk at the Royal Society.
    """
    c,amp,pha = fftfit.cprof(template)
    pha1 = pha[0]
    pha = Num.fmod(pha-Num.arange(1,len(pha)+1)*pha1,TWOPI)
    shift,eshift,snr,esnr,b,errb,ngood = fftfit.fftfit(profile,amp,pha)
    return shift,eshift,snr,esnr,b,errb,ngood
コード例 #2
0
ファイル: sum_profiles.py プロジェクト: matteobachetti/presto
def measure_phase(profile, template):
    """
    measure_phase(profile, template):
        Call FFTFIT on the profile and template to determine the
            following parameters: shift,eshift,snr,esnr,b,errb,ngood
            (returned as a tuple).  These are defined as in Taylor's
            talk at the Royal Society.
    """
    c, amp, pha = fftfit.cprof(template)
    pha1 = pha[0]
    pha = Num.fmod(pha - Num.arange(1, len(pha) + 1) * pha1, TWOPI)
    shift, eshift, snr, esnr, b, errb, ngood = fftfit.fftfit(profile, amp, pha)
    return shift, eshift, snr, esnr, b, errb, ngood
コード例 #3
0
 def _measure_phase(self, profile, template, rotate_prof=True):
     """
     measure_phase(profile, template):
         Call FFTFIT on the profile and template to determine the
             following parameters: shift,eshift,snr,esnr,b,errb,ngood
             (returned as a tuple).  These are defined as in Taylor's
             talk at the Royal Society.
     """
     c, amp, pha = fftfit.cprof(template)
     print "template", template
     pha1 = pha[0]
     if (rotate_prof):
         pha = np.fmod(pha - np.arange(1, len(pha) + 1) * pha1, 2.0 * np.pi)
     print "profile", len(profile), profile
     print "amp", amp
     print "pha ", pha
     shift, eshift, snr, esnr, b, errb, ngood = fftfit.fftfit(
         profile, amp, pha)
     if 0:
         c2, amp2, pha2 = fftfit.cprof(profile)
         pl.ion()
         pl.figure(1)
         pl.title('Amplitudes')
         pl.plot(amp / amp.sum())
         pl.plot(amp2 / amp2.sum())
         pl.figure(2)
         pl.title('Phases')
         pl.plot(pha)
         pl.plot(pha2)
         pl.figure(3)
         #pl.title('Profile')
         pl.plot(profile / profile.sum())
         pl.plot(template / template.sum())
         pl.draw()
         tmp = raw_input()
         pl.close('all')
         print "shift, eshift, snr = ", shift, eshift, snr
     return shift, eshift, snr, esnr, b, errb, ngood
コード例 #4
0
ファイル: event_optimize.py プロジェクト: limyansky/PINT
def measure_phase(profile, template, rotate_prof=True):
    """
    measure_phase(profile, template):
        Call FFTFIT on the profile and template to determine the
            following parameters: shift,eshift,snr,esnr,b,errb,ngood
            (returned as a tuple).  These are defined as in Taylor's
            talk at the Royal Society.
    """
    import fftfit
    c, amp, pha = fftfit.cprof(template)
    pha1 = pha[0]
    if (rotate_prof):
        pha = np.fmod(pha - np.arange(1, len(pha) + 1) * pha1, 2.0 * np.pi)
    shift, eshift, snr, esnr, b, errb, ngood = fftfit.fftfit(profile, amp, pha)
    return shift, eshift, snr, esnr, b, errb, ngood
コード例 #5
0
ファイル: dissect.py プロジェクト: susmitasett/pypulsar
def measure_phase(profile, template):
    """Call FFTFIT on the profile and template to determine the
        following parameters: shift,eshift,snr,esnr,b,errb,ngood
        (returned as a tuple).  These are defined as in Taylor's
        talk at the Royal Society.

        pha1, the amount the template is rotated by (in radians)
        is also returned, in addition to the values mentioned
        above. pha1 is the last element in the tuple.
    """
    # This code is taken from Scott Ransom's PRESTO's get_TOAs.py
    c,amp,pha = fftfit.cprof(template)
    pha1 = pha[0]
    # Rotate the template
    pha = np.fmod(pha-np.arange(1,len(pha)+1)*pha1, 2.0*np.pi)
    shift,eshift,snr,esnr,b,errb,ngood = fftfit.fftfit(profile,amp,pha)
    return shift,eshift,snr,esnr,b,errb,ngood,pha1
コード例 #6
0
ファイル: test_fftfit.py プロジェクト: matteobachetti/presto
from __future__ import print_function
#>>> print fftfit.__doc__
#This module 'fftfit' is auto-generated with f2py (version:2.13.175-1250).
#Functions:
#  zbrent = zbrent(x1,x2,f1,f2,tol,tmp,pha,nsum)
#  dchisqr = dchisqr(tau,tmp,r,nsum)
#  cprof(y,c,amp,pha,nmax=len(y),nh=(len(c)-1))
#  fccf(amp,pha,shift)
#  ffft(d,npts,isign,ireal)
#  fftfit(prof,s,phi,nmax,shift,eshift,snr,esnr,b,errb,ngood)

import numpy as num
from psr_utils import gaussian_profile, TWOPI
from fftfit import cprof, fftfit

template = gaussian_profile(64, 0.5, 0.1)
c, amp, pha = cprof(template)
#pha.savespace()
pha1 = pha[0]
pha = num.fmod(pha - num.arange(1, len(pha) + 1) * pha1, TWOPI)
for phs in [0.1, 0.3, 0.7]:
    prof = gaussian_profile(64, phs, 0.1) + num.random.standard_normal(64)
    shift, eshift, snr, esnr, b, errb, ngood = fftfit(prof, amp, pha)
    print("True phs = %f, measured phs = %f +/- %f" %
          (phs, shift / len(prof), eshift / len(prof)))
コード例 #7
0
ファイル: test_fftfit.py プロジェクト: matteobachetti/presto
from __future__ import print_function
#>>> print fftfit.__doc__
#This module 'fftfit' is auto-generated with f2py (version:2.13.175-1250).
#Functions:
#  zbrent = zbrent(x1,x2,f1,f2,tol,tmp,pha,nsum)
#  dchisqr = dchisqr(tau,tmp,r,nsum)
#  cprof(y,c,amp,pha,nmax=len(y),nh=(len(c)-1))
#  fccf(amp,pha,shift)
#  ffft(d,npts,isign,ireal)
#  fftfit(prof,s,phi,nmax,shift,eshift,snr,esnr,b,errb,ngood)

import numpy as num
from psr_utils import gaussian_profile, TWOPI
from fftfit import cprof, fftfit

template = gaussian_profile(64, 0.5, 0.1)
c,amp,pha = cprof(template)
#pha.savespace()
pha1 = pha[0]
pha = num.fmod(pha-num.arange(1,len(pha)+1)*pha1,TWOPI)
for phs in [0.1, 0.3, 0.7]:
    prof = gaussian_profile(64, phs, 0.1)+num.random.standard_normal(64)
    shift,eshift,snr,esnr,b,errb,ngood = fftfit(prof,amp,pha)
    print("True phs = %f, measured phs = %f +/- %f" % (phs, shift/len(prof),eshift/len(prof)))