{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Time dependent analyses with the public 10-year IceCube point-source data " ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This tutorial shows how to use the public point-source data for a time dependent point-source analysis. The time fit is performed by the expectation maximization (EM) algorithm. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n", "import numpy as np\n", "\n", "from skyllh.analyses.i3.publicdata_ps.time_dependent_ps import (\n", " create_analysis,\n", " do_trials_with_em,\n", " unblind_single_flare,\n", " TXS_0506_PLUS056_ALERT_TIME,\n", " TXS_0506_PLUS056_SOURCE,\n", ")\n", "from skyllh.core.config import Config\n", "from skyllh.datasets.i3.PublicData_10y_ps import create_dataset_collection" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "First we need to create a local configuration for the analysis. We will create just the default configuration:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "cfg = Config()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Now we can get the dataset:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "dsc = create_dataset_collection(\n", " cfg=cfg,\n", " base_path=\"/home/mwolf/projects/publicdata_ps/\")\n", "datasets = dsc[\"IC86_II-VII\", ]" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "We create the ``Anaylsis`` instance for the TXS 0506+056 source." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 43/43 [00:04<00:00, 9.25it/s]\n", "100%|██████████| 1/1 [00:23<00:00, 23.03s/it]\n", "100%|██████████| 44/44 [00:00<00:00, 2263.58it/s]\n" ] } ], "source": [ "ana = create_analysis(\n", " cfg=cfg,\n", " datasets=datasets, \n", " source=TXS_0506_PLUS056_SOURCE, \n", " refplflux_gamma=2.0, \n", " gauss={\"mu\":57000, \"sigma\": 65})" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 51/51 [00:06<00:00, 8.04it/s]\n" ] } ], "source": [ "(best_ts, best_em_result, best_fitparam_values) = unblind_single_flare(\n", " ana=ana, \n", " remove_time=TXS_0506_PLUS056_ALERT_TIME)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "best TS = 15.4046\n", "best em mu = 56972.7\n", "best em sigma = 27.9716\n", "best ns = 7.36603\n", "best gamma = 2.20371\n" ] } ], "source": [ "print(f'best TS = {best_ts:g}')\n", "print(f'best em mu = {best_em_result[\"mu\"]:g}')\n", "print(f'best em sigma = {best_em_result[\"sigma\"]:g}')\n", "print(f'best ns = {best_fitparam_values[0]:g}')\n", "print(f'best gamma = {best_fitparam_values[1]:g}')" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Run backgroud trials, i.e. ``mean_n_sig=0``" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 100/100 [03:25<00:00, 2.05s/it]\n" ] } ], "source": [ "bg_trials = do_trials_with_em(ana=ana, n=100, mean_n_sig=0, ncpu=4)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([ 3., 2., 7., 22., 25., 19., 8., 9., 3., 2.]),\n", " array([ 0.45811669, 2.35982925, 4.26154181, 6.16325437, 8.06496693,\n", " 9.96667949, 11.86839206, 13.77010462, 15.67181718, 17.57352974,\n", " 19.4752423 ]),\n", " )" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAD4CAYAAAATpHZ6AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0c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tKZa3SHqwT5vWboVh+ypJX5L08Yj414A2ZfaFuurr/ozm2gH9tn0rkQ9J+l1EHO63sYnxG5In9e1/dX3qO+TT4I3qfAL8rKSvFOs+L+nzxbLV+ecbz0p6WtJMw/W9X50/cZ6StL94bOypcaukg+p8Gv24pPc1WN/bi36fLGo4GcfwteqE9Ou71rU2fur8clmS9B91jn5ukPRGSXskHSqezynavlnSQ8P214bqe0ad+dQT++D3eusbtC80VN8Pin3rKXWCZs3JNH7F+rtP7HNdbRsdvyF5Utv+x20CACARrigFgEQIdQBIhFAHgEQIdQBIhFAHgEQIdQBIhFAHgET+C0juPW7V+QZjAAAAAElFTkSuQmCC", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "plt.hist(bg_trials[\"ts\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }