{ "cells": [ { "cell_type": "markdown", "id": "7497262a", "metadata": {}, "source": [ "# FITS_tutorial3\n", "Open a FITS file and retrieve the first plane of the image array\n", "as a TImage object.\n", "\n", "\n", "\n", "\n", "**Author:** Claudi Martinez \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:13 PM." ] }, { "cell_type": "markdown", "id": "516392e6", "metadata": {}, "source": [ "We open a FITS file that contains several image\n", "extensions. The primary HDU contains no data.\n", "Data copyright: NASA" ] }, { "cell_type": "markdown", "id": "fbe31ef3", "metadata": {}, "source": [ "Open extensions 1 to 5 from file" ] }, { "cell_type": "code", "execution_count": 1, "id": "0ebfaaa9", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:13:56.548690Z", "iopub.status.busy": "2026-05-19T20:13:56.548562Z", "iopub.status.idle": "2026-05-19T20:13:56.896483Z", "shell.execute_reply": "2026-05-19T20:13:56.895902Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Info in : The selected HDU contains an Image Extension\n", "Info in : The selected HDU contains an Image Extension\n", "Info in : The selected HDU contains an Image Extension\n", "Info in : The selected HDU contains an Image Extension\n", "Info in : The selected HDU contains an Image Extension\n" ] } ], "source": [ "TString dir = gROOT->GetTutorialDir();\n", "\n", "auto c = new TCanvas(\"c1\", \"FITS tutorial #1\", 800, 700);\n", "c->Divide(2, 3);\n", "for (auto i : ROOT::TSeqI(1, 6)) {\n", " TFITSHDU hdu(dir + \"/io/fitsio/sample3.fits\", i);\n", "\n", " TImage* im = (TImage *)hdu.ReadAsImage(0);\n", " c->cd(i);\n", " im->Draw();\n", "}" ] }, { "cell_type": "markdown", "id": "79f78b22", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "99d4bdb2", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:13:56.898211Z", "iopub.status.busy": "2026-05-19T20:13:56.898088Z", "iopub.status.idle": "2026-05-19T20:13:57.232793Z", "shell.execute_reply": "2026-05-19T20:13:57.232154Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gROOT->GetListOfCanvases()->Draw()" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }