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_tutorial3.C
Go to the documentation of this file.
1
// Open a FITS file and retrieve the first plane of the image array
2
// as a TImage object
3
void
FITS_tutorial3
()
4
{
5
printf
(
"\n\n--------------------------------\n"
);
6
printf
(
"WELCOME TO FITS tutorial #3 !!!!\n"
);
7
printf
(
"--------------------------------\n"
);
8
printf
(
"We're gonna open a FITS file that contains several image\n"
);
9
printf
(
"extensions. The primary HDU contains no data.\n"
);
10
printf
(
"Data copyright: NASA\n\n"
);
11
12
if
(!
gROOT
->IsBatch()) {
13
//printf("Press ENTER to start..."); getchar();
14
}
15
16
// Open extensions 1 to 5 from file
17
//printf("Press ENTER to see a canvas with all images within the file:"); getchar();
18
TString
dir
=
gSystem
->
DirName
(__FILE__);
19
20
TCanvas
*
c
=
new
TCanvas
(
"c1"
,
"FITS tutorial #1"
, 800, 700);
21
c->
Divide
(2,3);
22
for
(
int
i=1; i <= 5; i++) {
23
TFITSHDU
*hdu =
new
TFITSHDU
(dir+
"/sample3.fits"
, i);
24
if
(hdu == 0) {
25
printf
(
"ERROR: could not access the HDU\n"
);
return
;
26
}
27
28
TImage
*im = hdu->
ReadAsImage
(0);
29
c->
cd
(i);
30
im->
Draw
();
31
delete
hdu;
32
}
33
}
34
35
c
return c
Definition:
entrylist_figure1.C:47
TCanvas::cd
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition:
TCanvas.cxx:659
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
TObject::Draw
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition:
TObject.cxx:254
TImage
An abstract interface to image processing library.
Definition:
TImage.h:45
TFITSHDU
FITS file interface class.
Definition:
TFITS.h:40
gSystem
R__EXTERN TSystem * gSystem
Definition:
TSystem.h:545
TCanvas
The Canvas class.
Definition:
TCanvas.h:48
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
FITS_tutorial3
void FITS_tutorial3()
Definition:
FITS_tutorial3.C:3
TPad::Divide
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Definition:
TPad.cxx:1073
TFITSHDU::ReadAsImage
TImage * ReadAsImage(Int_t layer=0, TImagePalette *pal=0)
Read image HDU as a displayable image.
Definition:
TFITS.cxx:744