| 1 | /*    
 | 
|---|
| 2 |    --- SOPHYA software - FitsIOServer module ---
 | 
|---|
| 3 |    C. Magneville, 2001 
 | 
|---|
| 4 |    (C) UPS+LAL IN2P3/CNRS     (C) DAPNIA-SPP/CEA 
 | 
|---|
| 5 | */
 | 
|---|
| 6 | /* Interface Fits BINARY/ASCII Table Column Reader    cmv 26/09/2001 */
 | 
|---|
| 7 | #ifndef FABTCOLREAD_H_SEEN
 | 
|---|
| 8 | #define FABTCOLREAD_H_SEEN
 | 
|---|
| 9 | 
 | 
|---|
| 10 | #include "machdefs.h"
 | 
|---|
| 11 | #include <iostream>
 | 
|---|
| 12 | #include <string.h>
 | 
|---|
| 13 | #include <string>
 | 
|---|
| 14 | 
 | 
|---|
| 15 | #include "anydataobj.h"
 | 
|---|
| 16 | #include "tvector.h"
 | 
|---|
| 17 | #include "FitsIO/fitsio.h"
 | 
|---|
| 18 | 
 | 
|---|
| 19 | namespace SOPHYA {
 | 
|---|
| 20 | 
 | 
|---|
| 21 | ///////////////////////////////////////////////////////////////////
 | 
|---|
| 22 | //! Class for opening a FITS file for reading
 | 
|---|
| 23 | class FitsOpenFile : public AnyDataObj {
 | 
|---|
| 24 | public:
 | 
|---|
| 25 |   FitsOpenFile(string fname);
 | 
|---|
| 26 |   FitsOpenFile(const char *cfname);
 | 
|---|
| 27 |   FitsOpenFile();
 | 
|---|
| 28 |   FitsOpenFile(FitsOpenFile& fof);
 | 
|---|
| 29 |   virtual ~FitsOpenFile();
 | 
|---|
| 30 | 
 | 
|---|
| 31 |   inline string FileName() const {return FitsFN;}
 | 
|---|
| 32 |   //! Get the number of the HDU read
 | 
|---|
| 33 |   inline int HDU(void) const {return IHdu;}
 | 
|---|
| 34 |   //! Get the number of the HDU type
 | 
|---|
| 35 |   inline int HDUType(void) const {return HduType;}
 | 
|---|
| 36 |   //! Get the number of HDU in file
 | 
|---|
| 37 |   inline int NHDU() const {return NHdu;}
 | 
|---|
| 38 |   //! Get the CFISTIO fits file pointer
 | 
|---|
| 39 |   inline fitsfile* GetFitsPtr() const {return FitsPtr;}
 | 
|---|
| 40 |   //! Set the positionning status of the file
 | 
|---|
| 41 |   inline void SetPosStatus(bool sta=true) {HasBeenPos = sta;}
 | 
|---|
| 42 |   //! Get the positionning status of the file
 | 
|---|
| 43 |   inline bool GetPosStatus(void) const {return HasBeenPos;}
 | 
|---|
| 44 | 
 | 
|---|
| 45 |   int MoveToHDU(int ihdu);
 | 
|---|
| 46 |   int MoveToFirst(int hdutype,int ihdudeb=1);
 | 
|---|
| 47 |   int MoveToLast(int hdutype,int ihdudeb=1);
 | 
|---|
| 48 |   void Print(void);
 | 
|---|
| 49 | 
 | 
|---|
| 50 |   static double   ReadKey(fitsfile *fitsptr,const char *keyname);
 | 
|---|
| 51 |   static long     ReadKeyL(fitsfile *fitsptr,const char *keyname);
 | 
|---|
| 52 |   static LONGLONG ReadKeyLL(fitsfile *fitsptr,const char *keyname);
 | 
|---|
| 53 |   static string   ReadKeyS(fitsfile *fitsptr,const char *keyname);
 | 
|---|
| 54 |   static void   printerror(int sta);
 | 
|---|
| 55 | 
 | 
|---|
| 56 | protected:
 | 
|---|
| 57 |   void Init(const char *cfname);
 | 
|---|
| 58 |   void Delete(void);
 | 
|---|
| 59 | 
 | 
|---|
| 60 |   string FitsFN;
 | 
|---|
| 61 |   int NHdu, IHdu, HduType;
 | 
|---|
| 62 |   fitsfile *FitsPtr;
 | 
|---|
| 63 |   bool HasBeenPos;
 | 
|---|
| 64 | };
 | 
|---|
| 65 | 
 | 
|---|
| 66 | ///////////////////////////////////////////////////////////////////
 | 
|---|
| 67 | //! Class for reading a column in a FITS ASCII or BINARY table
 | 
|---|
| 68 | class FitsABTColRd : public AnyDataObj {
 | 
|---|
| 69 | public:
 | 
|---|
| 70 |   FitsABTColRd(FitsOpenFile* fof,string collabel,int ihdu=0
 | 
|---|
| 71 |               ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 72 |   FitsABTColRd(FitsOpenFile* fof,int colnum,int ihdu=0
 | 
|---|
| 73 |               ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 74 |   FitsABTColRd(FitsABTColRd& fbt);
 | 
|---|
| 75 |   FitsABTColRd();
 | 
|---|
| 76 |   virtual ~FitsABTColRd();
 | 
|---|
| 77 | 
 | 
|---|
| 78 |   void ChangeBuffer(long blen=100,long bsens=1);
 | 
|---|
| 79 | 
 | 
|---|
| 80 |   double    ReadKey(const char *keyname);
 | 
|---|
| 81 |   long      ReadKeyL(const char *keyname);
 | 
|---|
| 82 |   LONGLONG  ReadKeyLL(const char *keyname);
 | 
|---|
| 83 |   string    ReadKeyS(const char *keyname);
 | 
|---|
| 84 | 
 | 
|---|
| 85 |   double Read(LONGLONG n,bool usebuffer=true);
 | 
|---|
| 86 | 
 | 
|---|
| 87 |   LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data);
 | 
|---|
| 88 |   LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data);
 | 
|---|
| 89 |   LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<int_8>& data);
 | 
|---|
| 90 |   LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<float>& data);
 | 
