IC170922A_wGFU

Introduction

The IC170922A_wGFU analysis is a multi-dataset time-integrated single source analysis with a two-component likelihood function using a spacial and an energy event PDF.

Setup

Import analysis creation function from “i3skyllh” project.

[1]:
from i3skyllh.analyses.IC170922A_wGFU.analysis import create_analysis

Add the required imports for the analysis.

[2]:
import logging
import numpy as np

# Classes to define the source hypothesis.
from skyllh.physics.source import PointLikeSource

# Classes for utility functionality.
from skyllh.core.config import CFG
from skyllh.core.random import RandomStateService
from skyllh.core.timing import TimeLord

# Logging setup utilities.
from skyllh.core.debugging import (
    setup_logger,
    setup_console_handler,
    setup_file_handler
)

# The pre-defined data samples.
from i3skyllh.datasets import data_samples

Define TXS 0506+056 location to use as a point source.

[3]:
def TXS_location():
    src_ra  = np.radians(77.358)
    src_dec = np.radians(5.693)
    return (src_ra, src_dec)

Setup logging first to get log messages from “skyllh” project.

[4]:
setup_logger('skyllh', logging.DEBUG)
log_format = '%(asctime)s %(processName)s %(name)s %(levelname)s: '\
             '%(message)s'
setup_console_handler('skyllh', logging.INFO, log_format)
#setup_file_handler('skyllh', logging.DEBUG, log_format, 'debug.log')

Set a number of CPUs available for parallel calculations.

[5]:
CFG['multiproc']['ncpu'] = 16

Define which datasets seasons to use.

[6]:
sample_seasons = [
    ("PointSourceTracks", "IC40"),
    ("PointSourceTracks", "IC59"),
    ("PointSourceTracks", "IC79"),
    ("PointSourceTracks", "IC86, 2011"),
    ("PointSourceTracks", "IC86, 2012"),
    ("PointSourceTracks", "IC86, 2013"),
    ("PointSourceTracks", "IC86, 2014"),
    ("PointSourceTracks", "IC86, 2015"),
    ("PointSourceTracks", "IC86, 2016"),
    ("PointSourceTracks", "IC86, 2017"),
    ("GFU", "IC86, 2015-2018")
]

Get the datasets.

[7]:
datasets = []
for (sample, season) in sample_seasons:
    # Get the dataset from the correct dataset collection.
    dsc = data_samples[sample].create_dataset_collection()
    datasets.append(dsc.get_dataset(season))

Set a rss seed and define a random state service.

[8]:
rss_seed = 1
rss = RandomStateService(rss_seed)

Define the source.

[9]:
source = PointLikeSource(*TXS_location())

Create a TimeLord instance. It is used to keep track of execution times of specific code segments.

[10]:
tl = TimeLord()

Create analysis.

[11]:
with tl.task_timer('Creating analysis.'):
    ana = create_analysis(
        datasets, source,
        data_base_path=None,
        compress_data=False,
        tl=tl)
[==========================================================] 100% ELT 0h:03m:57s
[==========================================================] 100% ELT 0h:01m:34s

Unblind the data and print best fit parameters.

[12]:
with tl.task_timer('Unblinding data.'):
    (TS, fitparam_dict, status) = ana.unblind(rss)
print('TS = %g'%(TS))
print('ns_fit = %g'%(fitparam_dict['ns']))
print('gamma_fit = %g'%(fitparam_dict['gamma']))
TS = 25.1273
ns_fit = 15.8888
gamma_fit = 1.98958

Generate some signal events.

[13]:
with tl.task_timer('Generating signal events.'):
    (n_sig, signal_events_dict) = ana.sig_generator.generate_signal_events(rss, 100)
print('n_sig: %d', n_sig)
print('signal datasets: '+str(signal_events_dict.keys()))
('n_sig: %d', 98)
signal datasets: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Print the TimeLord instance to get a summary of execution times.

[14]:
print(tl)
Executed tasks:
[                                     Loading grl data from disk.] 0.622766 sec
[                                     Loading exp data from disk.] 2.55504 sec
[                                      Loading mc data from disk.] 64.3951 sec
[Selected only the experimental data that matches the GRL for dat] 0.0118048 sec
[                Preparing data of dataset "IC40" by "data_prep".] 0.0924909 sec
[             Appending IceCube-specific data fields to exp data.] 0.0445914 sec
[              Appending IceCube-specific data fields to MC data.] 4.54178 sec
[                                              Cleaning exp data.] 0.0034306 sec
[                                               Cleaning MC data.] 0.179492 sec
[                                          Asserting data format.] 0.000287294 sec
[Selected only the experimental data that matches the GRL for dat] 0.013073 sec
[                Preparing data of dataset "IC59" by "data_prep".] 0.22692 sec
[Selected only the experimental data that matches the GRL for dat] 0.00786304 sec
[                Preparing data of dataset "IC79" by "data_prep".] 0.216612 sec
[Selected only the experimental data that matches the GRL for dat] 0.0117018 sec
[          Preparing data of dataset "IC86, 2011" by "data_prep".] 0.0715699 sec
[Selected only the experimental data that matches the GRL for dat] 0.01633 sec
[          Preparing data of dataset "IC86, 2012" by "data_prep".] 1.39812 sec
[Selected only the experimental data that matches the GRL for dat] 0.0136781 sec
[          Preparing data of dataset "IC86, 2013" by "data_prep".] 2.32966 sec
[Selected only the experimental data that matches the GRL for dat] 0.0154629 sec
[          Preparing data of dataset "IC86, 2014" by "data_prep".] 1.78734 sec
[Selected only the experimental data that matches the GRL for dat] 0.0154121 sec
[          Preparing data of dataset "IC86, 2015" by "data_prep".] 1.34278 sec
[Selected only the experimental data that matches the GRL for dat] 0.0102689 sec
[          Preparing data of dataset "IC86, 2016" by "data_prep".] 1.51473 sec
[Selected only the experimental data that matches the GRL for dat] 0.015995 sec
[          Preparing data of dataset "IC86, 2017" by "data_prep".] 1.33161 sec
[Selected only the experimental data that matches the GRL for dat] 0.114225 sec
[     Preparing data of dataset "IC86, 2015-2018" by "data_prep".] 1.10847 sec
[                                              Creating analysis.] 335.913 sec
[                                                Unblinding data.] 0.361189 sec
[                                       Generating signal events.] 0.0934389 sec