1 | /*
|
---|
2 | --- SOPHYA software - FitsIOServer module ---
|
---|
3 | C. Magneville, 2001
|
---|
4 | (C) UPS+LAL IN2P3/CNRS (C) DAPNIA-SPP/CEA
|
---|
5 | */
|
---|
6 | /* Interface Fits pour bolometre cmv 29/09/2001 */
|
---|
7 | #ifndef FBOLOREAD_H_SEEN
|
---|
8 | #define FBOLOREAD_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 "fabtcolread.h"
|
---|
18 |
|
---|
19 | #include <vector>
|
---|
20 |
|
---|
21 | namespace SOPHYA {
|
---|
22 |
|
---|
23 | //! Class for defining a bolometer by connecting columns out FITS files
|
---|
24 | class FitsBoloRead : public AnyDataObj {
|
---|
25 | public:
|
---|
26 | enum {ColSNum=0, ColBolo=1, ColFlag=2, ColAlpha=3, ColDelta=4};
|
---|
27 |
|
---|
28 | FitsBoloRead(void);
|
---|
29 | virtual ~FitsBoloRead();
|
---|
30 |
|
---|
31 | //! Define the Alpha column connection (see addcol).
|
---|
32 | inline int SetAlpha(const char *label,const char* fname="",int ihdu=0)
|
---|
33 | {return addcol(ColAlpha,label,fname,ihdu);}
|
---|
34 | //! Define the Delta column connection (see addcol).
|
---|
35 | inline int SetDelta(const char *label,const char* fname="",int ihdu=0)
|
---|
36 | {return addcol(ColDelta,label,fname,ihdu);}
|
---|
37 | //! Define the Bolo column connection (see addcol).
|
---|
38 | inline int SetBolo(const char *label,const char* fname="",int ihdu=0)
|
---|
39 | {return addcol(ColBolo,label,fname,ihdu);}
|
---|
40 | //! Define the Flag column connection (see addcol).
|
---|
41 | inline int SetFlag(const char *label,const char* fname="",int ihdu=0)
|
---|
42 | {return addcol(ColFlag,label,fname,ihdu);}
|
---|
43 | //! Define the Sample Number column connection (see addcol).
|
---|
44 | inline int SetSNum(const char *label,const char* fname="",int ihdu=0)
|
---|
45 | {return addcol(ColSNum,label,fname,ihdu);}
|
---|
46 | //! Add a new column connection (see addcol).
|
---|
47 | inline int AddCol(const char *label,const char* fname,int ihdu=0)
|
---|
48 | {return addcol(-1,label,fname,ihdu);}
|
---|
49 |
|
---|
50 | //! return Alpha value for row "n" into double
|
---|
51 | inline double GetAlpha(LONGLONG n)
|
---|
52 | {return GetCol(ColAlpha,n);}
|
---|
53 | //! return Delta value for row "n" into double
|
---|
54 | inline double GetDelta(LONGLONG n)
|
---|
55 | {return GetCol(ColDelta,n);}
|
---|
56 | //! return Bolo value for row "n" into double
|
---|
57 | inline double GetBolo(LONGLONG n)
|
---|
58 | {return GetCol(ColBolo,n);}
|
---|
59 | //! return Flag value for row "n" into double
|
---|
60 | inline double GetFlag(LONGLONG n)
|
---|
61 | {if(!IsFlag()) return 0.; return GetCol(ColFlag,n);}
|
---|
62 | //! return SNum value for row "n" into double
|
---|
63 | inline double GetSNum(LONGLONG n) {return GetCol(ColSNum,n);}
|
---|
64 | //! return column "col" value for row "n" into double
|
---|
65 | inline double GetCol(int col,LONGLONG n) {
|
---|
66 | if(col<0 || col>=(int)mFABT.size())
|
---|
67 | throw ParmError("FitsBoloRead::GetCol: bad column number\n");
|
---|
68 | if(mFABT[col]==NULL)
|
---|
69 | throw NullPtrError("FitsBoloRead::GetCol: column not connected\n");
|
---|
70 | return mFABT[col]->Read(n);
|
---|
71 | }
|
---|
72 |
|
---|
73 | //! return Alpha values for rows [n1,n2] into TVector
|
---|
74 | inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<double>& data)
|
---|
75 | {return GetCol(ColAlpha,n1,n2,data);}
|
---|
76 | inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<float>& data)
|
---|
77 | {return GetCol(ColAlpha,n1,n2,data);}
|
---|
78 | inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
|
---|
79 | {return GetCol(ColAlpha,n1,n2,data);}
|
---|
80 |
|
---|
81 | //! return Delta values for rows [n1,n2] into TVector
|
---|
82 | inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<double>& data)
|
---|
83 | {return GetCol(ColDelta,n1,n2,data);}
|
---|
84 | inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<float>& data)
|
---|
85 | {return GetCol(ColDelta,n1,n2,data);}
|
---|
86 | inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
|
---|
87 | {return GetCol(ColDelta,n1,n2,data);}
|
---|
88 |
|
---|
89 | //! return Bolo values for rows [n1,n2] into TVector
|
---|
90 | inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<double>& data)
|
---|
91 | {return GetCol(ColBolo,n1,n2,data);}
|
---|
92 | inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<float>& data)
|
---|
93 | {return GetCol(ColBolo,n1,n2,data);}
|
---|
94 | inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
|
---|
95 | {return GetCol(ColBolo,n1,n2,data);}
|
---|
96 |
|
---|
97 | //! return Flag values for rows [n1,n2] into TVector
|
---|
98 | inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<double>& data)
|
---|
99 | {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);}
|
---|
100 | inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<float>& data)
|
---|
101 | {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);}
|
---|
102 | inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
|
---|
103 | {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);}
|
---|
104 |
|
---|
105 | //! return Sample Number values for rows [n1,n2] into TVector
|
---|
106 | inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<double>& data)
|
---|
107 | {return GetCol(ColSNum,n1,n2,data);}
|
---|
108 | inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<float>& data)
|
---|
109 | {return GetCol(ColSNum,n1,n2,data);}
|
---|
110 | inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
|
---|
111 | {return GetCol(ColSNum,n1,n2,data);}
|
---|
112 |
|
---|
113 | //! return column "col" values for rows [n1,n2] into TVector
|
---|
114 | inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<double>& data) {
|
---|
115 | if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0;
|
---|
116 | return mFABT[col]->Read(n1,n2,data);
|
---|
117 | }
|
---|
118 | inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<float>& data) {
|
---|
119 | if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0;
|
---|
120 | return mFABT[col]->Read(n1,n2,data);
|
---|
121 | }
|
---|
122 | inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<int_4>& data) {
|
---|
123 | if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0;
|
---|
124 | return mFABT[col]->Read(n1,n2,data);
|
---|
125 | }
|
---|
126 |
|
---|
127 | //! return the value of the first sampleNum
|
---|
128 | inline double ReadFirstSNum(void) {return GetSNum(0);}
|
---|
129 | //! return the value of the last sampleNum
|
---|
130 | inline double ReadLastSNum(void) {return GetSNum(NBline-1);}
|
---|
131 |
|
---|
132 | //! Is Alpha connected ?
|
---|
133 | inline bool IsAlpha(void) {return IsCol(ColAlpha);}
|
---|
134 | //! Is Delta connected ?
|
---|
135 | inline bool IsDelta(void) {return IsCol(ColDelta);}
|
---|
136 | //! Is Bolo connected ?
|
---|
137 | inline bool IsBolo(void) {return IsCol(ColBolo);}
|
---|
138 | //! Is Flag connected ?
|
---|
139 | inline bool IsFlag(void) {return IsCol(ColFlag);}
|
---|
140 | //! Is SNum connected ?
|
---|
141 | inline bool IsSNum(void) {return IsCol(ColSNum);}
|
---|
142 | //! Is column col connected ?
|
---|
143 | inline bool IsCol(int col) {if(mFABT[col]) return true; return false;}
|
---|
144 |
|
---|
145 | //! Set debug level
|
---|
146 | inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
|
---|
147 | //! Set the number of rows for that class choosing column "col"
|
---|
148 | void SetNbLine(int col=-1);
|
---|
149 | //! Get the number of rows to be read
|
---|
150 | inline LONGLONG GetNbLine(void) const {return NBline;}
|
---|
151 | //! Get the number of columns in the FITS HDU to be read
|
---|
152 | inline int GetNbCol(void) const {return mFABT.size();}
|
---|
153 | //! Print to os
|
---|
154 | virtual void Print(ostream& os,int lp=1) const;
|
---|
155 | //! Print to stdout
|
---|
156 | inline void Print(int lp=1) const {Print(cout,lp);}
|
---|
157 |
|
---|
158 | //! Get the FitsABTColRead pointer for the Alpha
|
---|
159 | inline FitsABTColRead* GetAlphaReader(void) {return GetColReader(ColAlpha);}
|
---|
160 | //! Get the FitsABTColRead pointer for the Delta
|
---|
161 | inline FitsABTColRead* GetDeltaReader(void) {return GetColReader(ColDelta);}
|
---|
162 | //! Get the FitsABTColRead pointer for the Bolo
|
---|
163 | inline FitsABTColRead* GetBoloReader(void) {return GetColReader(ColBolo);}
|
---|
164 | //! Get the FitsABTColRead pointer for the Flag
|
---|
165 | inline FitsABTColRead* GetFlagReader(void) {return GetColReader(ColFlag);}
|
---|
166 | //! Get the FitsABTColRead pointer for the SNum
|
---|
167 | inline FitsABTColRead* GetSNumReader(void) {return GetColReader(ColSNum);}
|
---|
168 | //! Get the FitsABTColRead pointer for the column "col"
|
---|
169 | inline FitsABTColRead* GetColReader(int col)
|
---|
170 | {if(col<0 || col>=(int)mFABT.size()) return NULL; return mFABT[col];}
|
---|
171 |
|
---|
172 | protected:
|
---|
173 | //! Protected method. Do not use directly but read the doc.
|
---|
174 | int addcol(int col,const char *label,const char* fname,int ihdu);
|
---|
175 | void Gess_If_Not_Define(int col);
|
---|
176 |
|
---|
177 | LONGLONG NBline;
|
---|
178 | unsigned short DbgLevel;
|
---|
179 | long BuffLen, BuffSens;
|
---|
180 |
|
---|
181 | vector<string> mFName;
|
---|
182 | vector<string> mLabel;
|
---|
183 | vector<int> mHDU;
|
---|
184 | vector<FitsABTColRead *> mFABT;
|
---|
185 | };
|
---|
186 |
|
---|
187 | } // namespace SOPHYA
|
---|
188 | #endif /* FBOLOREAD_H_SEEN */
|
---|