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

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

lecture d'une clef fits string cmv 29/10/2003

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