{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# DRS4 baseline 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": [ "\n", "file = \"../../../test_data/real/service/PixelCalibration/Cat-A/drs4_baseline/20200218/pro/drs4_pedestal.Run02005.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": [ "key=get_dataset_keys(file)\n", "key " ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "### Data " ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": {}, "outputs": [], "source": [ "# Date used for calibration are:\n", "# - baseline_mean : baseline to be subtracted per channel/pixel/capacitor (2, 1855, 4096)\n", "# - spike_height : spike to be subtracted, per channel/pixel/spike-type (2, 1855, 3)\n", "\n", "drs4_data = hdf5_f.root.r1.monitoring.drs4_baseline.tel_001[0]\n", "drs4_data[\"baseline_mean\"]" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "# other way, with ctapipe\n", "from ctapipe.io import read_table\n", "# read the table\n", "table = read_table(file, key[0])\n", "table" ] }, { "cell_type": "markdown", "id": "9", "metadata": {}, "source": [ "### Meta-data " ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "hdf5_f.root._v_attrs " ] }, { "cell_type": "code", "execution_count": null, "id": "11", "metadata": {}, "outputs": [], "source": [ "# plot baseline as function of capacitor for a given pixel\n", "pixel=0\n", "channel=[\"HG\",\"LG\"]\n", "baseline=drs4_data[\"baseline_mean\"]\n", "\n", "fig, ax = plt.subplots(1, 2, figsize=(12,6),constrained_layout=True)\n", "for chan in np.arange(2):\n", " label=f\"channel {channel[chan]}\"\n", " ax[chan].grid(True)\n", " ax[chan].set_ylim(380,420)\n", " ped_median=np.median(baseline[chan,pixel,:])\n", " ax[chan].plot(baseline[chan,pixel,:],label=label)\n", " ax[chan].axhline(ped_median, color='red',linestyle=\"--\")\n", " ax[chan].set_ylabel(f'baseline [ADC]',fontsize=20) \n", " ax[chan].set_xlabel(f'capacitor',fontsize=20) \n", " \n", " ax[chan].legend(prop={'size':15})\n" ] }, { "cell_type": "code", "execution_count": null, "id": "12", "metadata": {}, "outputs": [], "source": [ "# plot the spikes\n", "spike_data=drs4_data[\"spike_height\"]\n", "fig, ax = plt.subplots(1, 2, figsize=(12,6),constrained_layout=True)\n", "for chan in np.arange(2):\n", " label=f\"channel {channel[chan]}\"\n", " ax[chan].set_title(label, fontsize=15)\n", " ax[chan].grid(True)\n", " \n", " for spike in np.arange(3):\n", " label=f\"spike {spike}: median {np.median(spike_data[chan,:,spike]):3.1f}\"\n", " ax[chan].hist(spike_data[chan,:,spike], label=label)\n", " \n", " ax[chan].set_xlabel(f'spikes [ADC]',fontsize=20) \n", " ax[chan].set_ylabel(f'pixel',fontsize=20) \n", "\n", " ax[chan].legend(prop={'size':15})\n" ] }, { "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/drs4_baseline/20200218/pro/drs4_pedestal.Run02005.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[\"BASELINE_MEAN\"].data" ] }, { "cell_type": "markdown", "id": "19", "metadata": {}, "source": [ "### Meta-data " ] }, { "cell_type": "code", "execution_count": null, "id": "20", "metadata": {}, "outputs": [], "source": [ "fits_f[\"PRIMARY\"].header" ] }, { "cell_type": "code", "execution_count": null, "id": "21", "metadata": {}, "outputs": [], "source": [ "fits_f[\"BASELINE_MEAN\"].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 }