00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef SD_BASELINETABLE_H
00028 #define SD_BASELINETABLE_H
00029
00030 #include <casa/aips.h>
00031 #include <casa/Arrays/Vector.h>
00032 #include <casa/Logging/LogIO.h>
00033 #include <measures/Measures/MEpoch.h>
00034 #include <measures/TableMeasures/ScalarMeasColumn.h>
00035 #include <ms/MeasurementSets/MeasurementSet.h>
00036 #include <tables/Tables/Table.h>
00037 #include <tables/Tables/ScalarColumn.h>
00038 #include <tables/Tables/ArrayColumn.h>
00039 #include <libsakura/sakura.h>
00040
00041 #define BaselineType_kPolynomial 0
00042 #define BaselineType_kChebyshev 1
00043 #define BaselineType_kCubicSpline 2
00044 #define BaselineType_kSinusoid 3
00045 #define BaselineType_kNumElements 4
00046
00047 namespace casa {
00048
00049 class BaselineTable {
00050 public:
00051 BaselineTable() {;}
00052 BaselineTable(const MeasurementSet& parent);
00053 BaselineTable(const String &name);
00054
00055 virtual ~BaselineTable();
00056
00057 void setup();
00058 const String& name() const {return name_;};
00059
00060 const Table& table() const { return table_; }
00061 Table table() { return table_; }
00062 void attach();
00063 void attachBaseColumns();
00064 void attachOptionalColumns();
00065
00066 uInt nrow() {return table_.nrow();}
00067
00068 uInt getScan(uInt irow) const {return scanCol_.get(irow);}
00069 uInt getBeam(uInt irow) const {return beamCol_.get(irow);}
00070 uInt getAntenna(uInt irow) const {return antCol_.get(irow);}
00071 uint getSpw(uInt irow) const {return static_cast<uint>(ifCol_.get(irow));}
00072 double getTime(uInt irow) const {return static_cast<double>(timeCol_.get(irow));}
00073
00074 bool getApply(uInt irow, uInt ipol) const;
00075 uint getBaselineType(uInt irow, uInt ipol) const;
00076 int getFPar(uInt irow, uInt ipol) const;
00077
00078 void setdata(uInt irow, uInt scanno, uInt beamno,
00079 uInt antno, uInt ifno,
00080 uInt freqid, Double time,
00081 Array<Bool> apply,
00082 Array<uInt> ftype,
00083 Array<Int> fpar,
00084 Array<Float> ffpar,
00085 Array<uInt> mask,
00086 Array<Float> res,
00087 Array<Float> rms,
00088 uInt nchan,
00089 Array<Float> cthres,
00090 Array<uInt> citer,
00091 Array<Bool> uself,
00092 Array<Float> lfthres,
00093 Array<uInt> lfavg,
00094 Array<uInt> lfedge);
00095 void appenddata(uInt scanno, uInt beamno,
00096 uInt antno, uInt ifno,
00097 uInt freqid, Double time,
00098 Array<Bool> apply,
00099 Array<uInt> ftype,
00100 Array<Int> fpar,
00101 Array<Float> ffpar,
00102 Array<uInt> mask,
00103 Array<Float> res,
00104 Array<Float> rms,
00105 uInt nchan,
00106 Array<Float> cthres,
00107 Array<uInt> citer,
00108 Array<Bool> uself,
00109 Array<Float> lfthres,
00110 Array<uInt> lfavg,
00111 Array<uInt> lfedge);
00112 void appendbasedata(int scanno, int beamno, int antno, int ifno,
00113 int freqid, Double time);
00114 void setresult(uInt irow,
00115 Vector<Float> res,
00116 Array<Float> rms);
00117 void save(const std::string &filename);
00118 uInt nchan(uInt ifno);
00119
00120 Matrix<Bool> getApply() {return applyCol_.getColumn();}
00121 void setApply(int irow, int ipol, bool apply);
00122 Matrix<Int> getFuncParam() {return fparCol_.getColumn();}
00123 Matrix<Int> getFuncParam(uInt irow) {return fparCol_.get(irow);}
00124 Matrix<Float> getFuncFParam() {return ffparCol_.getColumn();}
00125 Matrix<Float> getFuncFParam(uInt irow) {return ffparCol_.get(irow);}
00126 Matrix<uInt> getMaskList() {return maskCol_.getColumn();}
00127 Matrix<Float> getResult() {return resCol_.getColumn();}
00128 Matrix<Float> getResult(uInt irow) {return resCol_.get(irow);}
00129 Matrix<Float> getRms() {return rmsCol_.getColumn();}
00130 Vector<uInt> getNChan() {return nchanCol_.getColumn();}
00131 uInt getNChan(int irow);
00132 Matrix<Float> getClipThreshold() {return cthresCol_.getColumn();}
00133 Matrix<uInt> getClipIteration() {return citerCol_.getColumn();}
00134 Matrix<Bool> getUseLineFinder() {return uselfCol_.getColumn();}
00135 Matrix<Float> getLineFinderThreshold() {return lfthresCol_.getColumn();}
00136 Matrix<uInt> getLineFinderChanAvg() {return lfavgCol_.getColumn();}
00137 Matrix<uInt> getLineFinderEdge() {return lfedgeCol_.getColumn();}
00138
00139 std::vector<bool> getMaskFromMaskList(uInt const nchan, std::vector<int> const& masklist);
00140
00141 private:
00142 void setbasedata(uInt irow, uInt scanno, uInt beamno, uInt antno,
00143 uInt ifno, uInt freqid, Double time);
00144 Table table_, originaltable_;
00145 ScalarColumn<uInt> scanCol_, beamCol_, antCol_, ifCol_, freqidCol_;
00146 ScalarColumn<Double> timeCol_;
00147 MEpoch::ScalarColumn timeMeasCol_;
00148 static const String name_;
00149
00150 ArrayColumn<Bool> applyCol_;
00151 ArrayColumn<uInt> ftypeCol_;
00152 ArrayColumn<Int> fparCol_;
00153 ArrayColumn<Float> ffparCol_;
00154 ArrayColumn<uInt> maskCol_;
00155 ArrayColumn<Float> resCol_;
00156 ArrayColumn<Float> rmsCol_;
00157 ScalarColumn<uInt> nchanCol_;
00158 ArrayColumn<Float> cthresCol_;
00159 ArrayColumn<uInt> citerCol_;
00160 ArrayColumn<Bool> uselfCol_;
00161 ArrayColumn<Float> lfthresCol_;
00162 ArrayColumn<uInt> lfavgCol_;
00163 ArrayColumn<uInt> lfedgeCol_;
00164 };
00165
00166 }
00167
00168 #endif