{
"cells": [
{
"cell_type": "markdown",
"id": "ea52b94a",
"metadata": {},
"source": [
"# FITS_tutorial6\n",
"Open a FITS file whose primary array represents\n",
"a spectrum table (flux vs wavelength) and dump its columns\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:14 PM."
]
},
{
"cell_type": "markdown",
"id": "a49d8202",
"metadata": {},
"source": [
"We open a table from a FITS file\n",
"and dump its columns."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "672979b9",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:14:06.969919Z",
"iopub.status.busy": "2026-05-19T20:14:06.969810Z",
"iopub.status.idle": "2026-05-19T20:14:07.289255Z",
"shell.execute_reply": "2026-05-19T20:14:07.288426Z"
}
},
"outputs": [],
"source": [
"TString dir = gROOT->GetTutorialDir();"
]
},
{
"cell_type": "markdown",
"id": "0fece2ab",
"metadata": {},
"source": [
"Open the table"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c94a1929",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:14:07.291267Z",
"iopub.status.busy": "2026-05-19T20:14:07.291142Z",
"iopub.status.idle": "2026-05-19T20:14:07.494142Z",
"shell.execute_reply": "2026-05-19T20:14:07.493431Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Info in : The selected HDU contains a Table Extension\n"
]
}
],
"source": [
"TFITSHDU hdu(dir + \"/io/fitsio/sample4.fits[1]\");"
]
},
{
"cell_type": "markdown",
"id": "aa880572",
"metadata": {},
"source": [
"Show columns"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "28abe684",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:14:07.495946Z",
"iopub.status.busy": "2026-05-19T20:14:07.495827Z",
"iopub.status.idle": "2026-05-19T20:14:07.707000Z",
"shell.execute_reply": "2026-05-19T20:14:07.706506Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The table has 8 columns:\n",
" - Column 0: objId\n",
" - Column 1: ra\n",
" - Column 2: dec\n",
" - Column 3: mag\n",
" - Column 4: reddening\n",
" - Column 5: objType\n",
" - Column 6: mu_ra\n",
" - Column 7: mu_dec\n"
]
}
],
"source": [
"const auto nColumns = hdu.GetTabNColumns();\n",
"printf(\"The table has %d columns:\\n\", nColumns);\n",
"for (auto i : ROOT::TSeqI(nColumns)) {\n",
" printf(\" - Column %d: %s\\n\", i, hdu.GetColumnName(i).Data());\n",
"}"
]
},
{
"cell_type": "markdown",
"id": "69f2ae30",
"metadata": {},
"source": [
"Draw all canvases "
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "b3711e62",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:14:07.708821Z",
"iopub.status.busy": "2026-05-19T20:14:07.708702Z",
"iopub.status.idle": "2026-05-19T20:14:07.913173Z",
"shell.execute_reply": "2026-05-19T20:14:07.912681Z"
}
},
"outputs": [],
"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
}