Logo ROOT   6.18/05
Reference Guide
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
14void 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);
38 gr.DrawClone("BA");
39}
#define c(i)
Definition: RSha256.hxx:101
@ kRed
Definition: Rtypes.h:64
#define gROOT
Definition: TROOT.h:414
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
The Canvas class.
Definition: TCanvas.h:31
FITS file interface class.
Definition: TFITS.h:34
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad...
Definition: TObject.cxx:219
Basic string class.
Definition: TString.h:131
TGraphErrors * gr
Definition: legend1.C:25