Logo ROOT   6.18/05
Reference Guide
FITS_tutorial7.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_FITS
3/// \notebook
4///
5/// Open a FITS file that contains a catalog of astronomical objects
6/// and dump some of its columns
7///
8/// \macro_code
9/// \macro_output
10///
11/// \author Elizabeth Buckley-Geer
12
13void FITS_tutorial7()
14{
15 // We are going to open a table from a FITS file
16 // and print out three columns for some of the objects.
17 // This table contains a logical data type so this tutorial tests
18 // that we can read it correctly
19
20 TString dir = gROOT->GetTutorialDir();
21
22 // Open the table
23 TFITSHDU hdu(dir + "/fitsio/sample5.fits[1]");
24
25 // Read the ra, dec, flux_g and brick_primary columns
26
27 std::unique_ptr<TVectorD> vec1(hdu.GetTabRealVectorColumn("ra"));
28 std::unique_ptr<TVectorD> vec2(hdu.GetTabRealVectorColumn("dec"));
29 std::unique_ptr<TVectorD> vec3(hdu.GetTabRealVectorColumn("flux_g"));
30 std::unique_ptr<TVectorD> vec4(hdu.GetTabRealVectorColumn("brick_primary"));
31
32 for (auto i : ROOT::TSeqI(vec1->GetLwb(), vec1->GetUpb())) {
33 const auto bp = (*vec4)[i];
34 if (bp) {
35 const auto gflux = (*vec3)[i];
36 const auto ra = (*vec1)[i];
37 const auto dec = (*vec2)[i];
38 printf("RA %f DEC %f G-FLUX %f\n", ra, dec, gflux);
39 }
40 }
41}
#define gROOT
Definition: TROOT.h:414
A pseudo container class which is a generator of indices.
Definition: TSeq.hxx:66
FITS file interface class.
Definition: TFITS.h:34
Basic string class.
Definition: TString.h:131