Esempio n. 1
0
"""Example of simulating a perfect survey."""
from frbpoppy import CosmicPopulation, Survey, SurveyPopulation, plot

# Generate an FRB population
cosmic_pop = CosmicPopulation.simple(1e4, generate=True)

# Setup a survey
survey = Survey('perfect')

# Observe the FRB population
survey_pop = SurveyPopulation(cosmic_pop, survey)

# Check the detection rates
print(survey_pop.rates())

# Note that due to redshift you won't see all bursts, as some will have
# redshifted out of the observing time. But no matter how faint, you'll see
# all bursts within the observing time

# Plot populations
plot(cosmic_pop, survey_pop, frbcat=False, mute=False)
Esempio n. 2
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)
Esempio n. 3
0
"""Short example of how frbpoppy works."""
from frbpoppy import CosmicPopulation, Survey, SurveyPopulation, plot

PLOT = False

# Generate an FRB population
cosmic_pop = CosmicPopulation(10000, days=1, name='example')

# Setup a survey
survey = Survey('htru')

# Observe the FRB population
survey_pop = SurveyPopulation(cosmic_pop, survey)

# Check the detection rates
print(survey_pop.rates())

# Plot populations
if PLOT:
    plot(cosmic_pop, survey_pop, frbcat='parkes')
Esempio n. 4
0
"""Short example of how frbpoppy works."""
from frbpoppy import CosmicPopulation, Survey, SurveyPopulation, plot

PLOT = True

# Generate an FRB population
cosmic_pop = CosmicPopulation(10000, days=7, name='example')

# Setup a survey
survey = Survey('apertif')

# Observe the FRB population
survey_pop = SurveyPopulation(cosmic_pop, survey)

# Check the detection rates
print(survey_pop.rates())

# Plot populations
if PLOT:
    plot(cosmic_pop, survey_pop, mute=False)
Esempio n. 5
0
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']
colors = prop_cycle.by_key()['color']

pops = (r, pop_rep, pop_one)

for i, pop in enumerate(pops):
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, frbcat=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']
colors = prop_cycle.by_key()['color']

pops = (r, pop_rep, pop_one)

for i, pop in enumerate(pops):
"""Short example of how frbpoppy works.

The first time you run frbpoppy, a series of cosmological databases will be
constructed to set up subsequent runs. This first run can take ~2h on a 4 core
machine. Subsequent runs will take mere seconds.
"""
from frbpoppy import CosmicPopulation, Survey, SurveyPopulation, plot

# Set up an FRB population of one-offs
# Add repeaters=True to turn into an FRB population of repeaters
cosmic_pop = CosmicPopulation.complex(1e5, n_days=0.01)

# Generate your FRB population
cosmic_pop.generate()

# Setup a survey
survey = Survey('parkes-htru')
survey.set_beam(model='parkes-htru')

# Observe the FRB population
survey_pop = SurveyPopulation(cosmic_pop, survey)

# Check the detection rates
print(survey_pop.source_rate)

# Plot populations in a browser
plot(cosmic_pop, survey_pop, tns='parkes')
Esempio n. 8
0
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)