#!/usr/bin/python

# import the populate and dosurvey modules
import populate
import dosurvey

# run the Populate.generate script, setting parameters as necessary.
# the resulting model is stored in the variable 'pop'
# Any unspecified variables use the default values (see populate
# for more details)

pop = populate.generate(
    1038,
    surveyList=['PMSURV'],
    radialDistType='lfl06',
    siDistPars=[-1.41, 0.96],  # non-standard SI distribution
    duty=6.,
    electronModel='lmt85',
    nostdout=True  # switches off output to stdout
)

# now run "dosurvey.run" on the model. Provide a list of surveys to use
surveyPopulations = dosurvey.run(pop, ['PMSURV'], nostdout=True)

# write out the survey results however you like
dosurvey.write(surveyPopulations, nores=False, summary=False, asc=False)

# write out the population model, if required
pop.write(outf="populate.model")
detections = np.full((runs_of_pop, runs_per_pop), 0)

#model_name = './1913_z330.model'
model_name = './1913_z330_varlum.model'

for xx, npop in enumerate(pops):

    print "On population:{}".format(npop)

    for ii in range(runs_of_pop):

        pop = populate.generate(npop,
                                pDistPars=[log_p_1913, 0.0],
                                duty_percent=16.9,
                                orbits=False,
                                nostdout=True,
                                zscale=0.33,
                                siDistPars=[-1.4, 1.0],
                                lumDistPars=lum_params)
        pop.write(outf=model_name)

        for jj in range(runs_per_pop):

            population = dosurvey.loadModel(model_name)

            output = dosurvey.run(population, surveys, nostdout=True)

            detections[ii][
                jj] = output[0][2].ndet + output[1][2].ndet + output[2][
                    2].ndet + output[3][2].ndet + output[4][2].ndet
Beispiel #3
0
runs_per_pop = 100

detections = np.full((runs_of_pop, runs_per_pop), 0)

model_name = './0737B_z330.model'

for xx, npop in enumerate(pops):

    print "On population:{}".format(npop)

    for ii in range(runs_of_pop):

        pop = populate.generate(npop,
                                pDistPars=[log_p_0737B, 0.0],
                                duty_percent=1.3,
                                orbits=False,
                                nostdout=True,
                                zscale=0.33,
                                siDistPars=[-1.4, 1.0])
        pop.write(outf=model_name)

        for jj in range(runs_per_pop):

            population = dosurvey.loadModel(model_name)

            output = dosurvey.run(population, surveys, nostdout=True)

            detections[ii][
                jj] = output[0][2].ndet + output[1][2].ndet + output[2][
                    2].ndet + output[3][2].ndet + output[4][2].ndet
#!/usr/bin/python

# import the populate and dosurvey modules
import populate
import dosurvey

# run the Populate.generate script, setting parameters as necessary.
# the resulting model is stored in the variable 'pop'
# Any unspecified variables use the default values (see populate
# for more details)

pop = populate.generate(1038, 
               surveyList=['PMSURV'],
               radialDistType='lfl06',
               siDistPars=[-1.41, 0.96], # non-standard SI distribution
               duty=6.,
               electronModel='lmt85',
               nostdout=True # switches off output to stdout
               )

# now run "dosurvey.run" on the model. Provide a list of surveys to use
surveyPopulations = dosurvey.run(pop, ['PMSURV'], nostdout=True)

# write out the survey results however you like
dosurvey.write(surveyPopulations, nores=False, summary=False, asc=False)

# write out the population model, if required
pop.write(outf="populate.model")
for jj, zzscale in enumerate(zscale):

    print "On run:", jj

    mean_z_hts = np.full(n_runs, 0.0)
    mean_z_hts_err = np.full(n_runs, 0.0)
    mean_dm_singb = np.full(n_runs, 0.0)
    mean_dm_singb_err = np.full(n_runs, 0.0)

    for ii in range(n_runs):

        #Make sure to change the zscale!
        pop = populate.generate(npop,
                                pDistType='unif',
                                surveyList=surveys,
                                pDistPars=[15, 70],
                                orbits=False,
                                nostdout=True,
                                zscale=zzscale,
                                siDistPars=[-1.4, 1.0])

        #I set the allsurveyfile = True to combine detected PSR properties into single numpy array
        op = dosurvey.run(pop, surveys, nostdout=True, allsurveyfile=True)

        #Here I make use of the allsurveyfile, i.e. op[3]
        mean_z_hts[ii] = np.nanmedian(
            np.abs(op[-1][1].make_plotting_dicts()[1]['Gal Z']))
        mean_z_hts_err[ii] = np.std(
            np.abs(
                op[-1][1].make_plotting_dicts()[1]['Gal Z'])) / np.sqrt(npop)
        mean_dm_singb[ii] = np.nanmedian(
            op[-1][1].make_plotting_dicts()[1]['DM'] * np.abs(