Example #1
0
def get_frbpoppy_data():
    """Get frbpoppy data."""
    surv_pop = unpickle('cosmic_chime')

    # Split population into seamingly one-off and repeater populations
    mask = ((~np.isnan(surv_pop.frbs.time)).sum(1) > 1)
    pop_ngt1, pop_nle1 = split_pop(surv_pop, mask)
    pop_ngt1.name += ' (> 1 burst)'
    pop_nle1.name += ' (1 burst)'

    # Limit to population above S/N limits
    mask = (pop_ngt1.frbs.snr > SNR_LIMIT_REPS)
    pop_ngt1.frbs.apply(mask)
    mask = (pop_nle1.frbs.snr > SNR_LIMIT_ONE_OFFS)
    pop_nle1.frbs.apply(mask)
    print(f'{surv_pop.n_repeaters()} repeaters')
    print(f'{surv_pop.n_one_offs()} one-offs')

    frbpop = {'r': {}, 'o': {}}
    for i, pop in enumerate((pop_ngt1, pop_nle1)):
        t = 'o'
        if i == 0:
            t = 'r'
        frbpop[t]['dm'] = pop.frbs.dm
        # Take only the first snr
        frbpop[t]['snr'] = pop.frbs.snr[:, 0]

    return frbpop
Example #2
0
survey = Survey('perfect', n_days=DAYS)
survey.set_beam(model='perfect')
survey.snr_limit = 1e6

surv_pop = SurveyPopulation(r, survey)

pprint(f'{r.n_bursts()}:{surv_pop.n_bursts()}')
pprint(f'{surv_pop.n_sources()} sources detected')

if r.n_bursts() < PLOTTING_LIMIT_N_SRCS:
    pprint('Not sufficient FRB sources for plotting')
    exit()

# Split population into seamingly one-off and repeater populations
mask = ((~np.isnan(surv_pop.frbs.time)).sum(1) > 1)
pop_rep, pop_one = split_pop(surv_pop, mask)
pop_rep.name += ' (> 1 burst)'
pop_one.name += ' (1 burst)'

if INTERACTIVE_PLOT:
    plot(r, pop_rep, pop_one, tns=False, mute=False)

# Plot dm distribution
if SNR:
    plot_aa_style(cols=2)
    f, (ax1, ax2) = plt.subplots(1, 2)
else:
    plot_aa_style(cols=1)
    f, ax1 = plt.subplots(1, 1)

prop_cycle = plt.rcParams['axes.prop_cycle']
Example #3
0
"""Generate a repeater population and split into repeaters and one-offs."""
import numpy as np

from frbpoppy import CosmicPopulation, Survey, SurveyPopulation
from frbpoppy import split_pop, pprint, plot

DAYS = 1

r = CosmicPopulation.simple(int(1e4), n_days=DAYS, repeaters=True)
r.set_time(model='regular', rate=2)
r.set_lum(model='powerlaw', low=1e40, high=1e45, per_source='different')
r.generate()

survey = Survey('chime-frb', n_days=DAYS)
survey.set_beam(model='perfect')
surv_pop = SurveyPopulation(r, survey)

# Split population into seamingly one-off and repeater populations
mask = ((~np.isnan(surv_pop.frbs.time)).sum(1) > 1)
pop_ngt1, pop_nle1 = split_pop(surv_pop, mask)
pop_ngt1.name += ' (> 1 burst)'
pop_nle1.name += ' (1 burst)'

pops = [pop_nle1, pop_ngt1]

pprint(f'{surv_pop.n_sources()} sources detected')
pprint(f'{surv_pop.n_bursts()} bursts detected')

plot(surv_pop)
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)