ROOT
6.07/01
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tutorials
fitsio
FITS_tutorial4.C
Go to the documentation of this file.
1
// Open a FITS file whose primary array represents
2
// a spectrum (flux vs wavelength)
3
void
FITS_tutorial4
()
4
{
5
printf
(
"\n\n--------------------------------\n"
);
6
printf
(
"WELCOME TO FITS tutorial #4 !!!!\n"
);
7
printf
(
"--------------------------------\n"
);
8
printf
(
"We're gonna open a FITS file that contains the\n"
);
9
printf
(
"primary HDU and a little data table.\n"
);
10
printf
(
"The data table is extension #1 and it has 2 rows.\n"
);
11
printf
(
"We want to read only the rows that have the column\n"
);
12
printf
(
"named DATAMAX greater than 2e-15 (there's only 1\n"
);
13
printf
(
"matching row)\n"
);
14
printf
(
"Data copyright: NASA\n\n"
);
15
16
if
(!
gROOT
->IsBatch()) {
17
//printf("Press ENTER to start..."); getchar();
18
}
19
TString
dir
=
gSystem
->
DirName
(__FILE__);
20
21
//Open the table extension number 1)
22
TFITSHDU
*hdu =
new
TFITSHDU
(dir+
"/sample2.fits[1][DATAMAX > 2e-15]"
);
23
if
(hdu == 0) {
24
printf
(
"ERROR: could not access the HDU\n"
);
return
;
25
}
26
//printf("Press ENTER to see information about the table's columns..."); getchar();
27
hdu->
Print
(
"T"
);
28
29
printf
(
"\n\n........................................\n"
);
30
printf
(
"Press ENTER to see full table contents (maybe you should resize\n"
);
31
//printf("this window as large as possible before)..."); getchar();
32
hdu->
Print
(
"T+"
);
33
34
printf
(
"\n\n........................................\n"
);
35
//printf("Press ENTER to get only the DATAMAX value of the matched row..."); getchar();
36
TVectorD
*
v
= hdu->
GetTabRealVectorColumn
(
"DATAMAX"
);
37
printf
(
"%lg\n"
, (*v)[0]);
38
39
40
printf
(
"Does the matched row have DATAMAX > 2e-15? :-)\n"
);
41
42
//Clean up
43
delete
v
;
44
delete
hdu;
45
}
46
47
TVectorT< Double_t >
gROOT
#define gROOT
Definition:
TROOT.h:344
TString
Basic string class.
Definition:
TString.h:137
TSystem::DirName
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition:
TSystem.cxx:980
TFITSHDU
FITS file interface class.
Definition:
TFITS.h:40
TFITSHDU::Print
void Print(const Option_t *opt="") const
Print metadata.
Definition:
TFITS.cxx:722
FITS_tutorial4
void FITS_tutorial4()
Definition:
FITS_tutorial4.C:3
gSystem
R__EXTERN TSystem * gSystem
Definition:
TSystem.h:545
v
SVector< double, 2 > v
Definition:
Dict.h:5
TFITSHDU::GetTabRealVectorColumn
TVectorD * GetTabRealVectorColumn(Int_t colnum)
Get a real number-typed column from a table HDU given its column index (>=0).
Definition:
TFITS.cxx:1194
printf
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
dir
void dir(char *path=0)
Definition:
rootalias.C:30