{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "02f882a7", "metadata": { "execution": { "iopub.execute_input": "2024-03-22T09:57:34.784263Z", "iopub.status.busy": "2024-03-22T09:57:34.783704Z", "iopub.status.idle": "2024-03-22T09:57:36.057096Z", "shell.execute_reply": "2024-03-22T09:57:36.056424Z" } }, "outputs": [], "source": [ "from icecube_tools.utils.data import RealEvents, SimEvents\n", "from icecube_tools.point_source_analysis.point_source_analysis import MapScan\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "id": "ec7b7f0a", "metadata": {}, "source": [ "## MapScan\n", "\n", "We can perform a scan over the sky for point sources. At each proposed source location a likelihood fit is performed. First we have to provide some events, here we use the simulated ones from the example notebook." ] }, { "cell_type": "code", "execution_count": 2, "id": "00563b0a", "metadata": { "execution": { "iopub.execute_input": "2024-03-22T09:57:36.060399Z", "iopub.status.busy": "2024-03-22T09:57:36.059855Z", "iopub.status.idle": "2024-03-22T09:57:36.066011Z", "shell.execute_reply": "2024-03-22T09:57:36.065386Z" } }, "outputs": [], "source": [ "events = SimEvents.load_from_h5(\"h5_test.hdf5\")" ] }, { "cell_type": "markdown", "id": "3a8b183c", "metadata": {}, "source": [ "Then we create a MapScan() object with some configuration `config.yaml` in which source lists, data cuts, etc. can be stored, the events, and a path for the output of the scan `test_output.hdf5`." ] }, { "cell_type": "code", "execution_count": 3, "id": "45d28e0e", "metadata": { "execution": { "iopub.execute_input": "2024-03-22T09:57:36.068623Z", "iopub.status.busy": "2024-03-22T09:57:36.068266Z", "iopub.status.idle": "2024-03-22T09:57:36.076647Z", "shell.execute_reply": "2024-03-22T09:57:36.076019Z" } }, "outputs": [], "source": [ "scan = MapScan(\"config.yaml\", \"test_output.hdf5\", events)" ] }, { "cell_type": "markdown", "id": "62becf8f", "metadata": {}, "source": [ "Let's create a small grid around the source location of the simulation: (ra, dec) = (180°, 30°)" ] }, { "cell_type": "code", "execution_count": 4, "id": "9afabbfe", "metadata": { "execution": { "iopub.execute_input": "2024-03-22T09:57:36.078878Z", "iopub.status.busy": "2024-03-22T09:57:36.078677Z", "iopub.status.idle": "2024-03-22T09:57:36.082555Z", "shell.execute_reply": "2024-03-22T09:57:36.082017Z" } }, "outputs": [], "source": [ "dec = np.linspace(np.deg2rad(25), np.deg2rad(35), 11)\n", "ra = np.linspace(np.pi - np.deg2rad(5), np.pi + np.deg2rad(5), 11)\n", "rr, dd = np.meshgrid(ra, dec)" ] }, { "cell_type": "markdown", "id": "3641835c", "metadata": {}, "source": [ "The source coordinates need to be handed over the the MapScan, then `generate_sources()` is called. Although the sources are already generated, it is able to create source lists from healpy keywords npix and nside for entire sky searches. Furthermore, output arrays of appropriate sizes are created. Afterwards the fits are started." ] }, { "cell_type": "code", "execution_count": 5, "id": "49d66076", "metadata": { "execution": { "iopub.execute_input": "2024-03-22T09:57:36.085049Z", "iopub.status.busy": "2024-03-22T09:57:36.084663Z", "iopub.status.idle": "2024-03-22T09:57:51.789908Z", "shell.execute_reply": "2024-03-22T09:57:51.789313Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\r", " 0%| | 0/121 [00:00" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig, ax = plt.subplots(1, 3, figsize=(15, 4))\n", "\n", "pcol = ax[0].pcolormesh(ra, dec, scan.ts.reshape((11, 11)), shading=\"nearest\")\n", "fig.colorbar(pcol, ax=ax[0], label=\"TS\")\n", "\n", "pcol = ax[1].pcolormesh(ra, dec, scan.index.reshape((11, 11)), shading=\"nearest\")\n", "fig.colorbar(pcol, ax=ax[1], label=\"index\")\n", "\n", "pcol = ax[2].pcolormesh(ra, dec, scan.ns.reshape((11, 11)), shading=\"nearest\")\n", "fig.colorbar(pcol, ax=ax[2], label=\"ns\")\n", "fig.savefig(\"example_sky_skan.png\", dpi=150)" ] }, { "cell_type": "code", "execution_count": null, "id": "cda77fd9", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.18" } }, "nbformat": 4, "nbformat_minor": 5 }