// // C++ Implementation: STTcal // // Description: // // // Author: Malte Marquarding , (C) 2006 // // Copyright: See COPYING file that comes with this distribution // // #include #include #include #include #include #include #include #include #include #include "STTcal.h" using namespace casacore; namespace asap { const casacore::String STTcal::name_ = "TCAL"; STTcal::STTcal(const Scantable& parent) : STSubTable( parent, name_ ) { setup(); } STTcal& asap::STTcal::operator =( const STTcal & other ) { if ( this != &other ) { static_cast(*this) = other; timeCol_.attach(table_,"TIME"); tcalCol_.attach(table_,"TCAL"); } return *this; } asap::STTcal::STTcal( casacore::Table tab ) : STSubTable(tab, name_) { timeCol_.attach(table_,"TIME"); tcalCol_.attach(table_,"TCAL"); } STTcal::~STTcal() { } void asap::STTcal::setup( ) { // add to base class table table_.addColumn(ScalarColumnDesc("TIME")); table_.addColumn(ArrayColumnDesc("TCAL")); // new cached columns timeCol_.attach(table_,"TIME"); tcalCol_.attach(table_,"TCAL"); } /*** rewrite this for handling of GBT data uInt STTcal::addEntry( const String& time, const Vector& cal) { // test if this already exists Table result = table_( table_.col("TIME") == time ); uInt resultid = 0; if ( result.nrow() > 0) { ROScalarColumn c(result, "ID"); c.get(0, resultid); } else { uInt rno = table_.nrow(); table_.addRow(); // get last assigned tcal_id and increment if ( rno > 0 ) { idCol_.get(rno-1, resultid); resultid++; } tcalCol_.put(rno, cal); timeCol_.put(rno, time); idCol_.put(rno, resultid); } return resultid; } ***/ uInt STTcal::addEntry( const String& time, const Vector& cal) { // test if this already exists // TT - different Tcal values for each polarization, feed, and // data description. So there may be multiple entries for the same // time stamp. uInt resultid; uInt rno = table_.nrow(); //table_.addRow(); // get last assigned tcal_id and increment if ( rno == 0 ) { resultid = 0; } else { idCol_.get(rno-1, resultid); resultid++; } table_.addRow(); tcalCol_.put(rno, cal); timeCol_.put(rno, time); idCol_.put(rno, resultid); return resultid; } void STTcal::getEntry( String& time, Vector& tcal, uInt id ) { Table t = table_(table_.col("ID") == Int(id),1); if (t.nrow() == 0 ) { throw(AipsError("STTcal::getEntry - id out of range")); } ROTableRow row(t); // get first row - there should only be one matching id const TableRecord& rec = row.get(0); time = rec.asString("TIME"); tcal.resize(); Vector out; rec.get("TCAL",out); tcal = out; } } //namespace