Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/graf2d:$Id$
2// Author: Claudi Martinez, July 19th 2010
5 * Copyright (C) 1995-2010, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
12#ifndef ROOT_TFITS
13#define ROOT_TFITS
16// //
17// TFITS //
18// //
19// Interface to FITS astronomical files. //
20// Please, see TFITS.cxx for info about implementation //
23#include "TNamed.h"
24#include "TMatrixDfwd.h"
25#include "TVectorDfwd.h"
26#include <vector>
28class TArrayI;
29class TArrayD;
30class TH1;
31class TImage;
32class TImagePalette;
33class TObjArray;
35class TFITSHDU : public TNamed {
38 void _release_resources();
39 void _initialize_me();
42 enum EHDUTypes { // HDU types
45 };
47 enum EColumnTypes { // Column data types
48 kString, // the column contains a string
49 kRealNumber, // the column contains a scalar
50 kRealArray, // the column contains a fixed-length array
51 kRealVector // the column contains a variable-length array
52 };
54 struct HDURecord { // FITS HDU record
58 };
60 struct Column { // Information of a table column
61 TString fName; // Column's name
62 enum EColumnTypes fType; // Column's data type
63 Int_t fDim; // When cells contain real number arrays, this field indicates
64 // the dimension of this vector (number of components), being 1 for scalars.
65 Bool_t fVariable; // kTRUE if the columns has variable-length arrays
66 std::vector<int> fRowStart; // starting index of each row
67 std::vector<int> fVarLengths; // sizes of the individual varaiable-length arrays
68 };
70 union Cell { //Table cell contents
75 };
78 TString fFilePath; ///< Path to HDU's file including filter
79 TString fBaseFilePath; ///< Path to HDU's file excluding filter
80 struct HDURecord *fRecords; ///< HDU metadata records
81 Int_t fNRecords; ///< Number of records
82 enum EHDUTypes fType; ///< HDU type
83 TString fExtensionName; ///< Extension Name
84 Int_t fNumber; ///< HDU number (1=PRIMARY)
85 TArrayI *fSizes; ///< Image sizes in each dimension (when fType == kImageHDU)
86 TArrayD *fPixels; ///< Image pixels (when fType == kImageHDU)
87 struct Column *fColumnsInfo; ///< Information about columns (when fType == kTableHDU)
88 Int_t fNColumns; ///< Number of columns (when fType == kTableHDU)
89 Int_t fNRows; ///< Number of rows (when fType == kTableHDU)
90 union Cell *fCells; ///< Table cells (when fType == kTableHDU). Cells are ordered in the following way:
91 ///< fCells[0..fNRows-1] -> cells of column 0
92 ///< fCells[fNRows..2*fNRows-1] -> cells of column 1
93 ///< fCells[2*fNRows..3*fNRows-1] -> cells of column 2
94 ///< fCells[(fNColumns-1)*fNRows..fNColumns*fNRows-1] -> cells of column fNColumns-1
97 Bool_t LoadHDU(TString& filepath_filter);
98 static void CleanFilePath(const char *filepath_with_filter, TString &dst);
99 void PrintHDUMetadata(const Option_t *opt="") const;
100 void PrintFileMetadata(const Option_t *opt="") const;
101 void PrintColumnInfo(const Option_t *) const;
102 void PrintFullTable(const Option_t *) const;
105 TFITSHDU(const char *filepath_with_filter);
106 TFITSHDU(const char *filepath, Int_t extension_number);
107 TFITSHDU(const char *filepath, const char *extension_name);
108 ~TFITSHDU();
110 //Metadata access methods
111 Int_t GetRecordNumber() const { return fNRecords; }
112 struct HDURecord *GetRecord(const char *keyword);
113 TString& GetKeywordValue(const char *keyword);
114 void Print(const Option_t *opt="") const;
116 //Image readers
118 TImage *ReadAsImage(Int_t layer = 0, TImagePalette *pal = 0);
119 TMatrixD *ReadAsMatrix(Int_t layer = 0, Option_t *opt="");
123 //Table readers
124 Int_t GetTabNColumns() const { return fNColumns; }
125 Int_t GetTabNRows() const { return fNRows; }
126 Int_t GetColumnNumber(const char *colname);
127 const TString& GetColumnName(Int_t colnum);
129 TObjArray *GetTabStringColumn(const char *colname);
131 TVectorD *GetTabRealVectorColumn(const char *colname);
132 TVectorD *GetTabRealVectorCell(Int_t rownum, Int_t colnum);
133 TVectorD *GetTabRealVectorCell(Int_t rownum, const char *colname);
135 TObjArray *GetTabRealVectorCells(const char *colname);
137 TArrayD *GetTabVarLengthVectorCell(Int_t rownum, const char *colname);
139 //Misc
140 void Draw(Option_t *opt="");
141 Bool_t Change(const char *filter);
142 Bool_t Change(Int_t extension_number);
145 ClassDef(TFITSHDU,0) // Class interfacing FITS HDUs
int Int_t
Definition: RtypesCore.h:43
char Char_t
Definition: RtypesCore.h:31
unsigned int UInt_t
Definition: RtypesCore.h:44
bool Bool_t
Definition: RtypesCore.h:61
double Double_t
Definition: RtypesCore.h:57
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
Array of doubles (64 bits per element).
Definition: TArrayD.h:27
Array of integers (32 bits per element).
Definition: TArrayI.h:27
FITS file interface class.
Definition: TFITS.h:35
union Cell * fCells
Table cells (when fType == kTableHDU).
Definition: TFITS.h:90
void PrintColumnInfo(const Option_t *) const
Print column information.
Definition: TFITS.cxx:766
void _initialize_me()
Do some initializations.
Definition: TFITS.cxx:222
Int_t GetTabNRows() const
Definition: TFITS.h:125
void Draw(Option_t *opt="")
If the HDU is an image, draw the first layer of the primary array To set a title to the canvas,...
Definition: TFITS.cxx:973
void PrintFullTable(const Option_t *) const
Print full table contents.
Definition: TFITS.cxx:794
TString & GetKeywordValue(const char *keyword)
Get the value of a given keyword. Return "" if not found.
Definition: TFITS.cxx:638
Definition: TFITS.h:42
@ kImageHDU
Definition: TFITS.h:43
@ kTableHDU
Definition: TFITS.h:44
Int_t fNRows
Number of rows (when fType == kTableHDU)
Definition: TFITS.h:89
Int_t GetRecordNumber() const
Definition: TFITS.h:111
const TString & GetColumnName(Int_t colnum)
Get the name of a column given its index (column>=0).
Definition: TFITS.cxx:1565
Int_t GetTabNColumns() const
Definition: TFITS.h:124
Int_t fNRecords
Number of records.
Definition: TFITS.h:81
TString fFilePath
Path to HDU's file including filter.
Definition: TFITS.h:78
struct Column * fColumnsInfo
Information about columns (when fType == kTableHDU)
Definition: TFITS.h:87
TFITSHDU(const char *filepath_with_filter)
TFITSHDU constructor from file path with HDU selection filter.
Definition: TFITS.cxx:118
Int_t fNColumns
Number of columns (when fType == kTableHDU)
Definition: TFITS.h:88
TImage * ReadAsImage(Int_t layer=0, TImagePalette *pal=0)
Read image HDU as a displayable image.
Definition: TFITS.cxx:880
TVectorD * GetTabRealVectorColumn(Int_t colnum)
Get a real number-typed column from a table HDU given its column index (>=0).
Definition: TFITS.cxx:1329
Definition: TFITS.h:47
@ kString
Definition: TFITS.h:48
@ kRealArray
Definition: TFITS.h:50
@ kRealVector
Definition: TFITS.h:51
@ kRealNumber
Definition: TFITS.h:49
TArrayI * fSizes
Image sizes in each dimension (when fType == kImageHDU)
Definition: TFITS.h:85
Bool_t Change(const char *filter)
Change to another HDU given by "filter".
Definition: TFITS.cxx:1414
TMatrixD * ReadAsMatrix(Int_t layer=0, Option_t *opt="")
Read image HDU as a matrix.
Definition: TFITS.cxx:1000
Int_t fNumber
HDU number (1=PRIMARY)
Definition: TFITS.h:84
void PrintHDUMetadata(const Option_t *opt="") const
Print records.
Definition: TFITS.cxx:651
TFITSHDU destructor.
Definition: TFITS.cxx:169
struct HDURecord * fRecords
HDU metadata records.
Definition: TFITS.h:80
TVectorD * GetArrayRow(UInt_t row)
Get a row from the image HDU when it's a 2D array.
Definition: TFITS.cxx:1172
void _release_resources()
Release internal resources.
Definition: TFITS.cxx:177
void PrintFileMetadata(const Option_t *opt="") const
Print HDU's parent file's metadata.
Definition: TFITS.cxx:665
static void CleanFilePath(const char *filepath_with_filter, TString &dst)
Clean path from possible filter and put the result in 'dst'.
Definition: TFITS.cxx:94
struct HDURecord * GetRecord(const char *keyword)
Get record by keyword.
Definition: TFITS.cxx:625
void Print(const Option_t *opt="") const
Print metadata.
Definition: TFITS.cxx:858
TObjArray * GetTabStringColumn(Int_t colnum)
Get a string-typed column from a table HDU given its column index (>=0).
Definition: TFITS.cxx:1266
TString fBaseFilePath
Path to HDU's file excluding filter.
Definition: TFITS.h:79
TH1 * ReadAsHistogram()
Read image HDU as a histogram.
Definition: TFITS.cxx:1093
TObjArray * GetTabRealVectorCells(Int_t colnum)
Get a collection of real vectors embedded in cells along a given column from a table HDU....
Definition: TFITS.cxx:1454
TArrayD * fPixels
Image pixels (when fType == kImageHDU)
Definition: TFITS.h:86
TVectorD * GetArrayColumn(UInt_t col)
Get a column from the image HDU when it's a 2D array.
Definition: TFITS.cxx:1212
enum EHDUTypes fType
HDU type.
Definition: TFITS.h:82
TVectorD * GetTabRealVectorCell(Int_t rownum, Int_t colnum)
Get a real array (with fixed or variable-length) embedded in a cell given by (row>=0,...
Definition: TFITS.cxx:1513
Bool_t LoadHDU(TString &filepath_filter)
Load HDU from fits file satisfying the specified filter.
Definition: TFITS.cxx:237
TString fExtensionName
Extension Name.
Definition: TFITS.h:83
TArrayD * GetTabVarLengthVectorCell(Int_t rownum, Int_t colnum)
Get the variable-length array contained in a cell given by (row>=0, column name)
Definition: TFITS.cxx:1583
Int_t GetColumnNumber(const char *colname)
Get column number given its name.
Definition: TFITS.cxx:1252
The TH1 histogram class.
Definition: TH1.h:56
A class to define a conversion from pixel values to pixel color.
Definition: TAttImage.h:33
An abstract interface to image processing library.
Definition: TImage.h:29
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
An array of TObjects.
Definition: TObjArray.h:37
Basic string class.
Definition: TString.h:131
std::vector< int > fRowStart
Definition: TFITS.h:66
Bool_t fVariable
Definition: TFITS.h:65
enum EColumnTypes fType
Definition: TFITS.h:62
TString fName
Definition: TFITS.h:61
Int_t fDim
Definition: TFITS.h:63
std::vector< int > fVarLengths
Definition: TFITS.h:67
TString fKeyword
Definition: TFITS.h:55
TString fValue
Definition: TFITS.h:56
TString fComment
Definition: TFITS.h:57
TArrayD * fRealVector
Definition: TFITS.h:74
Double_t * fRealArray
Definition: TFITS.h:73
Double_t fRealNumber
Definition: TFITS.h:72
Char_t * fString
Definition: TFITS.h:71