Source
//# SIISubterBot.cc: This file contains the implementation of the SISubIterBot class.
//#
//# CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
//# Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
//# Copyright (C) European Southern Observatory, 2011, All rights reserved.
//#
//# This library is free software; you can redistribute it and/or
//# modify it under the terms of the GNU Lesser General Public
//# License as published by the Free software Foundation; either
//# version 2.1 of the License, or (at your option) any later version.
//#
//# This library is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY, without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//# Lesser General Public License for more details.
//#
//# You should have received a copy of the GNU Lesser General Public
//# License along with this library; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
//# MA 02111-1307 USA
//# $Id: $
/* Records Interface */
// For FLT_MAX
using namespace casacore;
namespace casa { //# NAMESPACE CASA - BEGIN
SIMinorCycleController::SIMinorCycleController():
itsCycleNiter(0),
itsCycleThreshold(0.0),
itsNsigmaThreshold(0.0),
itsLoopGain(0.1),
itsIsThresholdReached(false),
itsUpdatedModelFlag(false),
itsIterDone(0),
itsCycleIterDone(0),
itsTotalIterDone(0),
itsMaxCycleIterDone(0),
itsPeakResidual(0),
itsIntegratedFlux(0),
itsMaxPsfSidelobe(0),
itsMinResidual(0),itsMinResidualNoMask(0),
itsPeakResidualNoMask(0), itsNsigma(0),
itsMadRMS(0), itsMaskSum(0),
itsSummaryMinor(IPosition(2, SIMinorCycleController::nSummaryFields, 0)),
itsDeconvolverID(0)
{}
SIMinorCycleController::~SIMinorCycleController(){}
Int SIMinorCycleController::majorCycleRequired(Float currentPeakResidual)
{
LogIO os( LogOrigin("SIMinorCycleController",__FUNCTION__,WHERE) );
Int stopCode=0;
// Reached iteration limit
if (itsCycleIterDone >= itsCycleNiter ) {stopCode=1;}
// Reached cyclethreshold
//if( fabs(currentPeakResidual) <= itsCycleThreshold ) { stopCode=2; }
// Reached cyclethreshold or n-sigma threshold
//debug (TT)
//os << LogIO::DEBUG1<< "itsNsigma="<<itsNsigma<<" itsIterDiff="<<itsIterDiff<<LogIO::POST;
os << LogIO::DEBUG1<< "itsNsigmaThreshoild="<<itsNsigmaThreshold<<" itsCycleThreshold="<<itsCycleThreshold<<" currentPeakRes="<<currentPeakResidual<<LogIO::POST;
if (itsCycleThreshold >= itsNsigmaThreshold) {
//if( fabs(currentPeakResidual) <= itsCycleThreshold ) { stopCode=2; }
if( fabs(currentPeakResidual) <= itsCycleThreshold ) {
//itsNsigmaThreshold = 0.0; // since stopped by gobal threshold, reset itsNsigmaThreshold
stopCode=2;
}
}
else {
if( fabs(currentPeakResidual) <= itsNsigmaThreshold && !(itsIterDiff<=0)) { if (itsNsigma!=0.0) stopCode=6; }
}
// Zero iterations done
if( itsIterDiff==0 ) {stopCode=3;}
// Diverged : CAS-8767, CAS-8584
//cout << " itsIterDiff : " << itsIterDiff << " itsPeak : " << itsPeakResidual << " currentPeak : " << currentPeakResidual << " itsMin : " << itsMinResidual << " stopcode so far : " << stopCode ;
if( itsIterDiff>0 &&