Exemple #1
0
def run(pop,
        surveyList, 
        nostdout=False, 
        allsurveyfile=False,
        scint=False):
    """ Run the surveys and detect the pulsars."""

    # print the population
    if not nostdout:
        print "Running doSurvey on population..."
        print pop

    # loop over the surveys we want to run on the pop file
    surveyPops = []
    for surv in surveyList:
        s = Survey(surv)
        s.discoveries = 0
        if not nostdout:
            print "\nRunning survey {0}".format(surv)

        # create a new population object to store discovered pulsars in 
        survpop = Population()
        # HERE SHOULD INCLUDE THE PROPERTIES OF THE ORIGINAL POPULATION
        
        # counters 
        nsmear = 0
        nout = 0
        ntf = 0
        ndet = 0
        # loop over the pulsars in the population list
        for psr in pop.population:
            # pulsar could be dead (evolve!) - continue if so
            if psr.dead:
                continue

            # is the pulsar over the detection threshold?
            snr = s.SNRcalc(psr, pop)

            # add scintillation, if required
            # modifying S/N rather than flux is sensible because then
            # a pulsar can have same flux but change S/N in repeated surveys
            if scint:
                snr = s.scint(psr, snr)

            if snr > s.SNRlimit:
                ndet += 1
                psr.snr = snr
                survpop.population.append(psr)
                
                # check if the pulsar has been detected in other 
                # surveys
                if not psr.detected:
                    # if not, set to detected and increment
                    # number of discoveries by the survey
                    psr.detected = True
                    s.discoveries += 1

            elif snr == -1.0:
                nsmear += 1
            elif snr == -2.0:
                nout += 1
            else:
                ntf += 1

        # report the results
        if not nostdout:
            print "Number detected by survey {0} = {1}".format(surv,ndet)
            print "Of which are discoveries = {0}".format(s.discoveries)
            print "Number too faint = {0}".format(ntf)
            print "Number smeared = {0}".format(nsmear)
            print "Number out = {0}".format(nout)
            print "\n"

        d = Detections(ndet=ndet, 
                       ntf=ntf, 
                       nsmear=nsmear, 
                       nout=nout,
                       ndisc=s.discoveries)
        surveyPops.append([surv,survpop,d])

    if allsurveyfile:
        allsurvpop = Population()
        allsurvpop.population = [psr for psr in pop.population if psr.detected]
        surveyPops.append([None, allsurvpop, None])

    return surveyPops
def run(pop,
        surveyList,
        nostdout=False,
        allsurveyfile=False,
        scint=False,
        accelsearch=False,
        jerksearch=False,
        rratssearch=False):
    """ Run the surveys and detect the pulsars."""

    # print the population
    if not nostdout:
        print "Running doSurvey on population..."
        print pop

    # loop over the surveys we want to run on the pop file
    surveyPops = []
    for surv in surveyList:
        s = Survey(surv)
        s.discoveries = 0
        if not nostdout:
            print "\nRunning survey {0}".format(surv)

        # create a new population object to store discovered pulsars in
        survpop = Population()
        # HERE SHOULD INCLUDE THE PROPERTIES OF THE ORIGINAL POPULATION

        # counters
        nsmear = 0
        nout = 0
        ntf = 0
        ndet = 0
        nbr = 0
        # loop over the pulsars in the population list
        for psr in pop.population:
            # pulsar could be dead (evolve!) - continue if so
            if psr.dead:
                continue

            # is the pulsar over the detection threshold?
            snr = s.SNRcalc(psr, pop, accelsearch, jerksearch, rratssearch)
            #print snr
            ######################################################################################
            #This section is to add in degradation due to orbital motion of DNS pulsars.
            #Remove this if doing literally anything else.
            #Right now this is very ad-hoc and manual. Optimization possible, maybe not worth right now.
            deg_fac_1102 = {
                'PALFA_one_v_older': 0.9997,
                'PHSURV': 0.9997,
                'HTRU_low_1757': 0.9912,
                '1534_survey': 0.9999,
                'PMSURV': 0.4649
            }  #This is for 1913+1102
            deg_fac_1913 = {
                'PALFA_one_v_older': 0.9953,
                'PHSURV': 0.9956,
                'HTRU_low_1757': 0.9569,
                '1534_survey': 0.9999,
                'PMSURV': 0.7915
            }
            deg_fac_1946 = {
                'PALFA_one_v_older': 0.9514,
                'PHSURV': 0.9543,
                'HTRU_low_1757': 0.6513,
                '1534_survey': 0.9999,
                'PMSURV': 0.2368
            }
            deg_fac_1757 = {
                'PALFA_one_v_older': 0.9710,
                'PHSURV': 0.9716,
                'HTRU_low_1757': 0.9255,
                '1534_survey': 0.9999,
                'PMSURV': 0.5080
            }
            deg_fac_1534 = {
                'PALFA_one_v_older': 0.9999,
                'PHSURV': 0.9999,
                'HTRU_low_1757': 0.9994,
                '1534_survey': 0.9999,
                'PMSURV': 0.7759
            }
            deg_fac_0737A = {
                'PALFA_one_v_older': 0.9910,
                'PHSURV': 0.9916,
                'HTRU_low_1757': 0.8371,
                '1534_survey': 0.9999,
                'PMSURV': 0.2991
            }
            deg_fac_0737B = {
                'PALFA_one_v_older': 0.9999,
                'PHSURV': 0.9999,
                'HTRU_low_1757': 0.9999,
                '1534_survey': 0.9999,
                'PMSURV': 1
            }
            deg_fac_1756 = {
                'PALFA_one_v_older': 0.9999,
                'PHSURV': 0.9999,
                'HTRU_low_1757': 0.9982,
                '1534_survey': 0.9999,
                'PMSURV': 0.5598
            }
            deg_fac_1906 = {
                'PALFA_one_v_older': 0.9999,
                'PHSURV': 0.9999,
                'HTRU_low_1757': 0.9994,
                '1534_survey': 0.9999,
                'PMSURV': 0.7337
            }

            snr = snr * (deg_fac_1913[surv]**2
                         )  #Please change this for each DNS
            ######################################################################################
            # add scintillation, if required
            # modifying S/N rather than flux is sensible because then
            # a pulsar can have same flux but change S/N in repeated surveys
            if scint:
                snr = s.scint(psr, snr)

            if snr > s.SNRlimit:
                ndet += 1
                psr.snr = snr
                survpop.population.append(psr)

                # check if the pulsar has been detected in other
                # surveys
                if not psr.detected:
                    # if not, set to detected and increment
                    # number of discoveries by the survey
                    psr.detected = True
                    s.discoveries += 1

            elif snr == -1.0:
                nsmear += 1
            elif snr == -2.0:
                nout += 1
            elif snr == -3.0:
                nbr += 1
            else:
                ntf += 1

        # report the results
        if not nostdout:
            print "Total pulsars in model = {0}".format(len(pop.population))
            print "Number detected by survey {0} = {1}".format(surv, ndet)
            print "Of which are discoveries = {0}".format(s.discoveries)
            print "Number too faint = {0}".format(ntf)
            print "Number smeared = {0}".format(nsmear)
            print "Number out = {0}".format(nout)
            if rratssearch:
                print "Number didn't burst = {0}".format(nbr)
            print "\n"

        d = Detections(ndet=ndet,
                       ntf=ntf,
                       nsmear=nsmear,
                       nout=nout,
                       nbr=nbr,
                       ndisc=s.discoveries)
        surveyPops.append([surv, survpop, d])

    if allsurveyfile:
        allsurvpop = Population()
        allsurvpop.population = [psr for psr in pop.population if psr.detected]
        surveyPops.append([None, allsurvpop, None])

    return surveyPops
