//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# Charlottesville, VA 22903-2475 USA
//# $Id: NewCalTable.cc 15602 2011-07-14 00:03:34Z tak.tsutsumi $
//----------------------------------------------------------------------------
#include <msvis/MSVis/ViImplementation2.h>
#include <synthesis/CalTables/CTIter.h>
#include <tables/Tables/ScalarColumn.h>
#include <casa/OS/Timer.h>
using namespace casacore;
namespace casa { //# NAMESPACE CASA - BEGIN
//----------------------------------------------------------------------------
ROCTIter::ROCTIter(NewCalTable tab, const Block<String>& sortcol) :
sortCols_(sortcol.begin( ),sortcol.end( )),
ti_=new TableIterator(tab,sortcol);
// Attach initial accessors:
// cout << "CTIter sort columns (" << sortCols_.nelements() << "): " << sortCols_ << endl;
// If SPW a sort column, then
singleSpw_=anyEQ(sortCols_,String("SPECTRAL_WINDOW_ID"));
// Initialize MSDerivedValues and MEpoch
msd_ = new MSDerivedValues();
msd_->setAntennas(calCol_.antenna());
epoch_ = calCol_.timeMeas()(0);
cout << "singleSpw_ = " << boolalpha << singleSpw_ << endl;
cout << "inct_->nrow() = " << inct_->nrow() << endl;
cout << "this->nrow() = " << this->nrow() << endl;
cout << "iROCTMainCols_->spwId() = " << iROCTMainCols_->spwId().getColumn() << endl;
cout << "iROCTMainCols_->spwId()(0) = " << iROCTMainCols_->spwId()(0) << endl;
cout << "thisSpw() = " << this->thisSpw() << endl;
//----------------------------------------------------------------------------
if (ti_!=NULL) delete ti_;
if (iROCTMainCols_!=NULL) delete iROCTMainCols_;
if (inct_!=NULL) delete inct_;
if (msd_!=NULL) delete msd_;
// Advance the TableIterator
// attach accessors to new iteration
void ROCTIter::updatePhaseCenter() {
// Set MSDerivedValues phase center when changed
if (field != lastfield_) {
Double time = thisTime();
MDirection phaseCenter = calCol_.field().phaseDirMeas(field, time);
msd_->setFieldCenter(phaseCenter);
// Advance the TableIterator
Double ROCTIter::thisTime() const { return iROCTMainCols_->time()(0); };
Vector<Double> ROCTIter::time() const { return iROCTMainCols_->time().getColumn(); };
void ROCTIter::time(Vector<Double>& v) const { iROCTMainCols_->time().getColumn(v); };
void ROCTIter::freq(Vector<Double>& v) const {
calCol_.spectralWindow().chanFreq().get(this->thisSpw(),v);
// more than one spw per iteration...
throw(AipsError("Please sort by spw."));
casacore::MDirection ROCTIter::azel0(casacore::Double time) const {
casacore::MDirection azel;
vi::ViImplementation2::azel0Calculate(time, *msd_, azel, epoch_);
casacore::Double ROCTIter::hourang(casacore::Double time) const {
return vi::ViImplementation2::hourangCalculate(time, *msd_, epoch_);
casacore::Float ROCTIter::parang0(casacore::Double time) const {
return vi::ViImplementation2::parang0Calculate(time, *msd_, epoch_);
void ROCTIter::attach() {
if (iROCTMainCols_!=NULL) delete iROCTMainCols_;
if (inct_!=NULL) delete inct_;
inct_= new NewCalTable(ti_->table());
iROCTMainCols_ = new ROCTMainColumns(*inct_);
CTIter::CTIter(NewCalTable tab, const Block<String>& sortcol) :