Logo ROOT   6.18/05
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
27class TArrayI;
28class TArrayD;
29class TH1;
30class TImage;
31class TImagePalette;
32class TObjArray;
33
34class TFITSHDU : public TNamed {
35
36private:
37 void _release_resources();
38 void _initialize_me();
39
40public:
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
71protected:
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
98public:
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
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
int Int_t
Definition: RtypesCore.h:41
char Char_t
Definition: RtypesCore.h:29
unsigned int UInt_t
Definition: RtypesCore.h:42
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
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:34
union Cell * fCells
Table cells (when fType == kTableHDU).
Definition: TFITS.h:84
void PrintColumnInfo(const Option_t *) const
Print column information.
Definition: TFITS.cxx:687
void _initialize_me()
Do some initializations.
Definition: TFITS.cxx:216
Int_t GetTabNRows() const
Definition: TFITS.h:119
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
void PrintFullTable(const Option_t *) const
Print full table contents.
Definition: TFITS.cxx:702
TString & GetKeywordValue(const char *keyword)
Get the value of a given keyword. Return "" if not found.
Definition: TFITS.cxx:559
EHDUTypes
Definition: TFITS.h:41
@ kImageHDU
Definition: TFITS.h:42
@ kTableHDU
Definition: TFITS.h:43
Int_t fNRows
Number of rows (when fType == kTableHDU)
Definition: TFITS.h:83
Int_t GetRecordNumber() const
Definition: TFITS.h:105
const TString & GetColumnName(Int_t colnum)
Get the name of a column given its index (column>=0).
Definition: TFITS.cxx:1457
Int_t GetTabNColumns() const
Definition: TFITS.h:118
Int_t fNRecords
Number of records.
Definition: TFITS.h:75
TString fFilePath
Path to HDU's file including filter.
Definition: TFITS.h:72
struct Column * fColumnsInfo
Information about columns (when fType == kTableHDU)
Definition: TFITS.h:81
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:82
TImage * ReadAsImage(Int_t layer=0, TImagePalette *pal=0)
Read image HDU as a displayable image.
Definition: TFITS.cxx:775
TVectorD * GetTabRealVectorColumn(Int_t colnum)
Get a real number-typed column from a table HDU given its column index (>=0).
Definition: TFITS.cxx:1225
EColumnTypes
Definition: TFITS.h:46
@ kString
Definition: TFITS.h:48
@ kRealVector
Definition: TFITS.h:49
@ kRealNumber
Definition: TFITS.h:47
TArrayI * fSizes
Image sizes in each dimension (when fType == kImageHDU)
Definition: TFITS.h:79
Bool_t Change(const char *filter)
Change to another HDU given by "filter".
Definition: TFITS.cxx:1306
TMatrixD * ReadAsMatrix(Int_t layer=0, Option_t *opt="")
Read image HDU as a matrix.
Definition: TFITS.cxx:896
Int_t fNumber
HDU number (1=PRIMARY)
Definition: TFITS.h:78
void PrintHDUMetadata(const Option_t *opt="") const
Print records.
Definition: TFITS.cxx:572
~TFITSHDU()
TFITSHDU destructor.
Definition: TFITS.cxx:169
struct HDURecord * fRecords
HDU metadata records.
Definition: TFITS.h:74
TVectorD * GetArrayRow(UInt_t row)
Get a row from the image HDU when it's a 2D array.
Definition: TFITS.cxx:1068
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:586
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:546
void Print(const Option_t *opt="") const
Print metadata.
Definition: TFITS.cxx:753
TObjArray * GetTabStringColumn(Int_t colnum)
Get a string-typed column from a table HDU given its column index (>=0).
Definition: TFITS.cxx:1162
TString fBaseFilePath
Path to HDU's file excluding filter.
Definition: TFITS.h:73
TH1 * ReadAsHistogram()
Read image HDU as a histogram.
Definition: TFITS.cxx:989
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
TArrayD * fPixels
Image pixels (when fType == kImageHDU)
Definition: TFITS.h:80
TVectorD * GetArrayColumn(UInt_t col)
Get a column from the image HDU when it's a 2D array.
Definition: TFITS.cxx:1108
enum EHDUTypes fType
HDU type.
Definition: TFITS.h:76
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
Bool_t LoadHDU(TString &filepath_filter)
Load HDU from fits file satisfying the specified filter.
Definition: TFITS.cxx:231
TString fExtensionName
Extension Name.
Definition: TFITS.h:77
Int_t GetColumnNumber(const char *colname)
Get column number given its name.
Definition: TFITS.cxx:1148
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
enum EColumnTypes fType
Definition: TFITS.h:60
TString fName
Definition: TFITS.h:59
Int_t fDim
Definition: TFITS.h:61
TString fKeyword
Definition: TFITS.h:53
TString fValue
Definition: TFITS.h:54
TString fComment
Definition: TFITS.h:55
Double_t * fRealVector
Definition: TFITS.h:68
Double_t fRealNumber
Definition: TFITS.h:67
Char_t * fString
Definition: TFITS.h:66