Logo ROOT  
Reference Guide
FITS_tutorial2.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_FITS
3/// \notebook -draw
4/// Open a FITS file whose primary array represents
5/// a spectrum (flux vs wavelength).
6///
7/// \macro_image
8/// \macro_code
9/// \macro_output
10///
11/// \author Claudi Martinez
12
13void FITS_tutorial2()
14{
15 // We're gonna open a FITS file that contains the primary HDU and a little data table.
16 // The primary HDU is an array of 2 rows by 2040 columns, and they represent a radiation
17 // spectrum. The first row contains the flux data, whereas the second row the wavelengths.
18 // Data copyright: NASA
19
20 TString dir = gROOT->GetTutorialDir();
21
22 // Open primary HDU from file
23 TFITSHDU hdu(dir + "/fitsio/sample2.fits");
24
25 // Dump the HDUs within the FITS file
26 // and also their metadata
27 hdu.Print("F+");
28
29 // We now generate a TGraph from vectors
30 std::unique_ptr<TVectorD> Y(hdu.GetArrayRow(0));
31 std::unique_ptr<TVectorD> X(hdu.GetArrayRow(1));
32 TGraph gr(*X,*Y);
33
34 // Show the graphic
35 auto c = new TCanvas("c1", "FITS tutorial #2", 800, 800);
37 gr.DrawClone("BA");
38}
#define c(i)
Definition: RSha256.hxx:101
@ kRed
Definition: Rtypes.h:66
#define gROOT
Definition: TROOT.h:404
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
The Canvas class.
Definition: TCanvas.h:23
FITS file interface class.
Definition: TFITS.h:35
A TGraph is an 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:221
Basic string class.
Definition: TString.h:136
TGraphErrors * gr
Definition: legend1.C:25