|---|
| 91 |   LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<double>& data);
 | 
|---|
| 92 | 
 | 
|---|
| 93 |   //! return the value of the first row
 | 
|---|
| 94 |   double ReadFirstRow(bool usebuffer=false)
 | 
|---|
| 95 |                      {return Read(0,usebuffer);}
 | 
|---|
| 96 |   //! return the value of the last row
 | 
|---|
| 97 |   double ReadLastRow(bool usebuffer=false)
 | 
|---|
| 98 |                     {return Read(NBline-1,usebuffer);}
 | 
|---|
| 99 | 
 | 
|---|
| 100 |   LONGLONG FirstRow(double val1,double val2,LONGLONG rowstart=-1);
 | 
|---|
| 101 |   LONGLONG LastRow(double val1,double val2,LONGLONG rowstart=-1);
 | 
|---|
| 102 | 
 | 
|---|
| 103 |   //! Set debug level
 | 
|---|
| 104 |   inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
 | 
|---|
| 105 |   //! Set null value to be return when reading null data (0=return the data)
 | 
|---|
| 106 |   inline void SetNulVal(double nulval=0.) {NulVal = nulval;}
 | 
|---|
| 107 |   //! Get the FITS file name
 | 
|---|
| 108 |   inline string FileName(void) const
 | 
|---|
| 109 |          {if(FitsOF) return FitsOF->FileName(); else return (string)"";}
 | 
|---|
| 110 |   //! Get the pointer to FitsOpenFile
 | 
