| [1661] | 1 | /* Interface Fits pour bolometre    cmv 29/09/2001 */ | 
|---|
|  | 2 | #ifndef FBOLOREAD_H_SEEN | 
|---|
|  | 3 | #define FBOLOREAD_H_SEEN | 
|---|
|  | 4 |  | 
|---|
|  | 5 | #include "machdefs.h" | 
|---|
|  | 6 | #include <iostream.h> | 
|---|
|  | 7 | #include <string.h> | 
|---|
|  | 8 | #include <string> | 
|---|
|  | 9 |  | 
|---|
|  | 10 | #include "anydataobj.h" | 
|---|
|  | 11 | #include "tvector.h" | 
|---|
|  | 12 | #include "fabtcolread.h" | 
|---|
|  | 13 |  | 
|---|
|  | 14 | #include <vector> | 
|---|
|  | 15 |  | 
|---|
|  | 16 | namespace SOPHYA { | 
|---|
|  | 17 |  | 
|---|
|  | 18 | //! Class for defining a bolometer by connecting columns out FITS files | 
|---|
|  | 19 | class FitsBoloRead : public AnyDataObj { | 
|---|
|  | 20 | public: | 
|---|
|  | 21 | enum {ColSNum=0, ColBolo=1, ColFlag=2, ColAlpha=3, ColDelta=4}; | 
|---|
|  | 22 |  | 
|---|
|  | 23 | FitsBoloRead(long blen=100,long bsens=1); | 
|---|
|  | 24 | virtual ~FitsBoloRead(); | 
|---|
|  | 25 |  | 
|---|
|  | 26 | //! Define the Alpha column connection (see addcol). | 
|---|
|  | 27 | inline int SetAlpha(const char *label,const char* fname="",int ihdu=0) | 
|---|
|  | 28 | {return addcol(ColAlpha,label,fname,ihdu);} | 
|---|
|  | 29 | //! Define the Delta column connection (see addcol). | 
|---|
|  | 30 | inline int SetDelta(const char *label,const char* fname="",int ihdu=0) | 
|---|
|  | 31 | {return addcol(ColDelta,label,fname,ihdu);} | 
|---|
|  | 32 | //! Define the Bolo column connection (see addcol). | 
|---|
|  | 33 | inline int SetBolo(const char *label,const char* fname="",int ihdu=0) | 
|---|
|  | 34 | {return addcol(ColBolo,label,fname,ihdu);} | 
|---|
|  | 35 | //! Define the Flag column connection (see addcol). | 
|---|
|  | 36 | inline int SetFlag(const char *label,const char* fname="",int ihdu=0) | 
|---|
|  | 37 | {return addcol(ColFlag,label,fname,ihdu);} | 
|---|
|  | 38 | //! Define the Sample Number column connection (see addcol). | 
|---|
|  | 39 | inline int SetSNum(const char *label,const char* fname="",int ihdu=0) | 
|---|
|  | 40 | {return addcol(ColSNum,label,fname,ihdu);} | 
|---|
|  | 41 | //! Add a new column connection (see addcol). | 
|---|
|  | 42 | inline int AddCol(const char *label,const char* fname,int ihdu=0) | 
|---|
|  | 43 | {return addcol(-1,label,fname,ihdu);} | 
|---|
|  | 44 |  | 
|---|
|  | 45 | //! return Alpha value for row "n" into double | 
|---|
|  | 46 | inline double GetAlpha(long n,bool usebuffer=true) | 
|---|
|  | 47 | {return GetCol(ColAlpha,n,usebuffer);} | 
|---|
|  | 48 | //! return Delta value for row "n" into double | 
|---|
|  | 49 | inline double GetDelta(long n,bool usebuffer=true) | 
|---|
|  | 50 | {return GetCol(ColDelta,n,usebuffer);} | 
|---|
|  | 51 | //! return Bolo value for row "n" into double | 
|---|
|  | 52 | inline double GetBolo(long n,bool usebuffer=true) | 
|---|
|  | 53 | {return GetCol(ColBolo,n,usebuffer);} | 
|---|
|  | 54 | //! return Flag value for row "n" into double | 
|---|
|  | 55 | inline double GetFlag(long n,bool usebuffer=true) | 
|---|
|  | 56 | {if(!IsFlag()) return 0.; return GetCol(ColFlag,n,usebuffer);} | 
|---|
|  | 57 | //! return SNum value for row "n" into double | 
|---|
|  | 58 | inline double GetSNum(long n,bool usebuffer=true) | 
|---|
|  | 59 | {return GetCol(ColSNum,n,usebuffer);} | 
|---|
|  | 60 | //! return column "col" value for row "n" into double | 
|---|
|  | 61 | inline double GetCol(int col,long n,bool usebuffer=true) { | 
|---|
|  | 62 | if(col<0 || col>=(int)mFABT.size()) | 
|---|
|  | 63 | throw ParmError("FitsBoloRead::GetCol: bad column number\n"); | 
|---|
|  | 64 | if(mFABT[col]==NULL) | 
|---|
|  | 65 | throw NullPtrError("FitsBoloRead::GetCol: column not connected\n"); | 
|---|
|  | 66 | return mFABT[col]->Read(n,usebuffer); | 
|---|
|  | 67 | } | 
|---|
|  | 68 |  | 
|---|
|  | 69 | //! return Alpha values for rows [n1,n2] into TVector | 
|---|
|  | 70 | inline long GetAlpha(long n1,long n2,TVector<double>& data) | 
|---|
|  | 71 | {return GetCol(ColAlpha,n1,n2,data);} | 
|---|
|  | 72 | inline long GetAlpha(long n1,long n2,TVector<float>& data) | 
|---|
|  | 73 | {return GetCol(ColAlpha,n1,n2,data);} | 
|---|
|  | 74 | inline long GetAlpha(long n1,long n2,TVector<int_4>& data) | 
|---|
|  | 75 | {return GetCol(ColAlpha,n1,n2,data);} | 
|---|
|  | 76 |  | 
|---|
|  | 77 | //! return Delta values for rows [n1,n2] into TVector | 
|---|
|  | 78 | inline long GetDelta(long n1,long n2,TVector<double>& data) | 
|---|
|  | 79 | {return GetCol(ColDelta,n1,n2,data);} | 
|---|
|  | 80 | inline long GetDelta(long n1,long n2,TVector<float>& data) | 
|---|
|  | 81 | {return GetCol(ColDelta,n1,n2,data);} | 
|---|
|  | 82 | inline long GetDelta(long n1,long n2,TVector<int_4>& data) | 
|---|
|  | 83 | {return GetCol(ColDelta,n1,n2,data);} | 
|---|
|  | 84 |  | 
|---|
|  | 85 | //! return Bolo values for rows [n1,n2] into TVector | 
|---|
|  | 86 | inline long GetBolo(long n1,long n2,TVector<double>& data) | 
|---|
|  | 87 | {return GetCol(ColBolo,n1,n2,data);} | 
|---|
|  | 88 | inline long GetBolo(long n1,long n2,TVector<float>& data) | 
|---|
|  | 89 | {return GetCol(ColBolo,n1,n2,data);} | 
|---|
|  | 90 | inline long GetBolo(long n1,long n2,TVector<int_4>& data) | 
|---|
|  | 91 | {return GetCol(ColBolo,n1,n2,data);} | 
|---|
|  | 92 |  | 
|---|
|  | 93 | //! return Flag values for rows [n1,n2] into TVector | 
|---|
|  | 94 | inline long GetFlag(long n1,long n2,TVector<double>& data) | 
|---|
|  | 95 | {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);} | 
|---|
|  | 96 | inline long GetFlag(long n1,long n2,TVector<float>& data) | 
|---|
|  | 97 | {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);} | 
|---|
|  | 98 | inline long GetFlag(long n1,long n2,TVector<int_4>& data) | 
|---|
|  | 99 | {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);} | 
|---|
|  | 100 |  | 
|---|
|  | 101 | //! return Sample Number values for rows [n1,n2] into TVector | 
|---|
|  | 102 | inline long GetSNum(long n1,long n2,TVector<double>& data) | 
|---|
|  | 103 | {return GetCol(ColSNum,n1,n2,data);} | 
|---|
|  | 104 | inline long GetSNum(long n1,long n2,TVector<float>& data) | 
|---|
|  | 105 | {return GetCol(ColSNum,n1,n2,data);} | 
|---|
|  | 106 | inline long GetSNum(long n1,long n2,TVector<int_4>& data) | 
|---|
|  | 107 | {return GetCol(ColSNum,n1,n2,data);} | 
|---|
|  | 108 |  | 
|---|
|  | 109 | //! return column "col" values for rows [n1,n2] into TVector | 
|---|
|  | 110 | inline long GetCol(int col,long n1,long n2,TVector<double>& data) { | 
|---|
|  | 111 | if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0; | 
|---|
|  | 112 | return mFABT[col]->Read(n1,n2,data); | 
|---|
|  | 113 | } | 
|---|
|  | 114 | inline long GetCol(int col,long n1,long n2,TVector<float>& 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 long GetCol(int col,long n1,long n2,TVector<int_4>& 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 |  | 
|---|
|  | 123 | //! return the value of the first sampleNum | 
|---|
|  | 124 | inline double ReadFirstSNum(void) {return GetSNum(0,false);} | 
|---|
|  | 125 | //! return the value of the last sampleNum | 
|---|
|  | 126 | inline double ReadLastSNum(void)  {return GetSNum(NBline-1,false);} | 
|---|
|  | 127 |  | 
|---|
|  | 128 | //! Is Alpha connected ? | 
|---|
|  | 129 | inline bool IsAlpha(void)  {return IsCol(ColAlpha);} | 
|---|
|  | 130 | //! Is Delta connected ? | 
|---|
|  | 131 | inline bool IsDelta(void)  {return IsCol(ColDelta);} | 
|---|
|  | 132 | //! Is Bolo connected ? | 
|---|
|  | 133 | inline bool IsBolo(void)   {return IsCol(ColBolo);} | 
|---|
|  | 134 | //! Is Flag connected ? | 
|---|
|  | 135 | inline bool IsFlag(void)   {return IsCol(ColFlag);} | 
|---|
|  | 136 | //! Is SNum connected ? | 
|---|
|  | 137 | inline bool IsSNum(void)   {return IsCol(ColSNum);} | 
|---|
|  | 138 | //! Is column col connected ? | 
|---|
|  | 139 | inline bool IsCol(int col) {if(mFABT[col]) return true; return false;} | 
|---|
|  | 140 |  | 
|---|
|  | 141 | //! Set debug level | 
|---|
|  | 142 | inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;} | 
|---|
|  | 143 | //! Set the number of rows for that class choosing column "col" | 
|---|
|  | 144 | void SetNbLine(int col=-1); | 
|---|
|  | 145 | //! Get the number of rows to be read | 
|---|
|  | 146 | inline long GetNbLine(void) const {return NBline;} | 
|---|
|  | 147 | //! Get the number of columns in the FITS HDU to be read | 
|---|
|  | 148 | inline int  GetNbCol(void) const {return mFABT.size();} | 
|---|
|  | 149 | //! Get the read requested buffer length | 
|---|
|  | 150 | inline long GetBLen(void) const {return BuffLen;} | 
|---|
|  | 151 | //! Get the read buffer direction | 
|---|
|  | 152 | inline long GetBSens(void) const {return BuffSens;} | 
|---|
|  | 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 | long 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 */ | 
|---|