Logo ROOT  
Reference Guide
FITS_tutorial7.C File Reference

Detailed Description

View in nbviewer Open in SWAN

Open a FITS file that contains a catalog of astronomical objects and dump some of its columns

void FITS_tutorial7()
{
// 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);
}
}
}
RA 0.052712 DEC -0.362697 G-FLUX 1459.757935
RA 0.037071 DEC -0.357002 G-FLUX 5.139085
RA 0.032357 DEC -0.343962 G-FLUX 1.975864
RA 0.056218 DEC -0.374812 G-FLUX 0.981831
RA 0.061045 DEC -0.351853 G-FLUX 9.577291
RA 0.029734 DEC -0.342025 G-FLUX 0.805801
RA 0.071794 DEC -0.337535 G-FLUX 0.098234
RA 0.047283 DEC -0.348819 G-FLUX 2.887166
RA 0.063552 DEC -0.347375 G-FLUX 0.146420
RA 0.030166 DEC -0.344619 G-FLUX 0.284864
RA 0.069112 DEC -0.340087 G-FLUX 0.208166
RA 0.034459 DEC -0.372217 G-FLUX 0.413114
RA 0.058054 DEC -0.363081 G-FLUX 198.251205
RA 0.045903 DEC -0.349340 G-FLUX 3.730938
RA 0.054945 DEC -0.348756 G-FLUX 2.615938
RA 0.028211 DEC -0.342269 G-FLUX 0.034026
RA 0.059028 DEC -0.373087 G-FLUX 0.019045
RA 0.028507 DEC -0.339828 G-FLUX 0.309177
RA 0.034627 DEC -0.346718 G-FLUX 0.635741
RA 0.061070 DEC -0.345548 G-FLUX 0.242501
RA 0.061696 DEC -0.356539 G-FLUX 9.238210
RA 0.061587 DEC -0.371503 G-FLUX 5.064604
RA 0.050000 DEC -0.368469 G-FLUX 390.441345
RA 0.033772 DEC -0.366471 G-FLUX 0.180956
RA 0.073349 DEC -0.358763 G-FLUX 0.101244
RA 0.060981 DEC -0.354487 G-FLUX 0.757379
RA 0.034770 DEC -0.354675 G-FLUX 0.667123
RA 0.037716 DEC -0.366188 G-FLUX 32.245857
RA 0.034256 DEC -0.358326 G-FLUX 0.623143
RA 0.032029 DEC -0.342240 G-FLUX 0.074649
RA 0.057473 DEC -0.348615 G-FLUX 0.263933
RA 0.052388 DEC -0.345721 G-FLUX 1.497776
RA 0.043028 DEC -0.366264 G-FLUX 256.985260
RA 0.042472 DEC -0.372011 G-FLUX 1.392641
RA 0.055799 DEC -0.349283 G-FLUX 1.202020
RA 0.055537 DEC -0.358403 G-FLUX 18.192368
RA 0.034308 DEC -0.363553 G-FLUX 1.304242
RA 0.066448 DEC -0.342677 G-FLUX 0.366185
RA 0.036038 DEC -0.347978 G-FLUX 7.926686
RA 0.068389 DEC -0.357119 G-FLUX 0.450458
RA 0.067954 DEC -0.358446 G-FLUX 0.129933
RA 0.036134 DEC -0.370481 G-FLUX -0.195327
RA 0.048735 DEC -0.360530 G-FLUX 329491.750000
RA 0.224885 DEC -0.374596 G-FLUX 0.916501
RA 0.226318 DEC -0.374222 G-FLUX 0.113676
RA 0.223727 DEC -0.374312 G-FLUX 0.133866
RA 0.225505 DEC -0.372494 G-FLUX 0.091185
RA 0.227895 DEC -0.373918 G-FLUX 0.056656
RA 0.102478 DEC -0.372888 G-FLUX 12566.606445
RA 0.102551 DEC -0.372634 G-FLUX 68.942551
RA 0.108034 DEC -0.367427 G-FLUX 0.211915
RA 0.104215 DEC -0.374640 G-FLUX 11.440659
RA 0.105298 DEC -0.367680 G-FLUX 0.139645
RA 0.193002 DEC -0.372531 G-FLUX 0.180791
RA 0.249230 DEC -0.374757 G-FLUX 0.068739
RA 0.248291 DEC -0.374980 G-FLUX 1.432089
RA 0.022928 DEC -0.374486 G-FLUX 0.169427
RA 0.214647 DEC -0.374137 G-FLUX 0.016568
RA 0.038795 DEC -0.374764 G-FLUX 1.306070
RA 0.074997 DEC -0.374646 G-FLUX 0.229814
RA 0.243627 DEC -0.374658 G-FLUX 0.045574
Author
Elizabeth Buckley-Geer

Definition in file FITS_tutorial7.C.

TString
Definition: TString.h:136
TFITSHDU
Definition: TFITS.h:35
ROOT::TSeq
A pseudo container class which is a generator of indices.
Definition: TSeq.hxx:66
gROOT
#define gROOT
Definition: TROOT.h:406