Exemple #1
0
class PrepfoldSigmaRater(base.BaseRater):
    short_name = "prepfoldsigma"
    long_name = "Prepfold Sigma Rating"
    description = "Re-compute the sigma value reported in the " \
                  "prepfold plots."
    version = 1
    
    rat_cls = profile.ProfileClass()

    def _compute_rating(self, cand):
        """Return a rating for the candidate. The rating value is 
            the prepfold sigma value.

            Input:
                cand: A Candidate object to rate.

            Output:
                value: The rating value.
        """
        prof = cand.time_vs_phase.get_profile()
        pfd = cand.pfd

        prof_avg = np.sum(pfd.stats[:,:,4][:pfd.npart])
        prof_var = np.sum(pfd.stats[:,:,5][:pfd.npart])
        chisqr = presto.chisqr(prof, pfd.proflen, prof_avg, prof_var)
        df = pfd.proflen - 1
        
        #print "DEBUG: prof_avg, prof_var, chisqr/df", prof_avg, prof_var, chisqr/df
        
        prob = sp.stats.chi2.sf(chisqr, df)
        sig = -sp.stats.norm.ppf(prob)
        return sig 
Exemple #2
0
class DutyCycleRater(base.BaseRater):
    short_name = "dutycycle"
    long_name = "Duty Cycle Rating"
    description = "Compute the duty cycle, that is, the fraction of " \
                  "profile bins in which the value is more than " \
                  "(max+median)/2."
    version = 4

    rat_cls = profile.ProfileClass()

    def _compute_rating(self, cand):
        """Return a rating for the candidate. The rating value is an 
            estimate of the profile's duty cycle.

            Input:
                cand: A Candidate object to rate.

            Output:
                value: The rating value.
        """
        profile = cand.get_from_cache('profile')
        nbin = float(len(profile))
        thresh = (np.amax(profile) + np.median(profile)) / 2.0
        dutycycle = np.sum(profile > thresh) / nbin
        return dutycycle
Exemple #3
0
class RescaledPrepfoldSigmaRater(base.BaseRater):
    short_name = "rescaledpfdsigma"
    long_name = "Rescaled Prepfold Sigma Rating"
    description = "Rescale the sigma value reported in the " \
                  "prepfold plots using a better estimate of" \
                  "the off-pulse chi-square."
    version = 1

    rat_cls = profile.ProfileClass()

    def _compute_rating(self, cand):
        """Return a rating for the candidate. The rating value is 
            the prepfold sigma value.

            Input:
                cand: A Candidate object to rate.

            Output:
                value: The rating value.
        """
        tvph = cand.get_from_cache('time_vs_phase')
        prof = tvph.get_profile()
        pfd = cand.get_from_cache('pfd')

        prof_avg = np.sum(pfd.stats[:, :, 4][:pfd.npart])
        prof_var = np.sum(pfd.stats[:, :, 5][:pfd.npart])
        #chisqr = presto.chisqr(prof, pfd.proflen, prof_avg, prof_var)
        # Below is adapted for presto v2.1
        chisqr = presto.chisqr(prof, prof_avg, prof_var)
        df = pfd.proflen - 1

        redchisqr = chisqr / df

        off_redchisqr = pfd.estimate_offsignal_redchi2()
        rescaled_redchisqr = redchisqr / off_redchisqr

        #print "DEBUG: prof_avg, prof_var, chisqr/df", prof_avg, prof_var, chisqr/df

        prob = sp.stats.chi2.sf(rescaled_redchisqr * df, df)
        sig = -sp.stats.norm.ppf(prob)
        return sig
Exemple #4
0
class PeakOverRMSRater(base.BaseRater):
    short_name = "peakoverrms"
    long_name = "Peak Over RMS Rating"
    description = "Compute the peak amplitude of the profile divided" \
                  "by the RMS amplitude. Specifically, compute " \
                  "(max(profile)-median(profile))/std(profile)."
    version = 3
    
    rat_cls = profile.ProfileClass()

    def _compute_rating(self, cand):
        """Return a rating for the candidate. The rating value is 
            the profile peak divided by its RMS.

            Input:
                cand: A Candidate object to rate.

            Output:
                value: The rating value.
        """
        prof = cand.get_from_cache('profile')
        return (np.amax(prof)-np.median(prof))/np.std(prof)
Exemple #5
0
class ubc_pfd_ai(base.BaseRater):
    short_name = "pfd_AI"
    long_name = "UBC pfd AI"
    description = "compute the prediction from the pulsar classifier " \
                  "based on pfd files."
    version = 5

    rat_cls = profile.ProfileClass()

    def _compute_rating(self, cand):
        """Return a rating for the candidate. The rating value is 
            the prepfold sigma value.

            Input:
                cand: A Candidate object to rate.

            Output:
                value: The rating value.
        """
        pfd_fn = cand.get_from_cache('pfd').pfd_filename

        pred = classifier.report_score([pfdreader(pfd_fn)])
        return pred