{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plot Hillas parameters using PyWI-CTA" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jeremiedecock/pywi-cta-notebooks/master?filepath=tuto_1d_plot_hillas_parameters.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import required modules" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook requires PyWI-CTA for the I/O." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "import matplotlib.pyplot as plt\n", "\n", "import pywicta\n", "import pywicta.data\n", "from pywicta.io import geometry_converter\n", "from pywicta.io.images import image_generator\n", "from pywicta.io.images import plot_ctapipe_image\n", "\n", "from pywicta.io.images import plot_hillas_parameters_on_axes\n", "from pywicta.io.images import print_hillas_parameters\n", "\n", "print(pywicta.get_version())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get image" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The next cells define the list of images to use in this notebook.\n", "\n", "Images can be fetched from Fits files or from Simtel files.\n", "Fits files are much lighter and much faster to process than Simtel files but they are specific to PyWI-CTA and thus you first have to generate them from Simtel files using [the following script](). Also, contrary to Simtel files, a Fits files contains only one \"image\" (i.e. an unique event viewed from one unique telescope)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#pywicta.data.lst([\"lst_gamma_r104_prod3b-north_t1_e1016403_660GeV\", \"lst_gamma_r104_prod3b-north_t1_e6905_87GeV\"])\n", "pywicta.data.lst()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#CAM_ID = \"ASTRICam\"\n", "#CAM_ID = \"CHEC\"\n", "#CAM_ID = \"DigiCam\"\n", "#CAM_ID = \"FlashCam\"\n", "#CAM_ID = \"NectarCam\"\n", "CAM_ID = \"LSTCam\"\n", "\n", "IMG_PATH_LIST = pywicta.data.lst([\"lst_gamma_r104_prod3b-north_t1_e6905_87GeV\"])\n", "\n", "image_gen = image_generator(IMG_PATH_LIST,\n", " cam_filter_list=[CAM_ID],\n", " ctapipe_format=False)\n", "\n", "img = next(image_gen)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "img.meta" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot using pywicta" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Images comming from FITS files are stored in 2D arrays (mainly because the Sparce2D wavelet transform expects images stored in 2D arrays).\n", "But ctapipe uses a special 1D array representation for IACT images (defined in \"geom\" objects).\n", "Thus conversion has to be done prior to use ctapipe functions on images comming from Fits files (using the \"geometry_converter\" function)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geom1d = geometry_converter.get_geom1d(CAM_ID)\n", "\n", "img_ref_1d = geometry_converter.image_2d_to_1d(img.reference_image, CAM_ID)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "disp = plot_ctapipe_image(img_ref_1d,\n", " geom1d,\n", " title='Clean image',\n", " norm='lin',\n", " plot_axis=False)\n", "\n", "plot_hillas_parameters_on_axes(disp.axes,\n", " img_ref_1d,\n", " geom1d,\n", " hillas_implementation=2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print_hillas_parameters(img_ref_1d,\n", " CAM_ID,\n", " implementation=2)" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "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.6.6" } }, "nbformat": 4, "nbformat_minor": 2 }