Open a FITS file that contains a catalog of astronomical objects and dump some of its columns
Author: Elizabeth Buckley-Geer
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Thursday, January 21, 2021 at 09:31 AM.
We are going to open a table from a fits file and print out three columns for some of the objects. This table contains a logical data type so this tutorial tests that we can read it correctly
TString dir = gROOT->GetTutorialDir();
Open the table
TFITSHDU hdu(dir + "/fitsio/sample5.fits[1]");
Read the ra, dec, flux_g and brick_primary columns
std::unique_ptr<TVectorD> vec1(hdu.GetTabRealVectorColumn("ra"));
std::unique_ptr<TVectorD> vec2(hdu.GetTabRealVectorColumn("dec"));
std::unique_ptr<TVectorD> vec3(hdu.GetTabRealVectorColumn("flux_g"));
std::unique_ptr<TVectorD> vec4(hdu.GetTabRealVectorColumn("brick_primary"));
for (auto i : ROOT::TSeqI(vec1->GetLwb(), vec1->GetUpb())) {
const auto bp = (*vec4)[i];
if (bp) {
const auto gflux = (*vec3)[i];
const auto ra = (*vec1)[i];
const auto dec = (*vec2)[i];
printf("RA %f DEC %f G-FLUX %f\n", ra, dec, gflux);
}
}
Draw all canvases
gROOT->GetListOfCanvases()->Draw()