{ "cells": [ { "cell_type": "markdown", "id": "dc260be6", "metadata": {}, "source": [ "# FITS_tutorial7\n", "Open a FITS file that contains a catalog of astronomical objects\n", "and dump some of its columns\n", "\n", "\n", "\n", "\n", "**Author:** Elizabeth Buckley-Geer \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": "0b7b9f31", "metadata": {}, "source": [ "We are going to open a table from a FITS file\n", "and print out three columns for some of the objects.\n", "This table contains a logical data type so this tutorial tests\n", "that we can read it correctly" ] }, { "cell_type": "code", "execution_count": 1, "id": "785e0800", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:14:07.582415Z", "iopub.status.busy": "2026-05-19T20:14:07.582309Z", "iopub.status.idle": "2026-05-19T20:14:07.917907Z", "shell.execute_reply": "2026-05-19T20:14:07.916857Z" } }, "outputs": [], "source": [ "TString dir = gROOT->GetTutorialDir();" ] }, { "cell_type": "markdown", "id": "c9111dc4", "metadata": {}, "source": [ "Open the table" ] }, { "cell_type": "code", "execution_count": 2, "id": "98448df1", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:14:07.919510Z", "iopub.status.busy": "2026-05-19T20:14:07.919383Z", "iopub.status.idle": "2026-05-19T20:14:08.122728Z", "shell.execute_reply": "2026-05-19T20:14:08.122123Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Info in : The selected HDU contains a Table Extension\n" ] } ], "source": [ "TFITSHDU hdu(dir + \"/io/fitsio/sample5.fits[1]\");" ] }, { "cell_type": "markdown", "id": "cbd6b722", "metadata": {}, "source": [ "Read the ra, dec, flux_g and brick_primary columns" ] }, { "cell_type": "code", "execution_count": 3, "id": "2a2a68aa", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:14:08.124396Z", "iopub.status.busy": "2026-05-19T20:14:08.124206Z", "iopub.status.idle": "2026-05-19T20:14:08.328318Z", "shell.execute_reply": "2026-05-19T20:14:08.327767Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "RA 0.052712 DEC -0.362697 G-FLUX 1459.757935\n", "RA 0.037071 DEC -0.357002 G-FLUX 5.139085\n", "RA 0.032357 DEC -0.343962 G-FLUX 1.975864\n", "RA 0.056218 DEC -0.374812 G-FLUX 0.981831\n", "RA 0.061045 DEC -0.351853 G-FLUX 9.577291\n", "RA 0.029734 DEC -0.342025 G-FLUX 0.805801\n", "RA 0.071794 DEC -0.337535 G-FLUX 0.098234\n", "RA 0.047283 DEC -0.348819 G-FLUX 2.887166\n", "RA 0.063552 DEC -0.347375 G-FLUX 0.146420\n", "RA 0.030166 DEC -0.344619 G-FLUX 0.284864\n", "RA 0.069112 DEC -0.340087 G-FLUX 0.208166\n", "RA 0.034459 DEC -0.372217 G-FLUX 0.413114\n", "RA 0.058054 DEC -0.363081 G-FLUX 198.251205\n", "RA 0.045903 DEC -0.349340 G-FLUX 3.730938\n", "RA 0.054945 DEC -0.348756 G-FLUX 2.615938\n", "RA 0.028211 DEC -0.342269 G-FLUX 0.034026\n", "RA 0.059028 DEC -0.373087 G-FLUX 0.019045\n", "RA 0.028507 DEC -0.339828 G-FLUX 0.309177\n", "RA 0.034627 DEC -0.346718 G-FLUX 0.635741\n", "RA 0.061070 DEC -0.345548 G-FLUX 0.242501\n", "RA 0.061696 DEC -0.356539 G-FLUX 9.238210\n", "RA 0.061587 DEC -0.371503 G-FLUX 5.064604\n", "RA 0.050000 DEC -0.368469 G-FLUX 390.441345\n", "RA 0.033772 DEC -0.366471 G-FLUX 0.180956\n", "RA 0.073349 DEC -0.358763 G-FLUX 0.101244\n", "RA 0.060981 DEC -0.354487 G-FLUX 0.757379\n", "RA 0.034770 DEC -0.354675 G-FLUX 0.667123\n", "RA 0.037716 DEC -0.366188 G-FLUX 32.245857\n", "RA 0.034256 DEC -0.358326 G-FLUX 0.623143\n", "RA 0.032029 DEC -0.342240 G-FLUX 0.074649\n", "RA 0.057473 DEC -0.348615 G-FLUX 0.263933\n", "RA 0.052388 DEC -0.345721 G-FLUX 1.497776\n", "RA 0.043028 DEC -0.366264 G-FLUX 256.985260\n", "RA 0.042472 DEC -0.372011 G-FLUX 1.392641\n", "RA 0.055799 DEC -0.349283 G-FLUX 1.202020\n", "RA 0.055537 DEC -0.358403 G-FLUX 18.192368\n", "RA 0.034308 DEC -0.363553 G-FLUX 1.304242\n", "RA 0.066448 DEC -0.342677 G-FLUX 0.366185\n", "RA 0.036038 DEC -0.347978 G-FLUX 7.926686\n", "RA 0.068389 DEC -0.357119 G-FLUX 0.450458\n", "RA 0.067954 DEC -0.358446 G-FLUX 0.129933\n", "RA 0.036134 DEC -0.370481 G-FLUX -0.195327\n", "RA 0.048735 DEC -0.360530 G-FLUX 329491.750000\n", "RA 0.224885 DEC -0.374596 G-FLUX 0.916501\n", "RA 0.226318 DEC -0.374222 G-FLUX 0.113676\n", "RA 0.223727 DEC -0.374312 G-FLUX 0.133866\n", "RA 0.225505 DEC -0.372494 G-FLUX 0.091185\n", "RA 0.227895 DEC -0.373918 G-FLUX 0.056656\n", "RA 0.102478 DEC -0.372888 G-FLUX 12566.606445\n", "RA 0.102551 DEC -0.372634 G-FLUX 68.942551\n", "RA 0.108034 DEC -0.367427 G-FLUX 0.211915\n", "RA 0.104215 DEC -0.374640 G-FLUX 11.440659\n", "RA 0.105298 DEC -0.367680 G-FLUX 0.139645\n", "RA 0.193002 DEC -0.372531 G-FLUX 0.180791\n", "RA 0.249230 DEC -0.374757 G-FLUX 0.068739\n", "RA 0.248291 DEC -0.374980 G-FLUX 1.432089\n", "RA 0.022928 DEC -0.374486 G-FLUX 0.169427\n", "RA 0.214647 DEC -0.374137 G-FLUX 0.016568\n", "RA 0.038795 DEC -0.374764 G-FLUX 1.306070\n", "RA 0.074997 DEC -0.374646 G-FLUX 0.229814\n", "RA 0.243627 DEC -0.374658 G-FLUX 0.045574\n" ] } ], "source": [ "std::unique_ptr vec1(hdu.GetTabRealVectorColumn(\"ra\"));\n", "std::unique_ptr vec2(hdu.GetTabRealVectorColumn(\"dec\"));\n", "std::unique_ptr vec3(hdu.GetTabRealVectorColumn(\"flux_g\"));\n", "std::unique_ptr vec4(hdu.GetTabRealVectorColumn(\"brick_primary\"));\n", "\n", "for (auto i : ROOT::TSeqI(vec1->GetLwb(), vec1->GetUpb())) {\n", " const auto bp = (*vec4)[i];\n", " if (bp) {\n", " const auto gflux = (*vec3)[i];\n", " const auto ra = (*vec1)[i];\n", " const auto dec = (*vec2)[i];\n", " printf(\"RA %f DEC %f G-FLUX %f\\n\", ra, dec, gflux);\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "9095112d", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 4, "id": "e2f44091", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:14:08.329935Z", "iopub.status.busy": "2026-05-19T20:14:08.329817Z", "iopub.status.idle": "2026-05-19T20:14:08.534277Z", "shell.execute_reply": "2026-05-19T20:14:08.533649Z" } }, "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 }