|---|
| 111 |   inline FitsOpenFile* GetFitsOpenFile(void) const {return FitsOF;}
 | 
|---|
| 112 |   //! Get the FITS file pointer (cfistio pointer)
 | 
|---|
| 113 |   inline fitsfile* GetFitsPtr(void) const {return FitsOF->GetFitsPtr();}
 | 
|---|
| 114 |   //! Get the number of HDU in the FITS file
 | 
|---|
| 115 |   inline int NHDU(void) const
 | 
|---|
| 116 |          {if(FitsOF) return FitsOF->NHDU(); else return 0;}
 | 
|---|
| 117 |   //! Get the number of the HDU read
 | 
|---|
| 118 |   inline int HDU(void) const
 | 
|---|
| 119 |          {if(FitsOF) return FitsOF->HDU(); else return 0;}
 | 
|---|
| 120 |   //! Get the HDU type
 | 
|---|
| 121 |   inline int HDUType(void) const
 | 
|---|
| 122 |          {if(FitsOF) return FitsOF->HDUType(); else return 0;}
 | 
|---|
| 123 |   //! Get the number of rows in the FITS HDU to be read
 | 
|---|
| 124 |   inline LONGLONG GetNbLine(void) const {return NBline;}
 | 
|---|
| 125 |   //! Get the number of columns in the FITS HDU to be read
 | 
|---|
| 126 |   inline int GetNbCol(void) const {return NBcol;}
 | 
|---|
| 127 |   //! Get the columns number that is read
 | 
|---|
| 128 |   inline int GetColNum(void) const {return ColNum;}
 | 
|---|
| 129 |   //! Get the columns label that is read
 | 
|---|
| 130 |   inline string GetColLabel(void) const {return ColLabel;}
 | 
|---|
| 131 |   //! Get the columns type code that is read
 | 
|---|
| 132 |   inline int GetColTypeCode(void) const {return ColTypeCode;}
 | 
|---|
| 133 |   //! Get the columns fits tunit that is read
 | 
|---|
| 134 |   inline string GetColTUnit(void) const {return ColTUnit;}
 | 
|---|
| 135 |   //! Get the columns fits tform that is read
 | 
|---|
| 136 |   inline string GetColTForm(void) const {return ColTForm;}
 | 
|---|
| 137 |   //! Get the read requested buffer length
 | 
|---|
| 138 |   inline long GetBLen(void) const {return BuffLen;}
 | 
|---|
| 139 |   //! Get the read buffer direction
 | 
|---|
| 140 |   inline long GetBSens(void) const {return BuffSens;}
 | 
|---|
| 141 |   //! Print to os
 | 
|---|
| 142 |   virtual void Print(ostream& os,int lp=1) const;
 | 
|---|
| 143 |   //! Print to stdout
 | 
|---|
| 144 |   inline  void Print(int lp=1) const {Print(cout,lp);}
 | 
|---|
| 145 |   //! Get the read effective buffer length
 | 
|---|
| 146 |   inline long GetNBuffer(void) const {return NBuffer;}
 | 
|---|
| 147 |   //! Get the read bufferpointer
 | 
|---|
| 148 |   inline double* GetBuffer(void) {return Buffer;}
 | 
|---|
| 149 | 
 | 
|---|
| 150 | protected:
 | 
|---|
| 151 |   void Init(FitsOpenFile* fof,const char *collabel,int colnum
 | 
|---|
| 152 |            ,int ihdu,long blen,long bsens,int lp);
 | 
|---|
| 153 |   void Delete(void);
 | 
|---|
| 154 | 
 | 
|---|
| 155 |   string ColLabel,ColTUnit,ColTForm;
 | 
|---|
| 156 |   int ColNum,ColTypeCode,NBcol;
 | 
|---|
| 157 |   LONGLONG NBline;
 | 
|---|
| 158 | 
 | 
|---|
| 159 |   double NulVal;
 | 
