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

Last change on this file since 2453 was 2453, checked in by cmv, 22 years ago

Restructuration des fits ecriteur et lecteur:

  • en lecture: lecture des images 2D
  • en ecriture: ecriture des images 2D d'ou restructuration des classes avec heritage sur une class FitWriter

Pour demande DY...

cmv 13/11/2003

File size: 6.9 KB
Line 
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>
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
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
26 inline string GetFileName() {return FitsFN;}
27 inline int GetNHdu() {return NHdu;}
28 inline fitsfile* GetFitsPtr() {return FitsPtr;}
29
30 static double ReadKey(fitsfile *fitsptr,char *keyname);
31 static long ReadKeyL(fitsfile *fitsptr,char *keyname);
32 static string ReadKeyS(fitsfile *fitsptr,char *keyname);
33 static void printerror(int sta);
34
35protected:
36 void Init(const char *cfname);
37 void Delete(void);
38
39 string FitsFN;
40 int NHdu;
41 fitsfile *FitsPtr;
42};
43
44///////////////////////////////////////////////////////////////////
45//! Class for reading a column in a FITS ASCII or BINARY table
46class FitsABTColRd : public AnyDataObj {
47public:
48 FitsABTColRd(FitsOpenFile* fof,string collabel,int ihdu=0
49 ,long blen=100,long bsens=1,int lp=0);
50 FitsABTColRd(FitsOpenFile* fof,int colnum,int ihdu=0
51 ,long blen=100,long bsens=1,int lp=0);
52 FitsABTColRd(FitsABTColRd& fbt);
53 FitsABTColRd();
54 virtual ~FitsABTColRd();
55
56 void ChangeBuffer(long blen=100,long bsens=1);
57
58 double ReadKey(char *keyname);
59 long ReadKeyL(char *keyname);
60 string ReadKeyS(char *keyname);
61
62 double Read(long n,bool usebuffer=true);
63
64 long Read(long n1,long n2,TVector<uint_2>& data);
65 long Read(long n1,long n2,TVector<int_4>& data);
66 long Read(long n1,long n2,TVector<int_8>& data);
67 long Read(long n1,long n2,TVector<float>& data);
68 long Read(long n1,long n2,TVector<double>& data);
69
70 //! return the value of the first row
71 double ReadFirstRow(bool usebuffer=false)
72 {return Read(0,usebuffer);}
73 //! return the value of the last row
74 double ReadLastRow(bool usebuffer=false)
75 {return Read(NBline-1,usebuffer);}
76
77 long FirstRow(double val1,double val2,long rowstart=-1);
78 long LastRow(double val1,double val2,long rowstart=-1);
79
80 //! Set debug level
81 inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
82 //! Set null value to be return when reading null data (0=return the data)
83 inline void SetNulVal(double nulval=0.) {NulVal = nulval;}
84 //! Get the FITS file name
85 inline string GetFileName(void) {return FitsFN;}
86 //! Get the pointer to FitsOpenFile
87 inline FitsOpenFile* GetFitsOpenFile(void) {return FitsOF;}
88 //! Get the FITS file pointer (cfistio pointer)
89 inline fitsfile* GetFitsPointer(void) {return FitsPtr;}
90 //! Get the number of HDU in the FITS file
91 inline int GetNHDU(void) {return NHdu;}
92 //! Get the number of the HDU read
93 inline int GetHDU(void) {return IHdu;}
94 //! Get the HDU type
95 inline int GetHDUType(void) {return HduType;}
96 //! Get the number of rows in the FITS HDU to be read
97 inline long GetNbLine(void) {return NBline;}
98 //! Get the number of columns in the FITS HDU to be read
99 inline int GetNbCol(void) {return NBcol;}
100 //! Get the columns number that is read
101 inline int GetColNum(void) {return ColNum;}
102 //! Get the columns label that is read
103 inline string GetColLabel(void) {return ColLabel;}
104 //! Get the columns type code that is read
105 inline int GetColTypeCode(void) {return ColTypeCode;}
106 //! Get the columns fits tunit that is read
107 inline string GetColTUnit(void) {return ColTUnit;}
108 //! Get the columns fits tform that is read
109 inline string GetColTForm(void) {return ColTForm;}
110 //! Get the read requested buffer length
111 inline long GetBLen(void) {return BuffLen;}
112 //! Get the read buffer direction
113 inline long GetBSens(void) {return BuffSens;}
114 //! Print to os
115 virtual void Print(ostream& os,int lp=1) const;
116 //! Print to stdout
117 inline void Print(int lp=1) const {Print(cout,lp);}
118 //! Get the read effective buffer length
119 inline long GetNBuffer(void) {return NBuffer;}
120 //! Get the read bufferpointer
121 inline double* GetBuffer(void) {return Buffer;}
122
123protected:
124 void Init(FitsOpenFile* fof,const char *collabel,int colnum
125 ,int ihdu,long blen,long bsens,int lp);
126 void Delete(void);
127
128 string FitsFN,ColLabel,ColTUnit,ColTForm;
129 int ColNum,ColTypeCode,IHdu,NHdu,HduType,NBcol;
130 long NBline;
131
132 double NulVal;
133 unsigned short DbgLevel;
134 long BuffLen, BuffSens;
135
136 unsigned long NFitsRead;
137 FitsOpenFile* FitsOF;
138 fitsfile* FitsPtr;
139 long LineDeb, LineFin;
140 double *Buffer;
141 long NBuffer;
142};
143
144///////////////////////////////////////////////////////////////////
145//! Class for reading a column in a FITS ASCII or BINARY table with fits file opening
146class FitsABTColRead : public FitsABTColRd {
147public:
148 FitsABTColRead(string fname,string collabel,int ihdu=0
149 ,long blen=100,long bsens=1,int lp=0);
150 FitsABTColRead(string fname,int colnum,int ihdu=0
151 ,long blen=100,long bsens=1,int lp=0);
152 FitsABTColRead(const char *cfname,const char *collabel,int ihdu=0
153 ,long blen=100,long bsens=1,int lp=0);
154 FitsABTColRead(const char *cfname,int colnum,int ihdu=0
155 ,long blen=100,long bsens=1,int lp=0);
156 FitsABTColRead(FitsABTColRead& fbt);
157 FitsABTColRead();
158 virtual ~FitsABTColRead();
159};
160
161} // namespace SOPHYA
162#endif /* FABTCOLREAD_H_SEEN */
163
164///////////////////////////////////////////////////////////////////
165//! Class for reading a 2D image from a FITS file
166class FitsImg2DRd : public AnyDataObj {
167public:
168 FitsImg2DRd(FitsOpenFile* fof,int ihdu=0,int lp=0);
169 FitsImg2DRd(FitsImg2DRd& fbt);
170 FitsImg2DRd();
171 virtual ~FitsImg2DRd();
172
173 double ReadKey(char *keyname);
174 long ReadKeyL(char *keyname);
175 string ReadKeyS(char *keyname);
176
177 long Read(TMatrix<uint_2>& data);
178 long Read(TMatrix<int_4>& data);
179 long Read(TMatrix<int_8>& data);
180 long Read(TMatrix<float>& data);
181 long Read(TMatrix<double>& data);
182
183 //! Set debug level
184 inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
185 //! Set null value to be return when reading null data (0=return the data)
186 inline void SetNulVal(double nulval=0.) {NulVal = nulval;}
187 //! Get the pointer to FitsOpenFile
188 inline FitsOpenFile* GetFitsOpenFile(void) {return FitsOF;}
189 //! Get the number of the HDU read
190 inline int GetHDU(void) {return IHdu;}
191 //! Get the HDU type
192 inline int GetHDUType(void) {return HduType;}
193 //! Get NAXIS1
194 inline long GetNaxis1(void) {return Naxis[0];}
195 //! Get NAXIS2
196 inline long GetNaxis2(void) {return Naxis[1];}
197
198protected:
199 void Init(FitsOpenFile* fof,int ihdu,int lp);
200
201 string FitsFN;
202 int IHdu,NHdu,HduType;
203 long Naxis[2];
204
205 double NulVal;
206 unsigned short DbgLevel;
207
208 FitsOpenFile* FitsOF;
209 fitsfile* FitsPtr;
210};
Note: See TracBrowser for help on using the repository browser.