Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FITS_tutorial2.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Open a FITS file whose primary array represents a spectrum (flux vs wavelength).

void FITS_tutorial2()
{
// We're gonna open a FITS file that contains the primary HDU and a little data table.
// The primary HDU is an array of 2 rows by 2040 columns, and they represent a radiation
// spectrum. The first row contains the flux data, whereas the second row the wavelengths.
// Data copyright: NASA
TString dir = gROOT->GetTutorialDir();
// Open primary HDU from file
TFITSHDU hdu(dir + "/fitsio/sample2.fits");
// Dump the HDUs within the FITS file
// and also their metadata
hdu.Print("F+");
// We now generate a TGraph from vectors
std::unique_ptr<TVectorD> Y(hdu.GetArrayRow(0));
std::unique_ptr<TVectorD> X(hdu.GetArrayRow(1));
TGraph gr(*X,*Y);
// Show the graphic
auto c = new TCanvas("c1", "FITS tutorial #2", 800, 800);
gr.DrawClone("BA");
}
#define c(i)
Definition RSha256.hxx:101
@ kRed
Definition Rtypes.h:66
#define X(type, name)
#define gROOT
Definition TROOT.h:406
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 with: gROOT->SetSelectedPad(c1).
Definition TObject.cxx:299
Basic string class.
Definition TString.h:139
TGraphErrors * gr
Definition legend1.C:25
Total: 2 HDUs
[0] IMAGE (PRIMARY)
SIMPLE = T / Standard FITS format
BITPIX = -32 / 32 bit IEEE floating point numbers
NAXIS = 2 / Number of axes
NAXIS1 = 2064 /
NAXIS2 = 2 /
EXTEND = T / There may be standard extensions
OPSIZE = 832 / PSIZE of original image
ORIGIN = 'ST-DADS ' / Institution that originated the FITS file
FITSDATE = '12/07/94' / Date FITS file was created
FILENAME = 'y19g0309t_cvt.c2h' / Original GEIS header file name with _cvt
ODATTYPE = 'FLOATING' / Original datatype
SDASMGNU = 2 / GCOUNT of original image
DADSFILE = 'Y19G0309T.C2F' /
DADSCLAS = 'CAL ' /
DADSDATE = '12-JUL-1994 02:44:39' /
CRVAL1 = 1.0000000000000 /
CRPIX1 = 1.0000000000000 /
CD1_1 = 1.0000000000000 /
DATAMIN = 0.00000000000000 /
DATAMAX = 2.7387550387959E-15 /
RA_APER = 182.63573015260 /
DEC_APER = 39.405888372580 /
FILLCNT = 0 /
ERRCNT = 0 /
FPKTTIME = 49099.133531036 /
LPKTTIME = 49099.133541164 /
CTYPE1 = 'PIXEL ' /
APER_POS = 'SINGLE ' /
PASS_DIR = 0 /
YPOS = -1516.0000000000 /
YTYPE = 'OBJ ' /
EXPOSURE = 31.249689102173 /
X_OFFSET = 0.00000000000000 /
Y_OFFSET = 0.00000000000000 /
= /
= / / GROUP PARAMETERS: OSS
= /
= / / GROUP PARAMETERS: PODPS
= /
= / / FOS DATA DESCRIPTOR KEYWORDS
INSTRUME = 'FOS ' / instrument in use
ROOTNAME = 'Y19G0309T ' / rootname of the observation set
FILETYPE = 'ERR ' / file type
BUNIT = 'ERGS/CM**2/S/A' / brightness units
= /
= / / GENERIC CONVERSION KEYWORDS
HEADER = T / science header line exists
TRAILER = F / reject array exists
YWRDSLIN = 516 / science words per packet
YLINSFRM = 5 / packets per frame
= /
= / / CALIBRATION FLAGS AND INDICATORS
GRNDMODE = 'SPECTROSCOPY ' / ground software mode
DETECTOR = 'AMBER ' / detector in use: amber, blue
APER_ID = 'B-2 ' / aperture id
POLAR_ID = 'C ' / polarizer id
POLANG = 0.0000000E+00 / initial angular position of polarizer
FGWA_ID = 'H57 ' / FGWA id
FCHNL = 0 / first channel
NCHNLS = 512 / number of channels
OVERSCAN = 5 / overscan number
NXSTEPS = 4 / number of x steps
YFGIMPEN = T / onboard GIMP correction enabled (T/F)
YFGIMPER = 'NO ' / error in onboard GIMP correction (YES/NO)
= /
= / / CALIBRATION REFERENCE FILES AND TABLES
DEFDDTBL = F / UDL disabled diode table used
BACHFILE = 'yref$b3m1128fy.r0h' / background header file
FL1HFILE = 'yref$baf13103y.r1h' / first flat-field header file
FL2HFILE = 'yref$n/a ' / second flat-field header file
IV1HFILE = 'yref$c3u13412y.r2h' / first inverse sensitivity header file
IV2HFILE = 'yref$n/a ' / second inverse sensitivity header file
RETHFILE = 'yref$n/a ' / waveplate retardation header file
DDTHFILE = 'yref$c861559ay.r4h' / disabled diode table header file
DQ1HFILE = 'yref$b2f1301qy.r5h' / first data quality initialization header file
DQ2HFILE = 'yref$n/a ' / second data quality initialization header file
CCG2 = 'mtab$a3d1145ly.cmg' / paired pulse correction parameters
CCS0 = 'ytab$a3d1145dy.cy0' / aperture parameters
CCS1 = 'ytab$aaj0732ay.cy1' / aperture position parameters
CCS2 = 'ytab$a3d1145fy.cy2' / sky emission line regions
CCS3 = 'ytab$a3d1145gy.cy3' / big and sky filter widths and prism X0
CCS4 = 'ytab$b9d1019my.cy4' / polarimetry parameters
CCS5 = 'ytab$a3d1145jy.cy5' / sky shifts
CCS6 = 'ytab$bck10546y.cy6' / wavelength coefficients
CCS7 = 'ytab$ba910502y.cy7' / GIMP correction scale factores
CCS8 = 'ytab$ba31407ly.cy8' / predicted background count rates
= /
= / / CALIBRATION SWITCHES
CNT_CORR = 'COMPLETE' / count to count rate conversion
OFF_CORR = 'OMIT ' / GIMP correction
PPC_CORR = 'COMPLETE' / paired pulse correction
BAC_CORR = 'COMPLETE' / background subtraction
GMF_CORR = 'COMPLETE' / scale reference background
FLT_CORR = 'COMPLETE' / flat-fielding
SKY_CORR = 'COMPLETE' / sky subtraction
WAV_CORR = 'COMPLETE' / wavelength scale generation
FLX_CORR = 'COMPLETE' / flux scale generation
ERR_CORR = 'COMPLETE' / propagated error computation
MOD_CORR = 'OMIT ' / ground software mode dependent reductions
= /
= / / PATTERN KEYWORDS
INTS = 2 / number of integrations
YBASE = -1516 / y base
YRANGE = 0 / y range
YSTEPS = 1 / number of y steps
YSPACE = 0.0000000E+00 / yrange * 32 / ysteps
SLICES = 1 / number of time slices
NPAT = 12 / number of patterns per readout
NREAD = 2 / number of readouts per memory clear
NMCLEARS = 1 / number of memory clears per acquisition
YSTEP1 = 'OBJ ' / first ystep data type: OBJ, SKY, BCK, NUL
YSTEP2 = 'NUL ' / second ystep data type: OBJ, SKY, BCK, NUL
YSTEP3 = 'NUL ' / third ystep data type: OBJ, SKY, BCK, NUL
XBASE = 0 / X-deflection base
XPITCH = 1521 / X-deflection pitch between diode
YPITCH = 1834 / Y-deflection pitch
= /
= / / CALIBRATION KEYWORDS
LIVETIME = 33333 / accumulator open time (unit=7.8125 microsec)
DEADTIME = 1280 / accumulator close time (unit=7.8125 microsec)
MAXCLK = 0 / maximum clock count
PA_APER = 0.2462417E+03 / position ang of aperture used with target (deg)
NOISELM = 65535 / burst noise rejection limit
OFFS_TAB = 'n/a ' / GIMP offsets (post-pipeline processing only)
MINWAVE = 4569.102 / minimum wavelength (angstroms)
MAXWAVE = 6817.517 / maximum wavelength (angstroms)
= /
= / / STATISTICAL KEYWORDS
DATE = '22/04/93 ' / date this file was written (dd/mm/yy)
PKTFMT = 96 / packet format code
PODPSFF = '0 ' / 0=(no podps fill), 1=(podps fill present)
STDCFFF = '0 ' / 0=(no st dcf fill), 1=(st dcf fill present)
STDCFFP = '0000 ' / st dcf fill pattern (hex)
= /
= / / APERTURE POSITION
RA_APER1 = 0.1826357301526E+03 / right ascension of the aperture (deg)
DECAPER1 = 0.3940588837258E+02 / declination of the aperture (deg)
= /
= / / EXPOSURE INFORMATION
EQUINOX = 'J2000 ' / equinox of the celestial coordinate system
SUNANGLE = 0.1225114E+03 / angle between sun and V1 axis (deg)
MOONANGL = 0.1191039E+03 / angle between moon and V1 axis (deg)
SUN_ALT = 0.4515910E+02 / altitude of the sun above Earth's limb (deg)
FGSLOCK = 'COARSE ' / commanded FGS lock (FINE,COARSE,GYROS,UNKNOWN)
= /
DATE-OBS = '22/04/93 ' / UT date of start of observation (dd/mm/yy)
TIME-OBS = '03:12:17 ' / UT time of start of observation (hh:mm:ss)
EXPSTART = 0.4909913202874E+05 / exposure start time (Modified Julian Date)
EXPEND = 0.4909913505303E+05 / exposure end time (Modified Julian Date)
EXPTIME = 0.2499975E+03 / exposure duration (seconds)--calculated
EXPFLAG = 'NORMAL ' / Exposure interruption indicator
= /
= / / TARGET & PROPOSAL ID
TARGNAME = 'NGC4151-CLOUD2 ' / proposer's target name
RA_TARG = 0.1826357301526E+03 / right ascension of the target (deg) (J2000)
DEC_TARG = 0.3940588837258E+02 / declination of the target (deg) (J2000)
= /
PROPOSID = 4220 / PEP proposal identifier
PEP_EXPO = '174.0000000 ' / PEP exposure identifier including sequence
LINENUM = '174.000 ' / PEP proposal line number
SEQLINE = ' ' / PEP line number of defined sequence
SEQNAME = ' ' / PEP define/use sequence name
[1] ASCII TABLE ('y19g0309t.c2h.tab')
XTENSION = 'TABLE '
BITPIX = 8
NAXIS = 2
NAXIS1 = 336
NAXIS2 = 2
PCOUNT = 0
GCOUNT = 1
TFIELDS = 19
EXTNAME = 'y19g0309t.c2h.tab'
TTYPE1 = 'CRVAL1 '
CRVAL1 = 'pixel number'
TFORM1 = 'D25.16 '
TBCOL1 = 1
TTYPE2 = 'CRPIX1 '
CRPIX1 = 'pixel number of reference pixel'
TFORM2 = 'E15.7 '
TBCOL2 = 29
TTYPE3 = 'CD1_1 '
CD1_1 = 'pixel increment'
TFORM3 = 'E15.7 '
TBCOL3 = 45
TTYPE4 = 'DATAMIN '
DATAMIN = 'the minimum value of the data'
TFORM4 = 'E15.7 '
TBCOL4 = 61
TTYPE5 = 'DATAMAX '
DATAMAX = 'the maximum value of the data'
TFORM5 = 'E15.7 '
TBCOL5 = 77
TTYPE6 = 'RA_APER '
RA_APER = 'right ascension of aperture (deg)'
TFORM6 = 'D25.16 '
TBCOL6 = 93
TTYPE7 = 'DEC_APER'
DEC_APER = 'declination of aperture (deg)'
TFORM7 = 'D25.16 '
TBCOL7 = 121
TTYPE8 = 'FILLCNT '
FILLCNT = 'number of segments containing fill'
TFORM8 = 'I11 '
TBCOL8 = 149
TTYPE9 = 'ERRCNT '
ERRCNT = 'the error count of the data'
TFORM9 = 'I11 '
TBCOL9 = 161
TTYPE10 = 'FPKTTIME'
FPKTTIME = 'the time of the first packet'
TFORM10 = 'D25.16 '
TBCOL10 = 173
TTYPE11 = 'LPKTTIME'
LPKTTIME = 'the time of the last packet'
TFORM11 = 'D25.16 '
TBCOL11 = 201
TTYPE12 = 'CTYPE1 '
CTYPE1 = 'the first coordinate type'
TFORM12 = 'A8 '
TBCOL12 = 229
TTYPE13 = 'APER_POS'
APER_POS = 'aperture used'
TFORM13 = 'A8 '
TBCOL13 = 241
TTYPE14 = 'PASS_DIR'
PASS_DIR = 'polarization pass direction'
TFORM14 = 'I11 '
TBCOL14 = 253
TTYPE15 = 'YPOS '
YPOS = 'y-position on photocathode'
TFORM15 = 'E15.7 '
TBCOL15 = 265
TTYPE16 = 'YTYPE '
YTYPE = 'observation type: OBJ, SKY, BCK'
TFORM16 = 'A4 '
TBCOL16 = 281
TTYPE17 = 'EXPOSURE'
EXPOSURE = 'exposure time per pixel (seconds)'
TFORM17 = 'E15.7 '
TBCOL17 = 289
TTYPE18 = 'X_OFFSET'
X_OFFSET = 'x_offset for GIMP correction (diodes)'
TFORM18 = 'E15.7 '
TBCOL18 = 305
TTYPE19 = 'Y_OFFSET'
Y_OFFSET = 'y_offset for GIMP correction (defl.units)'
TFORM19 = 'E15.7 '
TBCOL19 = 321
Author
Claudi Martinez

Definition in file FITS_tutorial2.C.