|---|
| 160 |   unsigned short DbgLevel;
 | 
|---|
| 161 |   long BuffLen, BuffSens;
 | 
|---|
| 162 | 
 | 
|---|
| 163 |   LONGLONG NFitsRead;
 | 
|---|
| 164 |   FitsOpenFile* FitsOF;
 | 
|---|
| 165 |   LONGLONG LineDeb, LineFin;
 | 
|---|
| 166 |   double *Buffer;
 | 
|---|
| 167 |   long NBuffer;
 | 
|---|
| 168 | };
 | 
|---|
| 169 | 
 | 
|---|
| 170 | ///////////////////////////////////////////////////////////////////
 | 
|---|
| 171 | //! Class for reading a column in a FITS ASCII or BINARY table with fits file opening
 | 
|---|
| 172 | class FitsABTColRead : public FitsABTColRd {
 | 
|---|
| 173 | public:
 | 
|---|
| 174 |   FitsABTColRead(string fname,string collabel,int ihdu=0
 | 
|---|
| 175 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 176 |   FitsABTColRead(string fname,int colnum,int ihdu=0
 | 
|---|
| 177 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 178 |   FitsABTColRead(const char *cfname,const char *collabel,int ihdu=0
 | 
|---|
| 179 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 180 |   FitsABTColRead(const char *cfname,int colnum,int ihdu=0
 | 
|---|
| 181 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 182 |   FitsABTColRead(FitsABTColRead& fbt);
 | 
|---|
| 183 |   FitsABTColRead();
 | 
|---|
| 184 |   virtual ~FitsABTColRead();
 | 
|---|
| 185 | };
 | 
|---|
| 186 | 
 | 
|---|
| 187 | 
 | 
|---|
| 188 | ///////////////////////////////////////////////////////////////////
 | 
|---|
| 189 | //! Class for reading ALL the columns in a FITS ASCII or BINARY table
 | 
|---|
| 190 | class FitsABTColRd1F : public AnyDataObj {
 | 
|---|
| 191 | public:
 | 
|---|
| 192 |   FitsABTColRd1F(FitsOpenFile* fof,int ihdu=0
 | 
|---|
| 193 |               ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 194 |   virtual ~FitsABTColRd1F();
 | 
|---|
| 195 | 
 | 
|---|
| 196 |   void ChangeBuffer(long blen=100,long bsens=1);
 | 
|---|
| 197 | 
 | 
|---|
| 198 |   double    ReadKey(const char *keyname);
 | 
|---|
| 199 |   long      ReadKeyL(const char *keyname);
 | 
|---|
| 200 |   LONGLONG  ReadKeyLL(const char *keyname);
 | 
|---|
| 201 |   string    ReadKeyS(const char *keyname);
 | 
|---|
| 202 | 
 | 
|---|
| 203 |   double Read(int ColNum,LONGLONG n,bool usebuffer=true);
 | 
|---|
| 204 |   int GetColNum(const char *colname);
 | 
|---|
| 205 | 
 | 
|---|
| 206 |   //! Set debug level
 | 
|---|
| 207 |   inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
 | 
|---|
| 208 |   //! Set null value to be return when reading null data (0=return the data)
 | 
|---|
| 209 |   inline void SetNulVal(double nulval=0.) {NulVal = nulval;}
 | 
|---|
| 210 |   //! Get the FITS file name
 | 
|---|
| 211 |   inline string FileName(void) const
 | 
|---|
| 212 |          {if(FitsOF) return FitsOF->FileName(); else return (string)"";}
 | 
|---|
| 213 |   //! Get the pointer to FitsOpenFile
 | 
|---|
| 214 |   inline FitsOpenFile* GetFitsOpenFile(void) const {return FitsOF;}
 | 
|---|
| 215 |   //! Get the FITS file pointer (cfistio pointer)
 | 
|---|
| 216 |   inline fitsfile* GetFitsPtr(void) const {return FitsOF->GetFitsPtr();}
 | 
|---|
| 217 |   //! Get the number of HDU in the FITS file
 | 
|---|
| 218 |   inline int NHDU(void) const
 | 
|---|
| 219 |          {if(FitsOF) return FitsOF->NHDU(); else return 0;}
 | 
|---|
| 220 |   //! Get the number of the HDU read
 | 
|---|
| 221 |   inline int HDU(void) const
 | 
|---|
| 222 |          {if(FitsOF) return FitsOF->HDU(); else return 0;}
 | 
|---|
| 223 |   //! Get the HDU type
 | 
|---|
| 224 |   inline int HDUType(void) const
 | 
|---|
| 225 |          {if(FitsOF) return FitsOF->HDUType(); else return 0;}
 | 
|---|
| 226 |   //! Get the number of rows in the FITS HDU to be read
 | 
|---|
| 227 |   inline LONGLONG GetNbLine(void) const {return NBline;}
 | 
|---|
| 228 |   //! Get the number of columns in the FITS HDU to be read
 | 
|---|
| 229 |   inline int GetNbCol(void) const {return NBcol;}
 | 
|---|
| 230 |   //! Get the columns label that is read
 | 
|---|
| 231 |   inline string GetColLabel(int ColNum) const
 | 
|---|
| 232 |          {if(ColNum<0 || ColNum>=NBcol) return string(""); else return ColLabel[ColNum];}
 | 
|---|
| 233 |   //! Get the columns type code that is read
 | 
|---|
| 234 |   inline int GetColTypeCode(int ColNum) const
 | 
|---|
| 235 |          {if(ColNum<0 || ColNum>=NBcol) return -999; else return ColTypeCode[ColNum];}
 | 
|---|
| 236 |   //! Get the columns fits tunit that is read
 | 
|---|
| 237 |   inline string GetColTUnit(int ColNum) const
 | 
|---|
| 238 |          {if(ColNum<0 || ColNum>=NBcol) return string(""); else return ColTUnit[ColNum];}
 | 
|---|
| 239 |   //! Get the columns fits tform that is read
 | 
|---|
| 240 |   inline string GetColTForm(int ColNum) const
 | 
|---|
| 241 |          {if(ColNum<0 || ColNum>=NBcol) return string(""); else return ColTForm[ColNum];}
 | 
|---|
| 242 |   //! Get the read requested buffer length
 | 
|---|
| 243 |   inline long GetBLen(void) const {return BuffLen;}
 | 
|---|
| 244 |   //! Get the read buffer direction
 | 
|---|
| 245 |   inline long GetBSens(void) const {return BuffSens;}
 | 
|---|
| 246 |   //! Print to os
 | 
|---|
| 247 |   virtual void Print(ostream& os,int lp=1) const;
 | 
|---|
| 248 |   //! Print to stdout
 | 
|---|
| 249 |   inline  void Print(int lp=1) const {Print(cout,lp);}
 | 
|---|
| 250 |   //! Get the read effective buffer length
 | 
|---|
| 251 |   inline long GetNBuffer(void) const {return NBuffer;}
 | 
|---|
| 252 |   //! Get the read bufferpointer
 | 
|---|
| 253 |   inline double* GetBuffer(int ColNum)
 | 
|---|
| 254 |          {if(ColNum<0 || ColNum>=NBcol) return NULL; else return Buffer[ColNum];}
 | 
|---|
| 255 | 
 | 
|---|
| 256 | protected:
 | 
|---|
| 257 |   void Init(FitsOpenFile* fof,int ihdu,long blen,long bsens,int lp);
 | 
|---|
| 258 |   void Delete(void);
 | 
|---|
| 259 | 
 | 
|---|
| 260 |   vector<string> ColLabel,ColTUnit,ColTForm;
 | 
|---|
| 261 |   vector<int> ColTypeCode;
 | 
|---|
| 262 |   int NBcol;
 | 
|---|
| 263 |   LONGLONG NBline;
 | 
|---|
| 264 | 
 | 
|---|
| 265 |   double NulVal;
 | 
|---|
| 266 |   unsigned short DbgLevel;
 | 
|---|
| 267 |   long BuffLen, BuffSens;
 | 
|---|
| 268 | 
 | 
|---|
| 269 |   FitsOpenFile* FitsOF;
 | 
|---|
| 270 |   vector<LONGLONG> LineDeb, LineFin;
 | 
|---|
| 271 |   double **Buffer;
 | 
|---|
| 272 |   long NBuffer;
 | 
|---|
| 273 | };
 | 
|---|
| 274 | 
 | 
|---|
| 275 | 
 | 
|---|
| 276 | ///////////////////////////////////////////////////////////////////
 | 
|---|
| 277 | //! Class for reading ALL the columns in a FITS ASCII or BINARY table with fits file opening
 | 
|---|
| 278 | class FitsABTColRead1F : public FitsABTColRd1F {
 | 
|---|
| 279 | public:
 | 
|---|
| 280 |   FitsABTColRead1F(string fname,int ihdu=0
 | 
|---|
| 281 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 282 |   FitsABTColRead1F(const char *cfname,int ihdu=0
 | 
|---|
| 283 |                 ,long blen=100,long bsens=1,int lp=0);
 | 
|---|
| 284 |   virtual ~FitsABTColRead1F();
 | 
|---|
| 285 | };
 | 
|---|
| 286 | 
 | 
|---|
| 287 | ///////////////////////////////////////////////////////////////////
 | 
|---|
| 288 | //! Class for reading a 2D image from a FITS file
 | 
|---|
| 289 | class FitsImg2DRd : public AnyDataObj {
 | 
|---|
| 290 | public:
 | 
|---|
| 291 |   FitsImg2DRd(FitsOpenFile* fof,int ihdu=0,int lp=0);
 | 
|---|
| 292 |   FitsImg2DRd(FitsImg2DRd& fbt);
 | 
|---|
| 293 |   FitsImg2DRd();
 | 
|---|
| 294 |   virtual ~FitsImg2DRd();
 | 
|---|
| 295 | 
 | 
|---|
| 296 |   double   ReadKey(const char *keyname);
 | 
|---|
| 297 |   long     ReadKeyL(const char *keyname);
 | 
|---|
| 298 |   LONGLONG ReadKeyLL(const char *keyname);
 | 
|---|
| 299 |   string   ReadKeyS(const char *keyname);
 | 
|---|
| 300 | 
 | 
|---|
| 301 |   LONGLONG Read(TMatrix<uint_2>& data);
 | 
|---|
| 302 |   LONGLONG Read(TMatrix<int_4>& data);
 | 
|---|
| 303 |   LONGLONG Read(TMatrix<int_8>& data);
 | 
|---|
| 304 |   LONGLONG Read(TMatrix<float>& data);
 | 
|---|
| 305 |   LONGLONG Read(TMatrix<double>& data);
 | 
|---|
| 306 |   double   Read(LONGLONG numcol, LONGLONG numrow);
 | 
|---|
| 307 | 
 | 
|---|
| 308 |   //! Set debug level
 | 
|---|
| 309 |   inline void    SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
 | 
|---|
| 310 |   //! Set null value to be return when reading null data (0=return the data)
 | 
|---|
| 311 |   inline void    SetNulVal(double nulval=0.) {NulVal = nulval;}
 | 
|---|
| 312 |   //! Get the pointer to FitsOpenFile
 | 
|---|
| 313 |   inline FitsOpenFile* GetFitsOpenFile(void) const {return FitsOF;}
 | 
|---|
| 314 |   //! Get the FITS file pointer (cfistio pointer)
 | 
|---|
| 315 |   inline fitsfile* GetFitsPtr(void) const {return FitsOF->GetFitsPtr();}
 | 
|---|
| 316 |   //! Get the number of HDU in the FITS file
 | 
|---|
| 317 |   inline int NHDU(void) const
 | 
|---|
| 318 |          {if(FitsOF) return FitsOF->NHDU(); else return 0;}
 | 
|---|
| 319 |   //! Get the number of the HDU read
 | 
|---|
| 320 |   inline int HDU(void) const
 | 
|---|
| 321 |          {if(FitsOF) return FitsOF->HDU(); else return 0;}
 | 
|---|
| 322 |   //! Get the HDU type
 | 
|---|
| 323 |   inline int HDUType(void) const
 | 
|---|
| 324 |          {if(FitsOF) return FitsOF->HDUType(); else return 0;}
 | 
|---|
| 325 |   //! Get NAXIS1
 | 
|---|
| 326 |   inline LONGLONG Naxis1(void) const {return Naxis[0];}
 | 
|---|
| 327 |   //! Get NAXIS2
 | 
|---|
| 328 |   inline LONGLONG Naxis2(void) const {return Naxis[1];}
 | 
|---|
| 329 | 
 | 
|---|
| 330 | protected:
 | 
|---|
| 331 |   void Init(FitsOpenFile* fof,int ihdu,int lp);
 | 
|---|
| 332 | 
 | 
|---|
| 333 |   LONGLONG Naxis[2];
 | 
|---|
| 334 |   double NulVal;
 | 
|---|
| 335 |   unsigned short DbgLevel;
 | 
|---|
| 336 | 
 | 
|---|
| 337 |   FitsOpenFile* FitsOF;
 | 
|---|
| 338 | };
 | 
|---|
| 339 | 
 | 
|---|
| 340 | ///////////////////////////////////////////////////////////////////
 | 
|---|
| 341 | //! Class for reading a 2D image from a FITS file
 | 
|---|
| 342 | class FitsImg2DRead : public FitsImg2DRd {
 | 
|---|
| 343 | public:
 | 
|---|
| 344 |   FitsImg2DRead(string fname,int ihdu=0,int lp=0);
 | 
|---|
| 345 |   FitsImg2DRead(const char *cfname,int ihdu=0,int lp=0);
 | 
|---|
| 346 |   FitsImg2DRead(FitsImg2DRead& fbt);
 | 
|---|
| 347 |   FitsImg2DRead();
 | 
|---|
| 348 |   virtual ~FitsImg2DRead();
 | 
|---|
| 349 | };
 | 
|---|
| 350 | 
 | 
|---|
| 351 | 
 | 
|---|
| 352 | ///////////////////////////////////////////////////////////////////
 | 
|---|
| 353 | //! Class for reading a 3D image from a FITS file
 | 
|---|
| 354 | class FitsImg3DRd : public AnyDataObj {
 | 
|---|
| 355 | public:
 | 
|---|
| 356 |   FitsImg3DRd(FitsOpenFile* fof,int ihdu=0,int lp=0);
 | 
|---|
| 357 |   FitsImg3DRd(FitsImg3DRd& fbt);
 | 
|---|
| 358 |   FitsImg3DRd();
 | 
|---|
| 359 |   virtual ~FitsImg3DRd();
 | 
|---|
| 360 | 
 | 
|---|
| 361 |   double   ReadKey(const char *keyname);
 | 
|---|
| 362 |   long     ReadKeyL(const char *keyname);
 | 
|---|
| 363 |   LONGLONG ReadKeyLL(const char *keyname);
 | 
|---|
| 364 |   string   ReadKeyS(const char *keyname);
 | 
|---|
| 365 | 
 | 
|---|
| 366 |   LONGLONG Read(TArray<uint_2>& data);
 | 
|---|
| 367 |   LONGLONG Read(TArray<int_4>& data);
 | 
|---|
| 368 |   LONGLONG Read(TArray<int_8>& data);
 | 
|---|
| 369 |   LONGLONG Read(TArray<float>& data);
 | 
|---|
| 370 |   LONGLONG Read(TArray<double>& data);
 | 
|---|
| 371 |   double   Read(LONGLONG i, LONGLONG j, LONGLONG k);
 | 
|---|
| 372 | 
 | 
|---|
| 373 |   //! Set debug level
 | 
|---|
| 374 |   inline void    SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
 | 
|---|
| 375 |   //! Set null value to be return when reading null data (0=return the data)
 | 
|---|
| 376 |   inline void    SetNulVal(double nulval=0.) {NulVal = nulval;}
 | 
|---|
| 377 |   //! Get the pointer to FitsOpenFile
 | 
|---|
| 378 |   inline FitsOpenFile* GetFitsOpenFile(void) const {return FitsOF;}
 | 
|---|
| 379 |   //! Get the FITS file pointer (cfistio pointer)
 | 
|---|
| 380 |   inline fitsfile* GetFitsPtr(void) const {return FitsOF->GetFitsPtr();}
 | 
|---|
| 381 |   //! Get the number of HDU in the FITS file
 | 
|---|
| 382 |   inline int NHDU(void) const
 | 
|---|
| 383 |          {if(FitsOF) return FitsOF->NHDU(); else return 0;}
 | 
|---|
| 384 |   //! Get the number of the HDU read
 | 
|---|
| 385 |   inline int HDU(void) const
 | 
|---|
| 386 |          {if(FitsOF) return FitsOF->HDU(); else return 0;}
 | 
|---|
| 387 |   //! Get the HDU type
 | 
|---|
| 388 |   inline int HDUType(void) const
 | 
|---|
| 389 |          {if(FitsOF) return FitsOF->HDUType(); else return 0;}
 | 
|---|
| 390 |   //! Get NAXIS1
 | 
|---|
| 391 |   inline LONGLONG Naxis1(void) const {return Naxis[0];}
 | 
|---|
| 392 |   //! Get NAXIS2
 | 
|---|
| 393 |   inline LONGLONG Naxis2(void) const {return Naxis[1];}
 | 
|---|
| 394 |   //! Get NAXIS3
 | 
|---|
| 395 |   inline LONGLONG Naxis3(void) const {return Naxis[2];}
 | 
|---|
| 396 | 
 | 
|---|
| 397 | protected:
 | 
|---|
| 398 |   void Init(FitsOpenFile* fof,int ihdu,int lp);
 | 
|---|
| 399 | 
 | 
|---|
| 400 |   LONGLONG Naxis[3];
 | 
|---|
| 401 |   double NulVal;
 | 
|---|
| 402 |   unsigned short DbgLevel;
 | 
|---|
| 403 | 
 | 
|---|
| 404 |   FitsOpenFile* FitsOF;
 | 
|---|
| 405 | };
 | 
|---|
| 406 | 
 | 
|---|
| 407 | ///////////////////////////////////////////////////////////////////
 | 
|---|
| 408 | //! Class for reading a 3D image from a FITS file
 | 
|---|
| 409 | class FitsImg3DRead : public FitsImg3DRd {
 | 
|---|
| 410 | public:
 | 
|---|
| 411 |   FitsImg3DRead(string fname,int ihdu=0,int lp=0);
 | 
|---|
| 412 |   FitsImg3DRead(const char *cfname,int ihdu=0,int lp=0);
 | 
|---|
| 413 |   FitsImg3DRead(FitsImg3DRead& fbt);
 | 
|---|
| 414 |   FitsImg3DRead();
 | 
|---|
| 415 |   virtual ~FitsImg3DRead();
 | 
|---|
| 416 | };
 | 
|---|
| 417 | 
 | 
|---|
| 418 | } // namespace SOPHYA
 | 
|---|
| 419 | #endif    /* FABTCOLREAD_H_SEEN */
 | 
|---|