Logo ROOT   6.08/07
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 #ifndef ROOT_TNamed
24 #include "TNamed.h"
25 #endif
26 #ifndef ROOT_TMatrixDfwd
27 #include "TMatrixDfwd.h"
28 #endif
29 #ifndef ROOT_TVectorDfwd
30 #include "TVectorDfwd.h"
31 #endif
32 
33 class TArrayI;
34 class TArrayD;
35 class TH1;
36 class TImage;
37 class TImagePalette;
38 class TObjArray;
39 
40 class TFITSHDU : public TNamed {
41 
42 private:
43  void _release_resources();
44  void _initialize_me();
45 
46 public:
47  enum EHDUTypes { // HDU types
50  };
51 
52  enum EColumnTypes { // Column data types
56  };
57 
58  struct HDURecord { // FITS HDU record
62  };
63 
64  struct Column { //Information of a table column
65  TString fName; // Column's name
66  enum EColumnTypes fType; // Column's data type
67  Int_t fDim; // When cells contain real number vectors, this field indicates
68  // the dimension of this vector (number of components), being 1 for scalars.
69  };
70 
71  union Cell { //Table cell contents
75  };
76 
77 protected:
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
95 
96 
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;
103 
104 public:
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();
109 
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;
115 
116  //Image readers
117  TH1 *ReadAsHistogram();
118  TImage *ReadAsImage(Int_t layer = 0, TImagePalette *pal = 0);
119  TMatrixD *ReadAsMatrix(Int_t layer = 0, Option_t *opt="");
122 
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);
136 
137  //Misc
138  void Draw(Option_t *opt="");
139  Bool_t Change(const char *filter);
140  Bool_t Change(Int_t extension_number);
141 
142 
143  ClassDef(TFITSHDU,0) // Class interfacing FITS HDUs
144 };
145 
146 
147 #endif
TString fKeyword
Definition: TFITS.h:59
Double_t * fRealVector
Definition: TFITS.h:74
An array of TObjects.
Definition: TObjArray.h:39
TString fValue
Definition: TFITS.h:60
Int_t fNRows
Number of rows (when fType == kTableHDU)
Definition: TFITS.h:89
EColumnTypes
Definition: TFITS.h:52
TString fExtensionName
Extension Name.
Definition: TFITS.h:83
TFITSHDU(const char *filepath_with_filter)
TFITSHDU constructor from file path with HDU selection filter.
Definition: TFITS.cxx:117
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:838
Int_t fNRecords
Number of records.
Definition: TFITS.h:81
TArrayI * fSizes
Image sizes in each dimension (when fType == kImageHDU)
Definition: TFITS.h:85
Int_t GetTabNColumns() const
Definition: TFITS.h:124
TMatrixD * ReadAsMatrix(Int_t layer=0, Option_t *opt="")
Read image HDU as a matrix.
Definition: TFITS.cxx:865
Int_t GetTabNRows() const
Definition: TFITS.h:125
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t fDim
Definition: TFITS.h:67
Int_t GetRecordNumber() const
Definition: TFITS.h:111
An abstract interface to image processing library.
Definition: TImage.h:37
void _release_resources()
Release internal resources.
Definition: TFITS.cxx:176
Bool_t LoadHDU(TString &filepath_filter)
Load HDU from fits file satisfying the specified filter.
Definition: TFITS.cxx:230
Array of integers (32 bits per element).
Definition: TArrayI.h:29
void Print(const Option_t *opt="") const
Print metadata.
Definition: TFITS.cxx:722
~TFITSHDU()
TFITSHDU destructor.
Definition: TFITS.cxx:168
struct HDURecord * GetRecord(const char *keyword)
Get record by keyword.
Definition: TFITS.cxx:515
Double_t fRealNumber
Definition: TFITS.h:73
#define ClassDef(name, id)
Definition: Rtypes.h:254
FITS file interface class.
Definition: TFITS.h:40
void _initialize_me()
Do some initializations.
Definition: TFITS.cxx:215
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void PrintFileMetadata(const Option_t *opt="") const
Print HDU&#39;s parent file&#39;s metadata.
Definition: TFITS.cxx:555
TVectorD * GetArrayRow(UInt_t row)
Get a row from the image HDU when it&#39;s a 2D array.
Definition: TFITS.cxx:1037
enum EHDUTypes fType
HDU type.
Definition: TFITS.h:82
TObjArray * GetTabStringColumn(Int_t colnum)
Get a string-typed column from a table HDU given its column index (>=0).
Definition: TFITS.cxx:1131
TH1 * ReadAsHistogram()
Read image HDU as a histogram.
Definition: TFITS.cxx:958
Bool_t Change(const char *filter)
Change to another HDU given by "filter".
Definition: TFITS.cxx:1275
void PrintColumnInfo(const Option_t *) const
Print column information.
Definition: TFITS.cxx:656
unsigned int UInt_t
Definition: RtypesCore.h:42
EHDUTypes
Definition: TFITS.h:47
void PrintHDUMetadata(const Option_t *opt="") const
Print records.
Definition: TFITS.cxx:541
TArrayD * fPixels
Image pixels (when fType == kImageHDU)
Definition: TFITS.h:86
double Double_t
Definition: RtypesCore.h:55
TString fName
Definition: TFITS.h:65
TVectorD * GetTabRealVectorColumn(Int_t colnum)
Get a real number-typed column from a table HDU given its column index (>=0).
Definition: TFITS.cxx:1194
Char_t * fString
Definition: TFITS.h:72
Int_t fNumber
HDU number (1=PRIMARY)
Definition: TFITS.h:84
TString fComment
Definition: TFITS.h:61
The TH1 histogram class.
Definition: TH1.h:80
A class to define a conversion from pixel values to pixel color.
Definition: TAttImage.h:39
Array of doubles (64 bits per element).
Definition: TArrayD.h:29
TString fBaseFilePath
Path to HDU&#39;s file excluding filter.
Definition: TFITS.h:79
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:1373
TString fFilePath
Path to HDU&#39;s file including filter.
Definition: TFITS.h:78
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:1077
union Cell * fCells
Table cells (when fType == kTableHDU).
Definition: TFITS.h:90
TString & GetKeywordValue(const char *keyword)
Get the value of a given keyword. Return "" if not found.
Definition: TFITS.cxx:528
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:93
struct HDURecord * fRecords
HDU metadata records.
Definition: TFITS.h:80
void PrintFullTable(const Option_t *) const
Print full table contents.
Definition: TFITS.cxx:671
const TString & GetColumnName(Int_t colnum)
Get the name of a column given its index (column>=0).
Definition: TFITS.cxx:1426
struct Column * fColumnsInfo
Information about columns (when fType == kTableHDU)
Definition: TFITS.h:87
Int_t fNColumns
Number of columns (when fType == kTableHDU)
Definition: TFITS.h:88
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:1315
TImage * ReadAsImage(Int_t layer=0, TImagePalette *pal=0)
Read image HDU as a displayable image.
Definition: TFITS.cxx:744
Int_t GetColumnNumber(const char *colname)
Get column number given its name.
Definition: TFITS.cxx:1117