Logo ROOT   6.21/01
Reference Guide
TFITS.h
Go to the documentation of this file.
1 // @(#)root/graf2d:$Id$
2 // Author: Claudi Martinez, July 19th 2010
3 
4 /*************************************************************************
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  *************************************************************************/
11 
12 #ifndef ROOT_TFITS
13 #define ROOT_TFITS
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TFITS //
18 // //
19 // Interface to FITS astronomical files. //
20 // Please, see TFITS.cxx for info about implementation //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include "TNamed.h"
24 #include "TMatrixDfwd.h"
25 #include "TVectorDfwd.h"
26 
27 class TArrayI;
28 class TArrayD;
29 class TH1;
30 class TImage;
31 class TImagePalette;
32 class TObjArray;
33 
34 class TFITSHDU : public TNamed {
35 
36 private:
37  void _release_resources();
38  void _initialize_me();
39 
40 public:
41  enum EHDUTypes { // HDU types
44  };
45 
46  enum EColumnTypes { // Column data types
50  };
51 
52  struct HDURecord { // FITS HDU record
56  };
57 
58  struct Column { //Information of a table column
59  TString fName; // Column's name
60  enum EColumnTypes fType; // Column's data type
61  Int_t fDim; // When cells contain real number vectors, this field indicates
62  // the dimension of this vector (number of components), being 1 for scalars.
63  };
64 
65  union Cell { //Table cell contents
69  };
70 
71 protected:
72  TString fFilePath; ///< Path to HDU's file including filter
73  TString fBaseFilePath; ///< Path to HDU's file excluding filter
74  struct HDURecord *fRecords; ///< HDU metadata records
75  Int_t fNRecords; ///< Number of records
76  enum EHDUTypes fType; ///< HDU type
77  TString fExtensionName; ///< Extension Name
78  Int_t fNumber; ///< HDU number (1=PRIMARY)
79  TArrayI *fSizes; ///< Image sizes in each dimension (when fType == kImageHDU)
80  TArrayD *fPixels; ///< Image pixels (when fType == kImageHDU)
81  struct Column *fColumnsInfo; ///< Information about columns (when fType == kTableHDU)
82  Int_t fNColumns; ///< Number of columns (when fType == kTableHDU)
83  Int_t fNRows; ///< Number of rows (when fType == kTableHDU)
84  union Cell *fCells; ///< Table cells (when fType == kTableHDU). Cells are ordered in the following way:
85  ///< fCells[0..fNRows-1] -> cells of column 0
86  ///< fCells[fNRows..2*fNRows-1] -> cells of column 1
87  ///< fCells[2*fNRows..3*fNRows-1] -> cells of column 2
88  ///< fCells[(fNColumns-1)*fNRows..fNColumns*fNRows-1] -> cells of column fNColumns-1
89 
90 
91  Bool_t LoadHDU(TString& filepath_filter);
92  static void CleanFilePath(const char *filepath_with_filter, TString &dst);
93  void PrintHDUMetadata(const Option_t *opt="") const;
94  void PrintFileMetadata(const Option_t *opt="") const;
95  void PrintColumnInfo(const Option_t *) const;
96  void PrintFullTable(const Option_t *) const;
97 
98 public:
99  TFITSHDU(const char *filepath_with_filter);
100  TFITSHDU(const char *filepath, Int_t extension_number);
101  TFITSHDU(const char *filepath, const char *extension_name);
102  ~TFITSHDU();
103 
104  //Metadata access methods
105  Int_t GetRecordNumber() const { return fNRecords; }
106  struct HDURecord *GetRecord(const char *keyword);
107  TString& GetKeywordValue(const char *keyword);
108  void Print(const Option_t *opt="") const;
109 
110  //Image readers
111  TH1 *ReadAsHistogram();
112  TImage *ReadAsImage(Int_t layer = 0, TImagePalette *pal = 0);
113  TMatrixD *ReadAsMatrix(Int_t layer = 0, Option_t *opt="");
116 
117  //Table readers
118  Int_t GetTabNColumns() const { return fNColumns; }
119  Int_t GetTabNRows() const { return fNRows; }
120  Int_t GetColumnNumber(const char *colname);
121  const TString& GetColumnName(Int_t colnum);
123  TObjArray *GetTabStringColumn(const char *colname);
125  TVectorD *GetTabRealVectorColumn(const char *colname);
126  TVectorD *GetTabRealVectorCell(Int_t rownum, Int_t colnum);
127  TVectorD *GetTabRealVectorCell(Int_t rownum, const char *colname);
129  TObjArray *GetTabRealVectorCells(const char *colname);
130 
131  //Misc
132  void Draw(Option_t *opt="");
133  Bool_t Change(const char *filter);
134  Bool_t Change(Int_t extension_number);
135 
136 
137  ClassDef(TFITSHDU,0) // Class interfacing FITS HDUs
138 };
139 
140 
141 #endif
TString fKeyword
Definition: TFITS.h:53
Double_t * fRealVector
Definition: TFITS.h:68
An array of TObjects.
Definition: TObjArray.h:37
TString fValue
Definition: TFITS.h:54
Int_t fNRows
Number of rows (when fType == kTableHDU)
Definition: TFITS.h:83
EColumnTypes
Definition: TFITS.h:46
TString fExtensionName
Extension Name.
Definition: TFITS.h:77
TFITSHDU(const char *filepath_with_filter)
TFITSHDU constructor from file path with HDU selection filter.
Definition: TFITS.cxx:118
const char Option_t
Definition: RtypesCore.h:62
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:869
Int_t fNRecords
Number of records.
Definition: TFITS.h:75
TArrayI * fSizes
Image sizes in each dimension (when fType == kImageHDU)
Definition: TFITS.h:79
Int_t GetTabNColumns() const
Definition: TFITS.h:118
TMatrixD * ReadAsMatrix(Int_t layer=0, Option_t *opt="")
Read image HDU as a matrix.
Definition: TFITS.cxx:896
TVectorT.
Definition: TMatrixTBase.h:79
Int_t GetTabNRows() const
Definition: TFITS.h:119
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t fDim
Definition: TFITS.h:61
Int_t GetRecordNumber() const
Definition: TFITS.h:105
An abstract interface to image processing library.
Definition: TImage.h:29
void _release_resources()
Release internal resources.
Definition: TFITS.cxx:177
Bool_t LoadHDU(TString &filepath_filter)
Load HDU from fits file satisfying the specified filter.
Definition: TFITS.cxx:231
Array of integers (32 bits per element).
Definition: TArrayI.h:27
TMatrixT.
Definition: TMatrixDfwd.h:22
void Print(const Option_t *opt="") const
Print metadata.
Definition: TFITS.cxx:753
~TFITSHDU()
TFITSHDU destructor.
Definition: TFITS.cxx:169
struct HDURecord * GetRecord(const char *keyword)
Get record by keyword.
Definition: TFITS.cxx:546
Double_t fRealNumber
Definition: TFITS.h:67
#define ClassDef(name, id)
Definition: Rtypes.h:326
FITS file interface class.
Definition: TFITS.h:34
void _initialize_me()
Do some initializations.
Definition: TFITS.cxx:216
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
void PrintFileMetadata(const Option_t *opt="") const
Print HDU&#39;s parent file&#39;s metadata.
Definition: TFITS.cxx:586
TVectorD * GetArrayRow(UInt_t row)
Get a row from the image HDU when it&#39;s a 2D array.
Definition: TFITS.cxx:1068
enum EHDUTypes fType
HDU type.
Definition: TFITS.h:76
TObjArray * GetTabStringColumn(Int_t colnum)
Get a string-typed column from a table HDU given its column index (>=0).
Definition: TFITS.cxx:1162
TH1 * ReadAsHistogram()
Read image HDU as a histogram.
Definition: TFITS.cxx:989
Bool_t Change(const char *filter)
Change to another HDU given by "filter".
Definition: TFITS.cxx:1306
enum EColumnTypes fType
Definition: TFITS.h:60
void PrintColumnInfo(const Option_t *) const
Print column information.
Definition: TFITS.cxx:687
unsigned int UInt_t
Definition: RtypesCore.h:42
EHDUTypes
Definition: TFITS.h:41
void PrintHDUMetadata(const Option_t *opt="") const
Print records.
Definition: TFITS.cxx:572
TArrayD * fPixels
Image pixels (when fType == kImageHDU)
Definition: TFITS.h:80
double Double_t
Definition: RtypesCore.h:55
TString fName
Definition: TFITS.h:59
TVectorD * GetTabRealVectorColumn(Int_t colnum)
Get a real number-typed column from a table HDU given its column index (>=0).
Definition: TFITS.cxx:1225
Char_t * fString
Definition: TFITS.h:66
Int_t fNumber
HDU number (1=PRIMARY)
Definition: TFITS.h:78
TString fComment
Definition: TFITS.h:55
The TH1 histogram class.
Definition: TH1.h:56
A class to define a conversion from pixel values to pixel color.
Definition: TAttImage.h:33
Array of doubles (64 bits per element).
Definition: TArrayD.h:27
TString fBaseFilePath
Path to HDU&#39;s file excluding filter.
Definition: TFITS.h:73
TVectorD * GetTabRealVectorCell(Int_t rownum, Int_t colnum)
Get a real vector embedded in a cell given by (row>=0, column>=0)
Definition: TFITS.cxx:1404
TString fFilePath
Path to HDU&#39;s file including filter.
Definition: TFITS.h:72
char Char_t
Definition: RtypesCore.h:29
TVectorD * GetArrayColumn(UInt_t col)
Get a column from the image HDU when it&#39;s a 2D array.
Definition: TFITS.cxx:1108
union Cell * fCells
Table cells (when fType == kTableHDU).
Definition: TFITS.h:84
TString & GetKeywordValue(const char *keyword)
Get the value of a given keyword. Return "" if not found.
Definition: TFITS.cxx:559
static void CleanFilePath(const char *filepath_with_filter, TString &dst)
Clean path from possible filter and put the result in &#39;dst&#39;.
Definition: TFITS.cxx:94
struct HDURecord * fRecords
HDU metadata records.
Definition: TFITS.h:74
void PrintFullTable(const Option_t *) const
Print full table contents.
Definition: TFITS.cxx:702
const TString & GetColumnName(Int_t colnum)
Get the name of a column given its index (column>=0).
Definition: TFITS.cxx:1457
struct Column * fColumnsInfo
Information about columns (when fType == kTableHDU)
Definition: TFITS.h:81
Int_t fNColumns
Number of columns (when fType == kTableHDU)
Definition: TFITS.h:82
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:1346
TImage * ReadAsImage(Int_t layer=0, TImagePalette *pal=0)
Read image HDU as a displayable image.
Definition: TFITS.cxx:775
Int_t GetColumnNumber(const char *colname)
Get column number given its name.
Definition: TFITS.cxx:1148