Exemple #1
0
true_ns = []
ra = []
dec = []
gammaList = []
mean_ninj = []
flux_list = []
true_ras = []
true_decs = []

seed_counter = 0

for gamma in gammas:
    f = FastResponseAnalysis(cascade_healpy_file,
                             start,
                             stop,
                             save=False,
                             alert_event=True,
                             smear=False,
                             alert_type='cascade')
    inj = f.initialize_injector(gamma=gamma)
    scale_arr = []
    step_size = 10
    for i in range(1, 20 * step_size + 1, step_size):
        scale_arr.append([])
        for j in range(5):
            scale_arr[-1].append(inj.sample(i, poisson=False)[0][0])
    scale_arr = np.median(scale_arr, axis=1)
    try:
        scale_factor = np.min(np.argwhere(scale_arr > 0)) * step_size + 1.
    except:
        print("Scale factor thing for prior injector didn't work")
Exemple #2
0
                                         h=True,
                                         verbose=False)

skymap_header = {name: val for name, val in skymap_header}
ev_mjd = skymap_header['EVENTMJD']
ev_run, ev_id = skymap_header['RUNID'], skymap_header['EVENTID']
source = {"Skipped Events": [(ev_run, ev_id)]}
source['Name'] = "RUN {} EVENT {} time window {:.2e}".format(
    str(skymap_header['RUNID']), str(skymap_header['EVENTID']), args.deltaT)
source['alert_type'] = 'track'

deltaT = args.deltaT / 86400.
event_mjd = ev_mjd
start_mjd = event_mjd - (deltaT / 2.)
stop_mjd = event_mjd + (deltaT / 2.)
start = Time(start_mjd, format='mjd').iso
stop = Time(stop_mjd, format='mjd').iso

f = FastResponseAnalysis(skymap_files[args.index],
                         start,
                         stop,
                         save=False,
                         alert_event=True,
                         smear=args.smear,
                         **source)
inj = f.initialize_injector(
    gamma=2.5)  #just put this here to initialize f.spatial_prior
ts = f.unblind_TS()
smear_str = 'smeared/' if args.smear else 'norm_prob/'
res = f.save_results(alt_path=output_paths + smear_str)
Exemple #3
0
true_ns = []
ra = []
dec = []
gammaList = []
mean_ninj = []
flux_list = []
true_ras = []
true_decs = []

seed_counter = 0

for gamma in gammas:
    f = FastResponseAnalysis(skymap_files[args.index],
                             start,
                             stop,
                             save=False,
                             alert_event=True,
                             smear=args.smear,
                             alert_type='track')
    inj = f.initialize_injector(gamma=gamma)
    scale_arr = []
    step_size = 10
    for i in range(1, 20 * step_size + 1, step_size):
        scale_arr.append([])
        for j in range(5):
            scale_arr[-1].append(inj.sample(i, poisson=False)[0][0])
    scale_arr = np.median(scale_arr, axis=1)
    try:
        scale_factor = np.min(np.argwhere(scale_arr > 0)) * step_size + 1.
    except:
        print("Scale factor thing for prior injector didn't work")
Exemple #4
0
    + 'fast-response/fast_response/cascades_results/skymaps/IceCube-Cascade' \
    + '_{}_{}.hp'.format(int(run_id), int(event_id))

trials_per_sig = args.ntrials

tsList_prior = []
nsList_prior = []
ra = []
dec = []

seed_counter = 0

f = FastResponseAnalysis(cascade_healpy_file,
                         start,
                         stop,
                         save=False,
                         alert_event=True,
                         smear=False,
                         alert_type='cascade')

inj = f.initialize_injector(
    gamma=2.5)  #just put this here to initialize f.spatial_prior
for jj in range(trials_per_sig):
    seed_counter += 1
    try:
        val = f.llh.scan(0.0,
                         0.0,
                         scramble=True,
                         seed=seed_counter,
                         spatial_prior=f.spatial_prior,
                         time_mask=[deltaT / 2., event_mjd],
Exemple #5
0
        final_args[name] = new_arg
    else:
        final_args[name] = argument
print('')   

import logging as log
from astropy.time import Time
from astropy.coordinates import Angle
import astropy.units as u
from fast_response.FastResponseAnalysis import FastResponseAnalysis

log.basicConfig(level=log.ERROR)
source = final_args
source['alert_event'] = args.alert_event
####################### INITIALIZE FAST RESPONSE OBJECT #######################
f = FastResponseAnalysis(source['Location'], source['Start Time'], source['Stop Time'], **source)
# Point source, gw, etc. handling done in analysis object instantiation

f.unblind_TS()
f.plot_ontime()
f.ns_scan()
f.calc_pvalue(ntrials = args.ntrials)
if not args.nodiag:
    f.make_dNdE()
    f.plot_tsd()
    f.upper_limit()
    
results = f.save_results()
f.generate_report()
if args.document:
    subprocess.call(['cp','-r',results['analysispath'],
Exemple #6
0
trials_per_sig = args.ntrials

tsList_prior = []
tsList = []
nsList = []
nsList_prior = []
true_ns = []
ra = []
dec = []

seed_counter = 0

f = FastResponseAnalysis(skymap_files[args.index],
                         start,
                         stop,
                         save=False,
                         alert_event=True,
                         smear=args.smear,
                         alert_type='track')
inj = f.initialize_injector(
    gamma=2.5)  #just put this here to initialize f.spatial_prior
for jj in range(trials_per_sig):
    seed_counter += 1
    try:
        val = f.llh.scan(0.0,
                         0.0,
                         scramble=True,
                         seed=seed_counter,
                         spatial_prior=f.spatial_prior,
                         time_mask=[deltaT / 2., event_mjd],
                         pixel_scan=[f.nside, 4.0],
skymap_files = glob(
    '/data/ana/realtime/alert_catalog_v2/2yr_prelim/fits_files/Run13*.fits.gz')

start_mjd = 58484.0
stop_mjd = start_mjd + (args.deltaT / 86400.)
start = Time(start_mjd, format='mjd').iso
stop = Time(stop_mjd, format='mjd').iso
deltaT = args.deltaT / 86400.

trials_per_sig = args.ntrials
seed_counter = args.seed

f = FastResponseAnalysis(skymap_files[0],
                         start,
                         stop,
                         save=False,
                         alert_event=True)
f.llh.nbackground = args.bkg * args.deltaT / 1000.
#inj = f.initialize_injector(gamma=2.5) #just put this here to initialize f.spatial_prior
#print f.llh.nbackground

#results_array = []

npix = hp.nside2npix(f.nside)
shape = (args.ntrials, npix)
maps = sparse.lil_matrix(shape, dtype=float)
for jj in range(trials_per_sig):
    seed_counter += 1
    val = f.llh.scan(
        0.0,