Logo ROOT   6.12/07
Reference Guide
FITS_tutorial6.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_FITS
3 /// Open a FITS file whose primary array represents
4 /// a spectrum table (flux vs wavelength) and dump its columns
5 ///
6 /// \macro_code
7 ///
8 /// \author Claudi Martinez
9 
10 void FITS_tutorial6()
11 {
12  TVectorD *v;
13 
14  printf("\n\n--------------------------------\n");
15  printf("WELCOME TO FITS tutorial #6 !!!!\n");
16  printf("--------------------------------\n");
17  printf("We are going to open a table from a FITS file\n");
18  printf("and dump its columns.\n\n");
19 
20  TString dir = gSystem->DirName(__FILE__);
21 
22  //Open the table
23  TFITSHDU *hdu = new TFITSHDU(dir+"/sample4.fits[1]");
24  if (hdu == 0) {
25  printf("ERROR: could not access the HDU\n"); return;
26  }
27 
28  //Show columns
29  Int_t nColumns = hdu->GetTabNColumns();
30  printf("The table has %d columns:\n", nColumns);
31  for (Int_t i = 0; i < nColumns; i++) {
32  printf("...Column %d: %s\n", i, hdu->GetColumnName(i).Data());
33  }
34  puts("");
35 
36  delete hdu;
37 }
Int_t GetTabNColumns() const
Definition: TFITS.h:118
TVectorT.
Definition: TMatrixTBase.h:77
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition: TSystem.cxx:1004
FITS file interface class.
Definition: TFITS.h:34
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
SVector< double, 2 > v
Definition: Dict.h:5
const TString & GetColumnName(Int_t colnum)
Get the name of a column given its index (column>=0).
Definition: TFITS.cxx:1457
const char * Data() const
Definition: TString.h:345