#ifndef ROOT_TFITS
#define ROOT_TFITS
#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_TMatrixDfwd
#include "TMatrixDfwd.h"
#endif
#ifndef ROOT_TVectorDfwd
#include "TVectorDfwd.h"
#endif
class TArrayI;
class TArrayD;
class TH1;
class TImage;
class TImagePalette;
class TObjArray;
class TFITSHDU : public TNamed {
private:
void _release_resources();
void _initialize_me();
public:
enum EHDUTypes {
kImageHDU,
kTableHDU
};
enum EColumnTypes {
kRealNumber,
kString,
kRealVector
};
struct HDURecord {
TString fKeyword;
TString fValue;
TString fComment;
};
struct Column {
TString fName;
enum EColumnTypes fType;
Int_t fDim;
};
union Cell {
Char_t *fString;
Double_t fRealNumber;
Double_t *fRealVector;
};
protected:
TString fFilePath;
TString fBaseFilePath;
struct HDURecord *fRecords;
Int_t fNRecords;
enum EHDUTypes fType;
TString fExtensionName;
Int_t fNumber;
TArrayI *fSizes;
TArrayD *fPixels;
struct Column *fColumnsInfo;
Int_t fNColumns;
Int_t fNRows;
union Cell *fCells;
Bool_t LoadHDU(TString& filepath_filter);
static void CleanFilePath(const char *filepath_with_filter, TString &dst);
void PrintHDUMetadata(const Option_t *opt="") const;
void PrintFileMetadata(const Option_t *opt="") const;
void PrintColumnInfo(const Option_t *) const;
void PrintFullTable(const Option_t *) const;
public:
TFITSHDU(const char *filepath_with_filter);
TFITSHDU(const char *filepath, Int_t extension_number);
TFITSHDU(const char *filepath, const char *extension_name);
~TFITSHDU();
Int_t GetRecordNumber() const { return fNRecords; }
struct HDURecord *GetRecord(const char *keyword);
TString& GetKeywordValue(const char *keyword);
void Print(const Option_t *opt="") const;
TH1 *ReadAsHistogram();
TImage *ReadAsImage(Int_t layer = 0, TImagePalette *pal = 0);
TMatrixD *ReadAsMatrix(Int_t layer = 0, Option_t *opt="");
TVectorD *GetArrayRow(UInt_t row);
TVectorD *GetArrayColumn(UInt_t col);
Int_t GetTabNColumns() const { return fNColumns; }
Int_t GetTabNRows() const { return fNRows; }
Int_t GetColumnNumber(const char *colname);
const TString& GetColumnName(Int_t colnum);
TObjArray *GetTabStringColumn(Int_t colnum);
TObjArray *GetTabStringColumn(const char *colname);
TVectorD *GetTabRealVectorColumn(Int_t colnum);
TVectorD *GetTabRealVectorColumn(const char *colname);
TVectorD *GetTabRealVectorCell(Int_t rownum, Int_t colnum);
TVectorD *GetTabRealVectorCell(Int_t rownum, const char *colname);
TObjArray *GetTabRealVectorCells(Int_t colnum);
TObjArray *GetTabRealVectorCells(const char *colname);
void Draw(Option_t *opt="");
Bool_t Change(const char *filter);
Bool_t Change(Int_t extension_number);
ClassDef(TFITSHDU,0)
};
#endif