Logo ROOT   6.21/01
Reference Guide
FITS_tutorial4.C File Reference

Detailed Description

View in nbviewer Open in SWAN

Open a FITS file whose primary array represents a spectrum (flux vs wavelength).

void FITS_tutorial4()
{
// We open a FITS file that contains the primary HDU and a little data table.
// The data table is extension #1 and it has 2 rows.
// We want to read only the rows that have the column named DATAMAX greater than 2e-15 (there's only 1
// matching row Data copyright: NASA
TString dir = gROOT->GetTutorialDir();
// Open the table extension number 1)
TFITSHDU hdu(dir + "/fitsio/sample2.fits[1][DATAMAX > 2e-15]");
hdu.Print("T");
hdu.Print("T+");
std::unique_ptr<TVectorD> vp(hdu.GetTabRealVectorColumn("DATAMAX"));
const auto &v = *vp;
std::cout << "v[0] = " << v[0] << std::endl;
std::cout << "Does the matched row have DATAMAX > 2e-15? :-)" << std::endl;
}
CRVAL1 : REAL NUMBER
CRPIX1 : REAL NUMBER
CD1_1 : REAL NUMBER
DATAMIN : REAL NUMBER
DATAMAX : REAL NUMBER
RA_APER : REAL NUMBER
DEC_APER : REAL NUMBER
FILLCNT : REAL NUMBER
ERRCNT : REAL NUMBER
FPKTTIME : REAL NUMBER
LPKTTIME : REAL NUMBER
CTYPE1 : STRING
APER_POS : STRING
PASS_DIR : REAL NUMBER
YPOS : REAL NUMBER
YTYPE : STRING
EXPOSURE : REAL NUMBER
X_OFFSET : REAL NUMBER
Y_OFFSET : REAL NUMBER
CRVAL1 | CRPIX1 | CD1_1 | DATAMIN | DATAMAX | RA_APER | DEC_APER | FILLCNT | ERRCNT | FPKTTIME | LPKTTIME | CTYPE1 | APER_POS | PASS_DIR | YPOS | YTYPE | EXPOSURE | X_OFFSET | Y_OFFSET |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 | 1 | 1 | 0 | 2.7e-15 | 1.8e+02 | 39 | 0 | 0 | 4.9e+04 | 4.9e+04 | PIXEL | SINGLE | 0 | -1.5e+03 | OBJ | 31 | 0 | 0 |
v[0] = 2.73876e-15
Does the matched row have DATAMAX > 2e-15? :-)
Author
Claudi Martinez

Definition in file FITS_tutorial4.C.