Logo ROOT   6.08/07
Reference Guide
FITS_tutorial3.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_FITS
3 /// Open a FITS file and retrieve the first plane of the image array
4 /// as a TImage object
5 ///
6 /// \macro_code
7 ///
8 /// \author Claudi Martinez
9 
10 void FITS_tutorial3()
11 {
12  printf("\n\n--------------------------------\n");
13  printf("WELCOME TO FITS tutorial #3 !!!!\n");
14  printf("--------------------------------\n");
15  printf("We're gonna open a FITS file that contains several image\n");
16  printf("extensions. The primary HDU contains no data.\n");
17  printf("Data copyright: NASA\n\n");
18 
19  if (!gROOT->IsBatch()) {
20  //printf("Press ENTER to start..."); getchar();
21  }
22 
23  // Open extensions 1 to 5 from file
24  //printf("Press ENTER to see a canvas with all images within the file:"); getchar();
25  TString dir = gSystem->DirName(__FILE__);
26 
27  TCanvas *c = new TCanvas("c1", "FITS tutorial #1", 800, 700);
28  c->Divide(2,3);
29  for (int i=1; i <= 5; i++) {
30  TFITSHDU *hdu = new TFITSHDU(dir+"/sample3.fits", i);
31  if (hdu == 0) {
32  printf("ERROR: could not access the HDU\n"); return;
33  }
34 
35  TImage *im = hdu->ReadAsImage(0);
36  c->cd(i);
37  im->Draw();
38  delete hdu;
39  }
40 }
return c
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Definition: TCanvas.cxx:659
#define gROOT
Definition: TROOT.h:364
Basic string class.
Definition: TString.h:137
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition: TSystem.cxx:997
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:255
An abstract interface to image processing library.
Definition: TImage.h:37
FITS file interface class.
Definition: TFITS.h:40
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
The Canvas class.
Definition: TCanvas.h:41
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:1089
TImage * ReadAsImage(Int_t layer=0, TImagePalette *pal=0)
Read image HDU as a displayable image.
Definition: TFITS.cxx:744