[1654] | 1 | /* Interface Fits BINARY/ASCII Table Column Reader cmv 26/09/2001 */
|
---|
| 2 | #ifndef FABTCOLREAD_H_SEEN
|
---|
| 3 | #define FABTCOLREAD_H_SEEN
|
---|
| 4 |
|
---|
| 5 | #include "machdefs.h"
|
---|
[2322] | 6 | #include <iostream>
|
---|
[1654] | 7 | #include <string.h>
|
---|
| 8 | #include <string>
|
---|
| 9 |
|
---|
| 10 | #include "anydataobj.h"
|
---|
| 11 | #include "tvector.h"
|
---|
| 12 | #include "FitsIO/fitsio.h"
|
---|
| 13 |
|
---|
| 14 | namespace SOPHYA {
|
---|
| 15 |
|
---|
[2449] | 16 | ///////////////////////////////////////////////////////////////////
|
---|
| 17 | //! Class for opening a FITS file for reading
|
---|
| 18 | class FitsOpenFile : public AnyDataObj {
|
---|
| 19 | public:
|
---|
| 20 | FitsOpenFile(string fname);
|
---|
| 21 | FitsOpenFile(const char *cfname);
|
---|
| 22 | FitsOpenFile();
|
---|
| 23 | FitsOpenFile(FitsOpenFile& fof);
|
---|
| 24 | virtual ~FitsOpenFile();
|
---|
| 25 |
|
---|
| 26 | inline string GetFileName() {return FitsFN;}
|
---|
| 27 | inline int GetNHdu() {return NHdu;}
|
---|
| 28 | inline fitsfile* GetFitsPtr() {return FitsPtr;}
|
---|
| 29 |
|
---|
| 30 | protected:
|
---|
| 31 | void Init(const char *cfname);
|
---|
| 32 | void Delete(void);
|
---|
| 33 | void printerror(int sta) const;
|
---|
| 34 |
|
---|
| 35 | string FitsFN;
|
---|
| 36 | int NHdu;
|
---|
| 37 | fitsfile *FitsPtr;
|
---|
| 38 | };
|
---|
| 39 |
|
---|
| 40 | ///////////////////////////////////////////////////////////////////
|
---|
[1654] | 41 | //! Class for reading a column in a FITS ASCII or BINARY table
|
---|
[2449] | 42 | class FitsABTColRd : public AnyDataObj {
|
---|
[1654] | 43 | public:
|
---|
[2449] | 44 | FitsABTColRd(FitsOpenFile* fof,string collabel,int ihdu=0
|
---|
| 45 | ,long blen=100,long bsens=1,int lp=0);
|
---|
| 46 | FitsABTColRd(FitsOpenFile* fof,int colnum,int ihdu=0
|
---|
| 47 | ,long blen=100,long bsens=1,int lp=0);
|
---|
| 48 | FitsABTColRd(FitsABTColRd& fbt);
|
---|
| 49 | FitsABTColRd();
|
---|
| 50 | virtual ~FitsABTColRd();
|
---|
[1654] | 51 |
|
---|
| 52 | void ChangeBuffer(long blen=100,long bsens=1);
|
---|
| 53 |
|
---|
[1814] | 54 | double ReadKey(char *keyname);
|
---|
| 55 |
|
---|
[1659] | 56 | double Read(long n,bool usebuffer=true);
|
---|
[2170] | 57 |
|
---|
| 58 | long Read(long n1,long n2,TVector<uint_2>& data);
|
---|
[1659] | 59 | long Read(long n1,long n2,TVector<int_4>& data);
|
---|
[2169] | 60 | long Read(long n1,long n2,TVector<int_8>& data);
|
---|
[2170] | 61 | long Read(long n1,long n2,TVector<float>& data);
|
---|
| 62 | long Read(long n1,long n2,TVector<double>& data);
|
---|
[1654] | 63 |
|
---|
[1659] | 64 | //! return the value of the first row
|
---|
| 65 | double ReadFirstRow(bool usebuffer=false)
|
---|
| 66 | {return Read(0,usebuffer);}
|
---|
| 67 | //! return the value of the last row
|
---|
| 68 | double ReadLastRow(bool usebuffer=false)
|
---|
| 69 | {return Read(NBline-1,usebuffer);}
|
---|
| 70 |
|
---|
| 71 | long FirstRow(double val1,double val2,long rowstart=-1);
|
---|
| 72 | long LastRow(double val1,double val2,long rowstart=-1);
|
---|
| 73 |
|
---|
[1654] | 74 | //! Set debug level
|
---|
[1657] | 75 | inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
|
---|
[1654] | 76 | //! Set null value to be return when reading null data (0=return the data)
|
---|
[1657] | 77 | inline void SetNulVal(double nulval=0.) {NulVal = nulval;}
|
---|
[1654] | 78 | //! Get the FITS file name
|
---|
| 79 | inline string GetFileName(void) {return FitsFN;}
|
---|
[2449] | 80 | //! Get the pointer to FitsOpenFile
|
---|
| 81 | inline FitsOpenFile* GetFitsOpenFile(void) {return FitsOF;}
|
---|
[1673] | 82 | //! Get the FITS file pointer (cfistio pointer)
|
---|
| 83 | inline fitsfile* GetFitsPointer(void) {return FitsPtr;}
|
---|
[1654] | 84 | //! Get the number of HDU in the FITS file
|
---|
| 85 | inline int GetNHDU(void) {return NHdu;}
|
---|
| 86 | //! Get the number of the HDU read
|
---|
| 87 | inline int GetHDU(void) {return IHdu;}
|
---|
| 88 | //! Get the HDU type
|
---|
| 89 | inline int GetHDUType(void) {return HduType;}
|
---|
| 90 | //! Get the number of rows in the FITS HDU to be read
|
---|
| 91 | inline long GetNbLine(void) {return NBline;}
|
---|
| 92 | //! Get the number of columns in the FITS HDU to be read
|
---|
| 93 | inline int GetNbCol(void) {return NBcol;}
|
---|
| 94 | //! Get the columns number that is read
|
---|
| 95 | inline int GetColNum(void) {return ColNum;}
|
---|
| 96 | //! Get the columns label that is read
|
---|
| 97 | inline string GetColLabel(void) {return ColLabel;}
|
---|
| 98 | //! Get the columns type code that is read
|
---|
| 99 | inline int GetColTypeCode(void) {return ColTypeCode;}
|
---|
| 100 | //! Get the columns fits tunit that is read
|
---|
| 101 | inline string GetColTUnit(void) {return ColTUnit;}
|
---|
| 102 | //! Get the columns fits tform that is read
|
---|
| 103 | inline string GetColTForm(void) {return ColTForm;}
|
---|
[1657] | 104 | //! Get the read requested buffer length
|
---|
[1654] | 105 | inline long GetBLen(void) {return BuffLen;}
|
---|
| 106 | //! Get the read buffer direction
|
---|
| 107 | inline long GetBSens(void) {return BuffSens;}
|
---|
| 108 | //! Print to os
|
---|
| 109 | virtual void Print(ostream& os,int lp=1) const;
|
---|
| 110 | //! Print to stdout
|
---|
| 111 | inline void Print(int lp=1) const {Print(cout,lp);}
|
---|
[1657] | 112 | //! Get the read effective buffer length
|
---|
| 113 | inline long GetNBuffer(void) {return NBuffer;}
|
---|
[1654] | 114 | //! Get the read bufferpointer
|
---|
| 115 | inline double* GetBuffer(void) {return Buffer;}
|
---|
| 116 |
|
---|
| 117 | protected:
|
---|
[2449] | 118 | void Init(FitsOpenFile* fof,const char *collabel,int colnum
|
---|
[1654] | 119 | ,int ihdu,long blen,long bsens,int lp);
|
---|
| 120 | void Delete(void);
|
---|
| 121 | void printerror(int sta) const;
|
---|
| 122 |
|
---|
| 123 | string FitsFN,ColLabel,ColTUnit,ColTForm;
|
---|
| 124 | int ColNum,ColTypeCode,IHdu,NHdu,HduType,NBcol;
|
---|
| 125 | long NBline;
|
---|
| 126 |
|
---|
[1657] | 127 | double NulVal;
|
---|
| 128 | unsigned short DbgLevel;
|
---|
[1654] | 129 | long BuffLen, BuffSens;
|
---|
| 130 |
|
---|
[1657] | 131 | unsigned long NFitsRead;
|
---|
[2449] | 132 | FitsOpenFile* FitsOF;
|
---|
| 133 | fitsfile* FitsPtr;
|
---|
[1654] | 134 | long LineDeb, LineFin;
|
---|
| 135 | double *Buffer;
|
---|
| 136 | long NBuffer;
|
---|
| 137 | };
|
---|
| 138 |
|
---|
[2449] | 139 | ///////////////////////////////////////////////////////////////////
|
---|
| 140 | //! Class for reading a column in a FITS ASCII or BINARY table with fits file opening
|
---|
| 141 | class FitsABTColRead : public FitsABTColRd {
|
---|
| 142 | public:
|
---|
| 143 | FitsABTColRead(string fname,string collabel,int ihdu=0
|
---|
| 144 | ,long blen=100,long bsens=1,int lp=0);
|
---|
| 145 | FitsABTColRead(string fname,int colnum,int ihdu=0
|
---|
| 146 | ,long blen=100,long bsens=1,int lp=0);
|
---|
| 147 | FitsABTColRead(const char *cfname,const char *collabel,int ihdu=0
|
---|
| 148 | ,long blen=100,long bsens=1,int lp=0);
|
---|
| 149 | FitsABTColRead(const char *cfname,int colnum,int ihdu=0
|
---|
| 150 | ,long blen=100,long bsens=1,int lp=0);
|
---|
| 151 | FitsABTColRead(FitsABTColRead& fbt);
|
---|
| 152 | FitsABTColRead();
|
---|
| 153 | virtual ~FitsABTColRead();
|
---|
| 154 | };
|
---|
| 155 |
|
---|
[1654] | 156 | } // namespace SOPHYA
|
---|
| 157 | #endif /* FABTCOLREAD_H_SEEN */
|
---|