def main():
    import rating
    import harmonic_rating
    import pfd_ratings
    import profile_ratings
    import gaussian_ratings

    if options.where is not None:
        print "Using 'where clause':", options.where 

    D = rating.usual_database()
    rating.run(D,
               [gaussian_ratings.GaussianWidth(D), 
                gaussian_ratings.GaussianHeight(D), 
                gaussian_ratings.GaussianPhase(D), 
                gaussian_ratings.GaussianSignificance(D), 
                harmonic_rating.HarmonicRating(D), 
                profile_ratings.DutyCycle(D), 
                profile_ratings.PrepfoldSigmaRating(D), 
                pfd_ratings.RatioRating(D), 
                pfd_ratings.RatioRatingPeak(D), 
               ],
              where_clause=options.where,
              scramble=options.scramble,
              limit=options.n)
Exemple #2
0
	# Un-dedispersed profile        
        p0 = pfd.time_vs_phase().sum(axis=0)
        p1 = profile_ratings.get_profile(cache, pfd)
        return np.std(p0)/np.std(p1)


class RatioRatingPeak(rating.DatabaseRater):
    def __init__(self,DBconn):
        rating.DatabaseRater.__init__(self,DBconn,version=5,
            name="Ratio Rating Peak",
            description="""Compare DM 0 and "best" DM

Computes the ratio of peak height for the profile dedispersed at
DM 0 divided by that for the profile dedispersed at the best-fit DM.
""",
            with_files=True)

    def rate_candidate(self, hdr, candidate, pfd, cache=None):
        
        p0 = pfd.time_vs_phase().sum(axis=0)
        p1 = profile_ratings.get_profile(cache, pfd)

        return (np.amax(p0)-np.median(p0))/(np.amax(p1)-np.median(p1))


if __name__=='__main__':
    D = rating.usual_database()
    rating.run(D, 
               [RatioRating(D),
               ])
Exemple #3
0
""")

    def rate_profile(self,hdr,candidate,profile,std,cache):
        return (np.amax(profile)-np.median(profile))/np.std(profile)

class PrepfoldSigmaRating(ProfileRating):
    def __init__(self, DBconn):
	rating.DatabaseRater.__init__(self, DBconn, \
	    version = 5, \
	    name = "Prepfold Sigma", \
	    description = "A re-calculation of the sigma value reported on " \
			  "prepfold plots.\n\nCandidates where P(noise) ~ 0 " \
			  "are rated as 99 since a proper sigma value " \
			  "cannot be computed.", \
	    with_files = True, \
	    with_bestprof = False)

    def rate_profile(self, hdr, candidate, profile, std, cache):
        chi2 = np.sum((profile-np.mean(profile))**2/std**2)
        df = len(profile)-1

	return min(-scipy.stats.norm.ppf(scipy.stats.chi2(df).sf(chi2)),99)

if __name__=='__main__':
    D = rating.usual_database()
    rating.run(D,
               [DutyCycle(D), 
                PeakOverRMS(D),
               ])

!#/usr/bin/env python

"""
Copy pfd files to McGill.

Patrick Lazarus, Oct. 25, 2010
"""

import rating

def main()
    import upload_rating
    D = rating.usual_database()
    rating.run(D, [upload_rating.SharePfdRating(D)])

if __name__ == '__main__':
    main()
def main():
    import upload_rating
    D = rating.usual_database()
    rating.run(D, [upload_rating.UploadRating(D)])
Exemple #6
0
""")

    def rate_gaussian_profile(self,hdr,candidate,profile,std,G,cache):
        return G.mu

class GaussianSignificance(GaussianRating):
    def __init__(self, DBconn):
        GaussianRating.__init__(self, DBconn,
            "Gaussian Sig",
            2,
            """Compute the significance of the best-fit Gaussian.

            The function being fit is not actually a Gaussian, it's a von Mises
            distribution (exp(k*cos(theta))). This compares the Gaussian height
            to the expected standard deviation of an average over the 
            Gaussian width.

""")

    def rate_gaussian_profile(self,hdr,candidate,profile,std,G,cache):
        return G.amplitude(len(profile))/(std/max(G.fwhm()/(1./len(profile)),1)**(0.5))

if __name__=='__main__':
    D = rating.usual_database()
    rating.run(D, [
        GaussianHeight(D),
        GaussianWidth(D),
        GaussianPhase(D),
        ])

Exemple #7
0
n = 10
base_f = 60.

class HarmonicRating(rating.DatabaseRater):
    def __init__(self,DBconn):
        rating.DatabaseRater.__init__(self,DBconn,version=version,
            name="Harmonic Rating",
            description="""Evaluate how close the topocentric frequency is to a harmonic or subharmonic of 60 Hz.

Considers all frequencies 60 Hz * a/b where a and b are integers adding up
to less than 10. The fractional difference between the candidate's frequency
and this frequency is computed, and an exponential is taken so that the
result lies between zero and one, reaching 1/2 at a tenth of a percent.
""",
            with_files=False)

    def rate_candidate(self, hdr, candidate, file=None, cache=None):
        f = candidate["frequency"]
        fdiff_min = 1e10
        for a in range(1,9):
            for b in range(1,10-a):
                rf = (base_f * a)/b
                fdiff = 2*abs(f-rf)/(f+rf)
                fdiff_min = min(fdiff,fdiff_min)
        return 2.**(-fdiff_min/1e-3)


if __name__=='__main__':
    D = rating.usual_database()
    rating.run(D, [HarmonicRating(D)])