Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FITS_tutorial4.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_FITS
3/// \notebook
4/// Open a FITS file whose primary array represents
5/// a spectrum (flux vs wavelength).
6///
7/// \macro_code
8/// \macro_output
9///
10/// \author Claudi Martinez
11
12void FITS_tutorial4()
13{
14 // We open a FITS file that contains the primary HDU and a little data table.
15 // The data table is extension #1 and it has 2 rows.
16 // We want to read only the rows that have the column named DATAMAX greater than 2e-15 (there's only 1
17 // matching row Data copyright: NASA
18
19 TString dir = gROOT->GetTutorialDir();
20
21 // Open the table extension number 1)
22 TFITSHDU hdu(dir + "/fitsio/sample2.fits[1][DATAMAX > 2e-15]");
23
24 hdu.Print("T");
25
26 hdu.Print("T+");
27
28 std::unique_ptr<TVectorD> vp(hdu.GetTabRealVectorColumn("DATAMAX"));
29 const auto &v = *vp;
30 std::cout << "v[0] = " << v[0] << std::endl;
31 std::cout << "Does the matched row have DATAMAX > 2e-15? :-)" << std::endl;
32}
#define gROOT
Definition TROOT.h:407
FITS file interface class.
Definition TFITS.h:35
Basic string class.
Definition TString.h:139