Exemple #3
0
def run(pop,
        surveyList,
        nostdout=False,
        allsurveyfile=False,
        scint=False,
        accelsearch=False,
        jerksearch=False):

    """ Run the surveys and detect the pulsars."""

    # print the population
    if not nostdout:
        print "Running doSurvey on population..."
        print pop

    # loop over the surveys we want to run on the pop file
    surveyPops = []
    for surv in surveyList:
        s = Survey(surv)
        s.discoveries = 0
        if not nostdout:
            print "\nRunning survey {0}".format(surv)

        # create a new population object to store discovered pulsars in
        survpop = Population()
        # HERE SHOULD INCLUDE THE PROPERTIES OF THE ORIGINAL POPULATION

        # counters
        nsmear = 0
        nout = 0
        ntf = 0
        ndet = 0
        # loop over the pulsars in the population list
        for psr in pop.population:
            # pulsar could be dead (evolve!) - continue if so
            if psr.dead:
                continue

            # is the pulsar over the detection threshold?
            snr = s.SNRcalc(psr, pop)

            # add scintillation, if required
            # modifying S/N rather than flux is sensible because then
            # a pulsar can have same flux but change S/N in repeated surveys
            if scint:
                snr = s.scint(psr, snr)

            if snr > s.SNRlimit:
                ndet += 1
                psr.snr = snr
                survpop.population.append(psr)

                # check if the pulsar has been detected in other
                # surveys
                if not psr.detected:
                    # if not, set to detected and increment
                    # number of discoveries by the survey
                    psr.detected = True
                    s.discoveries += 1

            elif snr == -1.0:
                nsmear += 1
            elif snr == -2.0:
                nout += 1
            else:
                ntf += 1

        # report the results
        if not nostdout:
            print "Total pulsars in model = {0}".format(len(pop.population))
            print "Number detected by survey {0} = {1}".format(surv, ndet)
            print "Of which are discoveries = {0}".format(s.discoveries)
            print "Number too faint = {0}".format(ntf)
            print "Number smeared = {0}".format(nsmear)
            print "Number out = {0}".format(nout)
            print "\n"

        d = Detections(ndet=ndet,
                       ntf=ntf,
                       nsmear=nsmear,
                       nout=nout,
                       ndisc=s.discoveries)
        surveyPops.append([surv, survpop, d])

    if allsurveyfile:
        allsurvpop = Population()
        allsurvpop.population = [psr for psr in pop.population if psr.detected]
        surveyPops.append([None, allsurvpop, None])

    return surveyPops