source: Sophya/trunk/SophyaExt/FitsIOServer/fabtcolread.h@ 3128

Last change on this file since 3128 was 3128, checked in by cmv, 19 years ago

gestion gros fichiers FITS dans fabtcolread et fabtwriter cmv 11/01/2007

File size: 10.8 KB
RevLine 
[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
14namespace SOPHYA {
15
[2449]16///////////////////////////////////////////////////////////////////
17//! Class for opening a FITS file for reading
18class FitsOpenFile : public AnyDataObj {
19public:
20 FitsOpenFile(string fname);
21 FitsOpenFile(const char *cfname);
22 FitsOpenFile();
23 FitsOpenFile(FitsOpenFile& fof);
24 virtual ~FitsOpenFile();
25
[2456]26 inline string FileName() const {return FitsFN;}
27 //! Get the number of the HDU read
28 inline int HDU(void) const {return IHdu;}
29 //! Get the number of the HDU type
30 inline int HDUType(void) const {return HduType;}
31 //! Get the number of HDU in file
32 inline int NHDU() const {return NHdu;}
33 //! Get the CFISTIO fits file pointer
34 inline fitsfile* GetFitsPtr() const {return FitsPtr;}
35 //! Set the positionning status of the file
36 inline void SetPosStatus(bool sta=true) {HasBeenPos = sta;}
37 //! Get the positionning status of the file
38 inline bool GetPosStatus(void) const {return HasBeenPos;}
[2449]39
[2456]40 int MoveToHDU(int ihdu);
41 int MoveToFirst(int hdutype,int ihdudeb=1);
42 int MoveToLast(int hdutype,int ihdudeb=1);
43 void Print(void);
44
[3128]45 static double ReadKey(fitsfile *fitsptr,char *keyname);
46 static long ReadKeyL(fitsfile *fitsptr,char *keyname);
47 static LONGLONG ReadKeyLL(fitsfile *fitsptr,char *keyname);
48 static string ReadKeyS(fitsfile *fitsptr,char *keyname);
[2453]49 static void printerror(int sta);
50
[2449]51protected:
52 void Init(const char *cfname);
53 void Delete(void);
54
55 string FitsFN;
[2456]56 int NHdu, IHdu, HduType;
[2449]57 fitsfile *FitsPtr;
[2456]58 bool HasBeenPos;
[2449]59};
60
61///////////////////////////////////////////////////////////////////
[1654]62//! Class for reading a column in a FITS ASCII or BINARY table
[2449]63class FitsABTColRd : public AnyDataObj {
[1654]64public:
[2449]65 FitsABTColRd(FitsOpenFile* fof,string collabel,int ihdu=0
66 ,long blen=100,long bsens=1,int lp=0);
67 FitsABTColRd(FitsOpenFile* fof,int colnum,int ihdu=0
68 ,long blen=100,long bsens=1,int lp=0);
69 FitsABTColRd(FitsABTColRd& fbt);
70 FitsABTColRd();
71 virtual ~FitsABTColRd();
[1654]72
73 void ChangeBuffer(long blen=100,long bsens=1);
74
[3128]75 double ReadKey(char *keyname);
76 long ReadKeyL(char *keyname);
77 LONGLONG ReadKeyLL(char *keyname);
78 string ReadKeyS(char *keyname);
[1814]79
[3128]80 double Read(LONGLONG n,bool usebuffer=true);
[2170]81
[3128]82 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data);
83 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data);
84 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<int_8>& data);
85 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<float>& data);
86 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<double>& data);
[1654]87
[1659]88 //! return the value of the first row
89 double ReadFirstRow(bool usebuffer=false)
90 {return Read(0,usebuffer);}
91 //! return the value of the last row
92 double ReadLastRow(bool usebuffer=false)
93 {return Read(NBline-1,usebuffer);}
94
[3128]95 LONGLONG FirstRow(double val1,double val2,LONGLONG rowstart=-1);
96 LONGLONG LastRow(double val1,double val2,LONGLONG rowstart=-1);
[1659]97
[1654]98 //! Set debug level
[2456]99 inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
[1654]100 //! Set null value to be return when reading null data (0=return the data)
[2456]101 inline void SetNulVal(double nulval=0.) {NulVal = nulval;}
[1654]102 //! Get the FITS file name
[2456]103 inline string FileName(void) const
104 {if(FitsOF) return FitsOF->FileName(); else return (string)"";}
[2449]105 //! Get the pointer to FitsOpenFile
[2456]106 inline FitsOpenFile* GetFitsOpenFile(void) const {return FitsOF;}
[1673]107 //! Get the FITS file pointer (cfistio pointer)
[3114]108 inline fitsfile* GetFitsPtr(void) const {return FitsOF->GetFitsPtr();}
[1654]109 //! Get the number of HDU in the FITS file
[2456]110 inline int NHDU(void) const
111 {if(FitsOF) return FitsOF->NHDU(); else return 0;}
[1654]112 //! Get the number of the HDU read
[2456]113 inline int HDU(void) const
114 {if(FitsOF) return FitsOF->HDU(); else return 0;}
[1654]115 //! Get the HDU type
[2456]116 inline int HDUType(void) const
117 {if(FitsOF) return FitsOF->HDUType(); else return 0;}
[1654]118 //! Get the number of rows in the FITS HDU to be read
[3128]119 inline LONGLONG GetNbLine(void) const {return NBline;}
[1654]120 //! Get the number of columns in the FITS HDU to be read
[2456]121 inline int GetNbCol(void) const {return NBcol;}
[1654]122 //! Get the columns number that is read
[2456]123 inline int GetColNum(void) const {return ColNum;}
[1654]124 //! Get the columns label that is read
[2456]125 inline string GetColLabel(void) const {return ColLabel;}
[1654]126 //! Get the columns type code that is read
[2456]127 inline int GetColTypeCode(void) const {return ColTypeCode;}
[1654]128 //! Get the columns fits tunit that is read
[2456]129 inline string GetColTUnit(void) const {return ColTUnit;}
[1654]130 //! Get the columns fits tform that is read
[2456]131 inline string GetColTForm(void) const {return ColTForm;}
[1657]132 //! Get the read requested buffer length
[2456]133 inline long GetBLen(void) const {return BuffLen;}
[1654]134 //! Get the read buffer direction
[2456]135 inline long GetBSens(void) const {return BuffSens;}
[1654]136 //! Print to os
[2456]137 virtual void Print(ostream& os,int lp=1) const;
[1654]138 //! Print to stdout
[2456]139 inline void Print(int lp=1) const {Print(cout,lp);}
[1657]140 //! Get the read effective buffer length
[2456]141 inline long GetNBuffer(void) const {return NBuffer;}
[1654]142 //! Get the read bufferpointer
143 inline double* GetBuffer(void) {return Buffer;}
144
145protected:
[2449]146 void Init(FitsOpenFile* fof,const char *collabel,int colnum
[1654]147 ,int ihdu,long blen,long bsens,int lp);
148 void Delete(void);
149
[2456]150 string ColLabel,ColTUnit,ColTForm;
151 int ColNum,ColTypeCode,NBcol;
[3128]152 LONGLONG NBline;
[1654]153
[1657]154 double NulVal;
155 unsigned short DbgLevel;
[1654]156 long BuffLen, BuffSens;
157
[3128]158 LONGLONG NFitsRead;
[2449]159 FitsOpenFile* FitsOF;
[3128]160 LONGLONG LineDeb, LineFin;
[1654]161 double *Buffer;
162 long NBuffer;
163};
164
[2449]165///////////////////////////////////////////////////////////////////
166//! Class for reading a column in a FITS ASCII or BINARY table with fits file opening
167class FitsABTColRead : public FitsABTColRd {
168public:
169 FitsABTColRead(string fname,string collabel,int ihdu=0
170 ,long blen=100,long bsens=1,int lp=0);
171 FitsABTColRead(string fname,int colnum,int ihdu=0
172 ,long blen=100,long bsens=1,int lp=0);
173 FitsABTColRead(const char *cfname,const char *collabel,int ihdu=0
174 ,long blen=100,long bsens=1,int lp=0);
175 FitsABTColRead(const char *cfname,int colnum,int ihdu=0
176 ,long blen=100,long bsens=1,int lp=0);
177 FitsABTColRead(FitsABTColRead& fbt);
178 FitsABTColRead();
179 virtual ~FitsABTColRead();
180};
181
[2453]182
183///////////////////////////////////////////////////////////////////
184//! Class for reading a 2D image from a FITS file
185class FitsImg2DRd : public AnyDataObj {
186public:
187 FitsImg2DRd(FitsOpenFile* fof,int ihdu=0,int lp=0);
188 FitsImg2DRd(FitsImg2DRd& fbt);
189 FitsImg2DRd();
190 virtual ~FitsImg2DRd();
191
[3128]192 double ReadKey(char *keyname);
193 long ReadKeyL(char *keyname);
194 LONGLONG ReadKeyLL(char *keyname);
195 string ReadKeyS(char *keyname);
[2453]196
[3128]197 LONGLONG Read(TMatrix<uint_2>& data);
198 LONGLONG Read(TMatrix<int_4>& data);
199 LONGLONG Read(TMatrix<int_8>& data);
200 LONGLONG Read(TMatrix<float>& data);
201 LONGLONG Read(TMatrix<double>& data);
[2453]202
203 //! Set debug level
204 inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
205 //! Set null value to be return when reading null data (0=return the data)
206 inline void SetNulVal(double nulval=0.) {NulVal = nulval;}
207 //! Get the pointer to FitsOpenFile
[2456]208 inline FitsOpenFile* GetFitsOpenFile(void) const {return FitsOF;}
209 //! Get the FITS file pointer (cfistio pointer)
[3114]210 inline fitsfile* GetFitsPtr(void) const {return FitsOF->GetFitsPtr();}
[2456]211 //! Get the number of HDU in the FITS file
212 inline int NHDU(void) const
213 {if(FitsOF) return FitsOF->NHDU(); else return 0;}
[2453]214 //! Get the number of the HDU read
[2456]215 inline int HDU(void) const
216 {if(FitsOF) return FitsOF->HDU(); else return 0;}
[2453]217 //! Get the HDU type
[2456]218 inline int HDUType(void) const
219 {if(FitsOF) return FitsOF->HDUType(); else return 0;}
[2453]220 //! Get NAXIS1
[3128]221 inline LONGLONG Naxis1(void) const {return Naxis[0];}
[2453]222 //! Get NAXIS2
[3128]223 inline LONGLONG Naxis2(void) const {return Naxis[1];}
[2453]224
225protected:
226 void Init(FitsOpenFile* fof,int ihdu,int lp);
227
[3128]228 LONGLONG Naxis[2];
[2453]229 double NulVal;
230 unsigned short DbgLevel;
231
232 FitsOpenFile* FitsOF;
233};
[2591]234
[2791]235///////////////////////////////////////////////////////////////////
236//! Class for reading a 2D image from a FITS file
237class FitsImg2DRead : public FitsImg2DRd {
238public:
239 FitsImg2DRead(string fname,int ihdu=0,int lp=0);
240 FitsImg2DRead(const char *cfname,int ihdu=0,int lp=0);
241 FitsImg2DRead(FitsImg2DRead& fbt);
242 FitsImg2DRead();
243 virtual ~FitsImg2DRead();
244};
245
[3114]246
247///////////////////////////////////////////////////////////////////
248//! Class for reading a 3D image from a FITS file
249class FitsImg3DRd : public AnyDataObj {
250public:
251 FitsImg3DRd(FitsOpenFile* fof,int ihdu=0,int lp=0);
252 FitsImg3DRd(FitsImg3DRd& fbt);
253 FitsImg3DRd();
254 virtual ~FitsImg3DRd();
255
[3128]256 double ReadKey(char *keyname);
257 long ReadKeyL(char *keyname);
258 LONGLONG ReadKeyLL(char *keyname);
259 string ReadKeyS(char *keyname);
[3114]260
[3128]261 LONGLONG Read(TArray<uint_2>& data);
262 LONGLONG Read(TArray<int_4>& data);
263 LONGLONG Read(TArray<int_8>& data);
264 LONGLONG Read(TArray<float>& data);
265 LONGLONG Read(TArray<double>& data);
[3114]266
267 //! Set debug level
268 inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
269 //! Set null value to be return when reading null data (0=return the data)
270 inline void SetNulVal(double nulval=0.) {NulVal = nulval;}
271 //! Get the pointer to FitsOpenFile
272 inline FitsOpenFile* GetFitsOpenFile(void) const {return FitsOF;}
273 //! Get the FITS file pointer (cfistio pointer)
274 inline fitsfile* GetFitsPtr(void) const {return FitsOF->GetFitsPtr();}
275 //! Get the number of HDU in the FITS file
276 inline int NHDU(void) const
277 {if(FitsOF) return FitsOF->NHDU(); else return 0;}
278 //! Get the number of the HDU read
279 inline int HDU(void) const
280 {if(FitsOF) return FitsOF->HDU(); else return 0;}
281 //! Get the HDU type
282 inline int HDUType(void) const
283 {if(FitsOF) return FitsOF->HDUType(); else return 0;}
284 //! Get NAXIS1
[3128]285 inline LONGLONG Naxis1(void) const {return Naxis[0];}
[3114]286 //! Get NAXIS2
[3128]287 inline LONGLONG Naxis2(void) const {return Naxis[1];}
[3114]288 //! Get NAXIS3
[3128]289 inline LONGLONG Naxis3(void) const {return Naxis[2];}
[3114]290
291protected:
292 void Init(FitsOpenFile* fof,int ihdu,int lp);
293
[3128]294 LONGLONG Naxis[3];
[3114]295 double NulVal;
296 unsigned short DbgLevel;
297
298 FitsOpenFile* FitsOF;
299};
300
301///////////////////////////////////////////////////////////////////
302//! Class for reading a 3D image from a FITS file
303class FitsImg3DRead : public FitsImg3DRd {
304public:
305 FitsImg3DRead(string fname,int ihdu=0,int lp=0);
306 FitsImg3DRead(const char *cfname,int ihdu=0,int lp=0);
307 FitsImg3DRead(FitsImg3DRead& fbt);
308 FitsImg3DRead();
309 virtual ~FitsImg3DRead();
310};
311
[2591]312} // namespace SOPHYA
313#endif /* FABTCOLREAD_H_SEEN */
Note: See TracBrowser for help on using the repository browser.