Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
FITS_tutorial2.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_FITS
3 /// \notebook -draw
4 ///
5 /// Open a FITS file whose primary array represents
6 /// a spectrum (flux vs wavelength).
7 ///
8 /// \macro_image
9 /// \macro_code
10 /// \macro_output
11 ///
12 /// \author Claudi Martinez
13 
14 void FITS_tutorial2()
15 {
16  // We're gonna open a FITS file that contains the primary HDU and a little data table.
17  // The primary HDU is an array of 2 rows by 2040 columns, and they represent a radiation
18  // spectrum. The first row contains the flux data, whereas the second row the wavelengths.
19  // Data copyright: NASA
20 
21  TString dir = gROOT->GetTutorialDir();
22 
23  // Open primary HDU from file
24  TFITSHDU hdu(dir + "/fitsio/sample2.fits");
25 
26  // Dump the HDUs within the FITS file
27  // and also their metadata
28  hdu.Print("F+");
29 
30  // We now generate a TGraph from vectors
31  std::unique_ptr<TVectorD> Y(hdu.GetArrayRow(0));
32  std::unique_ptr<TVectorD> X(hdu.GetArrayRow(1));
33  TGraph gr(*X,*Y);
34 
35  // Show the graphic
36  auto c = new TCanvas("c1", "FITS tutorial #2", 800, 800);
37  gr.SetFillColor(kRed);
38  gr.DrawClone("BA");
39 }