| 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"
 | 
|---|
| 6 | #include <iostream.h>
 | 
|---|
| 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 | 
 | 
|---|
| 16 | //! Class for reading a column in a FITS ASCII or BINARY table
 | 
|---|
| 17 | class FitsABTColRead : public AnyDataObj {
 | 
|---|
| 18 | public:
 | 
|---|
| 19 |   FitsABTColRead(string fname,string collabel,int ihdu=0
 | 
|---|
| 20 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 21 |   FitsABTColRead(string fname,int colnum,int ihdu=0
 | 
|---|
| 22 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 23 |   FitsABTColRead(const char *cfname,const char *collabel,int ihdu=0
 | 
|---|
| 24 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 25 |   FitsABTColRead(const char *cfname,int colnum,int ihdu=0
 | 
|---|
| 26 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 27 |   FitsABTColRead(FitsABTColRead& fbt);
 | 
|---|
| 28 |   virtual ~FitsABTColRead();
 | 
|---|
| 29 | 
 | 
|---|
| 30 |   void ChangeBuffer(long blen=100,long bsens=1);
 | 
|---|
| 31 | 
 | 
|---|
| 32 |   double ReadKey(char *keyname);
 | 
|---|
| 33 | 
 | 
|---|
| 34 |   double Read(long n,bool usebuffer=true);
 | 
|---|
| 35 |   long   Read(long n1,long n2,TVector<double>& data);
 | 
|---|
| 36 |   long   Read(long n1,long n2,TVector<float>& data);
 | 
|---|
| 37 |   long   Read(long n1,long n2,TVector<int_4>& data);
 | 
|---|
| 38 | 
 | 
|---|
| 39 |   //! return the value of the first row
 | 
|---|
| 40 |   double ReadFirstRow(bool usebuffer=false)
 | 
|---|
| 41 |                      {return Read(0,usebuffer);}
 | 
|---|
| 42 |   //! return the value of the last row
 | 
|---|
| 43 |   double ReadLastRow(bool usebuffer=false)
 | 
|---|
| 44 |                     {return Read(NBline-1,usebuffer);}
 | 
|---|
| 45 | 
 | 
|---|
| 46 |   long FirstRow(double val1,double val2,long rowstart=-1);
 | 
|---|
| 47 |   long LastRow(double val1,double val2,long rowstart=-1);
 | 
|---|
| 48 | 
 | 
|---|
| 49 |   //! Set debug level
 | 
|---|
| 50 |   inline void    SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
 | 
|---|
| 51 |   //! Set null value to be return when reading null data (0=return the data)
 | 
|---|
| 52 |   inline void    SetNulVal(double nulval=0.) {NulVal = nulval;}
 | 
|---|
| 53 |   //! Get the FITS file name
 | 
|---|
| 54 |   inline string  GetFileName(void) {return FitsFN;}
 | 
|---|
| 55 |   //! Get the FITS file pointer (cfistio pointer)
 | 
|---|
| 56 |   inline fitsfile* GetFitsPointer(void) {return FitsPtr;}
 | 
|---|
| 57 |   //! Get the number of HDU in the FITS file
 | 
|---|
| 58 |   inline int     GetNHDU(void) {return NHdu;}
 | 
|---|
| 59 |   //! Get the number of the HDU read
 | 
|---|
| 60 |   inline int     GetHDU(void) {return IHdu;}
 | 
|---|
| 61 |   //! Get the HDU type
 | 
|---|
| 62 |   inline int     GetHDUType(void) {return HduType;}
 | 
|---|
| 63 |   //! Get the number of rows in the FITS HDU to be read
 | 
|---|
| 64 |   inline long    GetNbLine(void) {return NBline;}
 | 
|---|
| 65 |   //! Get the number of columns in the FITS HDU to be read
 | 
|---|
| 66 |   inline int     GetNbCol(void) {return NBcol;}
 | 
|---|
| 67 |   //! Get the columns number that is read
 | 
|---|
| 68 |   inline int     GetColNum(void) {return ColNum;}
 | 
|---|
| 69 |   //! Get the columns label that is read
 | 
|---|
| 70 |   inline string  GetColLabel(void) {return ColLabel;}
 | 
|---|
| 71 |   //! Get the columns type code that is read
 | 
|---|
| 72 |   inline int     GetColTypeCode(void) {return ColTypeCode;}
 | 
|---|
| 73 |   //! Get the columns fits tunit that is read
 | 
|---|
| 74 |   inline string  GetColTUnit(void) {return ColTUnit;}
 | 
|---|
| 75 |   //! Get the columns fits tform that is read
 | 
|---|
| 76 |   inline string  GetColTForm(void) {return ColTForm;}
 | 
|---|
| 77 |   //! Get the read requested buffer length
 | 
|---|
| 78 |   inline long    GetBLen(void) {return BuffLen;}
 | 
|---|
| 79 |   //! Get the read buffer direction
 | 
|---|
| 80 |   inline long    GetBSens(void) {return BuffSens;}
 | 
|---|
| 81 |   //! Print to os
 | 
|---|
| 82 |   virtual void   Print(ostream& os,int lp=1) const;
 | 
|---|
| 83 |   //! Print to stdout
 | 
|---|
| 84 |   inline  void   Print(int lp=1) const {Print(cout,lp);}
 | 
|---|
| 85 |   //! Get the read effective buffer length
 | 
|---|
| 86 |   inline long    GetNBuffer(void) {return NBuffer;}
 | 
|---|
| 87 |   //! Get the read bufferpointer
 | 
|---|
| 88 |   inline double* GetBuffer(void) {return Buffer;}
 | 
|---|
| 89 | 
 | 
|---|
| 90 | protected:
 | 
|---|
| 91 |   void Init(const char *cfname,const char *collabel,int colnum
 | 
|---|
| 92 |            ,int ihdu,long blen,long bsens,int lp);
 | 
|---|
| 93 |   void Delete(void);
 | 
|---|
| 94 |   void printerror(int sta) const;
 | 
|---|
| 95 | 
 | 
|---|
| 96 |   string FitsFN,ColLabel,ColTUnit,ColTForm;
 | 
|---|
| 97 |   int ColNum,ColTypeCode,IHdu,NHdu,HduType,NBcol;
 | 
|---|
| 98 |   long NBline;
 | 
|---|
| 99 | 
 | 
|---|
| 100 |   double NulVal;
 | 
|---|
| 101 |   unsigned short DbgLevel;
 | 
|---|
| 102 |   long BuffLen, BuffSens;
 | 
|---|
| 103 | 
 | 
|---|
| 104 |   unsigned long NFitsRead;
 | 
|---|
| 105 |   fitsfile *FitsPtr;
 | 
|---|
| 106 |   long LineDeb, LineFin;
 | 
|---|
| 107 |   double *Buffer;
 | 
|---|
| 108 |   long NBuffer;
 | 
|---|
| 109 | };
 | 
|---|
| 110 | 
 | 
|---|
| 111 | } // namespace SOPHYA
 | 
|---|
| 112 | #endif    /* FABTCOLREAD_H_SEEN */
 | 
|---|