// // C++ Implementation: STBaselineTable // // Description: // // // Author: Wataru Kawasaki (C) 2013 // // Copyright: See COPYING file that comes with this distribution // // #include #include #include #include #include #include #include #include #include #include #include #include "Scantable.h" #include "STBaselineTable.h" using namespace casa; namespace asap { const String STBaselineTable::name_ = "APPLY_BASELINE"; STBaselineTable::STBaselineTable(const Scantable& parent) : STApplyTable(parent, name_) { setup(); } STBaselineTable::STBaselineTable(const String &name) : STApplyTable(name) { attachOptionalColumns(); } STBaselineTable::~STBaselineTable() { } void STBaselineTable::setup() { table_.addColumn(ScalarColumnDesc("NCHAN")); table_.addColumn(ScalarColumnDesc("FUNC_TYPE")); table_.addColumn(ArrayColumnDesc("FUNC_PARAM")); table_.addColumn(ArrayColumnDesc("FUNC_FPARAM")); table_.addColumn(ScalarColumnDesc("CLIP_ITERATION")); table_.addColumn(ScalarColumnDesc("CLIP_THRESHOLD")); table_.addColumn(ArrayColumnDesc("MASKLIST")); table_.addColumn(ArrayColumnDesc("RESULT")); table_.addColumn(ScalarColumnDesc("RMS")); table_.rwKeywordSet().define("ApplyType", "BASELINE"); attachOptionalColumns(); } void STBaselineTable::attachOptionalColumns() { nchanCol_.attach(table_, "NCHAN"); ftypeCol_.attach(table_, "FUNC_TYPE"); fparCol_.attach(table_, "FUNC_PARAM"); ffparCol_.attach(table_, "FUNC_FPARAM"); citerCol_.attach(table_, "CLIP_ITERATION"); cthresCol_.attach(table_, "CLIP_THRESHOLD"); maskCol_.attach(table_, "MASKLIST"); resCol_.attach(table_, "RESULT"); rmsCol_.attach(table_, "RMS"); } void STBaselineTable::save(const std::string &filename) { String inname(filename); Path path(inname); inname = path.expandedName(); table_.deepCopy(inname, Table::New); } void STBaselineTable::setdata(uInt irow, uInt scanno, uInt cycleno, uInt beamno, uInt ifno, uInt polno, uInt freqid, Double time, uInt nchan, STBaselineFunc::FuncName ftype, Vector fpar, Vector ffpar, uInt citer, Float cthres, Vector mask, Vector res, Float rms) { if (irow >= (uInt)nrow()) { throw AipsError("row index out of range"); } if (!sel_.empty()) { os_.origin(LogOrigin("STBaselineTable","setdata",WHERE)); os_ << LogIO::WARN << "Data selection is effective. Specified row index may be wrong." << LogIO::POST; } setbasedata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time); nchanCol_.put(irow, nchan); ftypeCol_.put(irow, uInt(ftype)); fparCol_.put(irow, fpar); ffparCol_.put(irow, ffpar); citerCol_.put(irow, citer); cthresCol_.put(irow, cthres); maskCol_.put(irow, mask); resCol_.put(irow, res); rmsCol_.put(irow, rms); } void STBaselineTable::appenddata(uInt scanno, uInt cycleno, uInt beamno, uInt ifno, uInt polno, uInt freqid, Double time, uInt nchan, STBaselineFunc::FuncName ftype, Vector fpar, Vector ffpar, uInt citer, Float cthres, Vector mask, Vector res, Float rms) { uInt irow = nrow(); table_.addRow(1, True); setdata(irow, scanno, cycleno, beamno, ifno, polno, freqid, time, nchan, ftype, fpar, ffpar, citer, cthres, mask, res, rms); } Vector STBaselineTable::getFunctionAsString() { Vector rawBlfuncColumn = ftypeCol_.getColumn(); uInt n = rawBlfuncColumn.nelements(); Vector blfuncColumn(n); for (uInt i = 0; i < n; ++i) { blfuncColumn[i] = STBaselineFunc::FuncName(rawBlfuncColumn(i)); } return blfuncColumn; } uInt STBaselineTable::nchan(uInt ifno) { STSelector org = sel_; STSelector sel; sel.setIFs(vector(1,(int)ifno)); setSelection(sel); uInt n = nchanCol_(0); unsetSelection(); if (!org.empty()) setSelection(org); return n; } }