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