{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Calibration files" ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "import tables\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from lstcam_calib.io import get_dataset_keys\n" ] }, { "cell_type": "markdown", "id": "2", "metadata": {}, "source": [ "## HDF5 format" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "file = \"../../../test_data/real/service/PixelCalibration/Cat-A/calibration//20200218/pro/calibration_filters_52.Run02006.0000.h5\"\n", "hdf5_f=tables.open_file(file, \"r\")\n", "hdf5_f" ] }, { "cell_type": "markdown", "id": "4", "metadata": {}, "source": [ "### Keys" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "keys=get_dataset_keys(file)\n", "keys " ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "### Data " ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": {}, "outputs": [], "source": [ "# one can access per array\n", "calibration = hdf5_f.root.tel_1.calibration[0]\n", "calibration[\"dc_to_pe\"]" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "# or use read_table for ctapipe\n", "\n", "from ctapipe.io import read_table\n", "\n", "table = read_table(file, keys[0])\n", "table\n" ] }, { "cell_type": "code", "execution_count": null, "id": "9", "metadata": {}, "outputs": [], "source": [ "# or fill the ctapipe monitoring container with a lstcam_calib reading function\n", "\n", "from lstcam_calib.io.calibration import read_calibration_file\n", "\n", "monitoring = read_calibration_file(file)\n", "\n", "monitoring\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "monitoring.calibration" ] }, { "cell_type": "markdown", "id": "11", "metadata": {}, "source": [ "### Meta-data " ] }, { "cell_type": "code", "execution_count": null, "id": "12", "metadata": {}, "outputs": [], "source": [ "hdf5_f.root._v_attrs \n", "# or\n", "monitoring.meta" ] }, { "cell_type": "markdown", "id": "13", "metadata": {}, "source": [ "## Fits format " ] }, { "cell_type": "code", "execution_count": null, "id": "14", "metadata": {}, "outputs": [], "source": [ "from astropy.io import fits\n", "\n", "file = \"../../../test_data/real/service/PixelCalibration/Cat-A/calibration//20200218/pro/calibration_filters_52.Run02006.0000.fits.gz\"\n", "fits_f = fits.open(file)\n" ] }, { "cell_type": "markdown", "id": "15", "metadata": {}, "source": [ "### HDU" ] }, { "cell_type": "code", "execution_count": null, "id": "16", "metadata": {}, "outputs": [], "source": [ "fits_f.info()" ] }, { "cell_type": "markdown", "id": "17", "metadata": {}, "source": [ "### Data" ] }, { "cell_type": "code", "execution_count": null, "id": "18", "metadata": {}, "outputs": [], "source": [ "fits_f[\"CALIBRATION\"].data" ] }, { "cell_type": "code", "execution_count": null, "id": "19", "metadata": {}, "outputs": [], "source": [ "# or with astropy tables\n", "from astropy.table import QTable\n", "QTable.read(file, hdu='CALIBRATION') \n" ] }, { "cell_type": "code", "execution_count": null, "id": "20", "metadata": {}, "outputs": [], "source": [ "# or fill the ctapipe monitoring container with a lstcam_calib reading function\n", "\n", "from lstcam_calib.io.calibration import read_calibration_file\n", "\n", "monitoring = read_calibration_file(file)\n", "\n", "monitoring\n" ] }, { "cell_type": "markdown", "id": "21", "metadata": {}, "source": [ "### Meta-data " ] }, { "cell_type": "code", "execution_count": null, "id": "22", "metadata": {}, "outputs": [], "source": [ "fits_f[\"PRIMARY\"].header" ] }, { "cell_type": "code", "execution_count": null, "id": "23", "metadata": {}, "outputs": [], "source": [ "fits_f[\"CALIBRATION\"].header" ] } ], "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.11.10" } }, "nbformat": 4, "nbformat_minor": 5 }