import frbpoppy.gen_dists as gd

# Set up a population
cosmic_pop = CosmicPopulation(1e4, generate=False)
# ... or adapt the population per parameter, e.g.
cosmic_pop.set_dist(z_max=2.5)
# Or to adapt the luminosity
cosmic_pop.set_lum(model='powerlaw', low=1e44, high=1e45)
# Generate the population
cosmic_pop.generate()

# Setup a survey
survey = Survey('wsrt-apertif')
# and adapt the survey with
survey.set_beam('airy', n_sidelobes=2)
survey.snr_limit = 2

# For a full list of available arguments or parameters check the classes as
# defined in /frbpoppy/*.py

# Some more difficult examples

# Use a convolution of two distributions
cosmic_pop = CosmicPopulation.simple(n_srcs=1e4, repeaters=True)
# Draw the mean value per source from a normal distribution
mean_dist = gd.trunc_norm(mean=1, std=2, shape=int(1e4))
# And use those means as a _means_ to generate from a new Gaussian
# distribution per source
cosmic_pop.set_w(model='gauss',
                 per_source='different',
                 mean=mean_dist,
Beispiel #2
0
RATE = 3
CHIME_HIST = False
SCATTER = False

pop = CosmicPopulation.simple(n_srcs, n_days=n_days, repeaters=True)
pop.set_dist(z_max=2.0)
pop.set_w(model='constant', value=1)
pop.set_dm(mw=False, igm=True, host=False)
pop.set_dm_igm(model='ioka', slope=1000, std=0)
pop.set_time(model='poisson', rate=RATE)
pop.set_time(model='regular', rate=RATE)
pop.set_w('constant', value=1)
pop.generate()

survey = Survey('perfect', n_days=n_days)
survey.snr_limit = 4e6

plot_aa_style(cols=1)
f, ax1 = plt.subplots(1, 1)
colors = plt.rcParams['axes.prop_cycle'].by_key()['color']

lum_funcs = ['neg. pl.', 'flat pl.', 'std. candle']
for i, lum_func in enumerate(lum_funcs):

    if lum_func == 'neg. pl.':
        pop.set_lum(model='powerlaw', per_source='different', low=1e40,
                    high=1e45, power=-1.5)
    elif lum_func == 'flat pl.':
        pop.set_lum(model='powerlaw', per_source='different', low=1e40,
                    high=1e45, power=0)
    elif lum_func == 'gauss':
def main():

    r = RepeaterPopulation(N,
                           days=1,
                           dm_host_model='gaussian',
                           dm_host_mu=100,
                           dm_host_sigma=0,
                           dm_igm_index=1000,
                           dm_igm_sigma=0,
                           dm_mw_model='zero',
                           emission_range=[10e6, 10e9],
                           lum_range=[1e38, 1e38],
                           lum_index=0,
                           n_model='vol_co',
                           alpha=-1.5,
                           w_model='uniform',
                           w_range=[1., 1.],
                           w_mu=0.1,
                           w_sigma=0.5,
                           si_mu=-1.4,
                           si_sigma=0.,
                           z_max=2.5,
                           lum_rep_model='independent',
                           lum_rep_sigma=1e3,
                           si_rep_model='same',
                           si_rep_sigma=0.1,
                           times_rep_model='even',
                           w_rep_model='independent',
                           w_rep_sigma=0.05,
                           generate=True)

    s = Survey('perfect')
    s.gain_pattern = 'perfect'

    # Setup pointings
    n_p = 1  # # of pointings
    decs = np.linspace(s.dec_min, s.dec_max, n_p + 2)[1:n_p + 1]
    ras = np.linspace(s.ra_min, s.ra_max, n_p + 2)[1:n_p + 1]
    s.pointings = list(zip(ras, decs))
    pop = limit_ra_dec(r, s.pointings)
    pop.name = 'Cosmic Population'

    s.snr_limit = 1
    surv_pop_low_snr = SurveyPopulation(r, s)
    surv_pop_low_snr.name = 'Low SNR'

    s.snr_limit = 10
    surv_pop_high_snr = SurveyPopulation(r, s)
    surv_pop_high_snr.name = 'High SNR'

    pops = [pop]
    # Split population into seamingly one-off and repeater populations
    for pop in (surv_pop_low_snr, surv_pop_high_snr):
        mask = ((~np.isnan(pop.frbs.time)).sum(1) > 1)
        pop_ngt1, pop_nle1 = split_pop(pop, mask)
        pop_ngt1.name += ' (> 1 burst)'
        pop_nle1.name += ' (1 burst)'
        pops.append(pop_nle1)
        pops.append(pop_ngt1)

    plot(*pops, frbcat=False, mute=False, show=True)
Beispiel #4
0
pop.set_lum(model='powerlaw', low=1e30, high=1e40, power=-1)
pop.set_w(model='constant', value=1)
pop.set_dm(mw=False, igm=True, host=False)

# Add a distribution of Poisson burst rates
if SINGLE_INPUT_RATE:
    rate_dist = RATE
else:
    rate_dist = log10normal(RATE, 2, N_SRCS)
pop.set_time(model='poisson', rate=rate_dist)
pop.generate()

# Survey the high fluences
survey = Survey('perfect', n_days=N_DAYS)
survey.set_beam(model='perfect')
survey.snr_limit = 1e-6
survey.t_obs = 60 * 60  # seconds

# Check the burst rate
surv_pop = SurveyPopulation(pop, survey)
time = surv_pop.frbs.time

# Set up plot
plot_aa_style()

if isinstance(rate_dist, np.ndarray):
    min_rate = np.log10(np.min(rate_dist[rate_dist != 0]))
    max_rate = np.log10(max(rate_dist))
else:
    min_rate = np.log10(RATE) - 1
    max_rate = np.log10(RATE) + 1
Beispiel #5
0
        n_one_offs = ((~np.isnan(time)).sum(1) == 1).sum()
        frac = n_rep / (n_rep + n_one_offs)
        fracs.append(frac)
    print(f'# one-offs: {n_one_offs}')
    print(f'# repeaters: {n_rep}')
    return days, fracs


r_pop = setup_pop(N_SRCS)

# Set up surveys
survey = Survey('perfect', n_days=MAX_DAYS)
survey.mount_type = 'transit'
survey.t_obs = 60*60*24
survey.set_beam(model='perfect')
survey.snr_limit = 10000

chime_survey = deepcopy(survey)
chime_survey.set_beam(model='chime-frb')
chime_survey.snr_limit = 1

# Set up plot style
plot_aa_style(cols=2)
f, (ax1, ax2) = plt.subplots(1, 2)

colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
linestyles = ['solid', 'dotted']
dist_types = ['rep', 'dist', 'mix']

# Further plot details
ax1.set_xlabel(r'Poisson Rate (day$^{-1}$)')