Source
143
143
void SDAlgorithmMSClean::takeOneStep( Float loopgain, Int cycleNiter, Float cycleThreshold, Float &peakresidual, Float &modelflux, Int &iterdone)
144
144
{
145
145
LogIO os( LogOrigin("SDAlgorithmMSClean","takeOneStep",WHERE) );
146
146
147
147
Quantity thresh( cycleThreshold, "Jy" );
148
148
// Quantity ftthresh( 100.0, "Jy" ); /// Look at MFMSCleanImageSkyModel.cc for more.
149
149
itsCleaner.setcontrol(CleanEnums::MULTISCALE, cycleNiter, loopgain, thresh); //, ftthresh);
150
150
151
151
Matrix<Float> tempModel;
152
152
tempModel.reference( itsMatModel );
153
+
//save the previous model
154
+
Matrix<Float> prevModel;
155
+
prevModel=itsMatModel;
153
156
154
157
//cout << "SDALMS, matrix shape : " << tempModel.shape() << " array shape : " << itsMatModel.shape() << endl;
155
158
156
159
// retval
157
160
// 1 = converged
158
161
// 0 = not converged but behaving normally
159
162
// -1 = not converged and stopped on cleaning consecutive smallest scale
160
163
// -2 = not converged and either large scale hit negative or diverging
161
164
// -3 = clean is diverging rather than converging
162
165
itsCleaner.startingIteration( 0 );
163
166
Int retval = itsCleaner.clean( tempModel );
164
167
iterdone = itsCleaner.numberIterations();
165
168
166
169
if( retval==-1 ) {os << LogIO::WARN << "MSClean minor cycle stopped on cleaning consecutive smallest scale" << LogIO::POST; }
167
170
if( retval==-2 ) {os << LogIO::WARN << "MSClean minor cycle stopped at large scale negative or diverging" << LogIO::POST;}
168
171
if( retval==-3 ) {os << LogIO::WARN << "MSClean minor cycle stopped because it is diverging" << LogIO::POST; }
169
172
170
173
////This is going to be wrong if there is no 0 scale;
171
-
peakresidual = max(abs(itsCleaner.residual()));
174
+
///Matrix<Float> residual(itsCleaner.residual());
175
+
Matrix<Float> residual(itsCleaner.residual(tempModel-prevModel));
176
+
// account for mask as well
177
+
peakresidual = max(abs(residual*itsMatMask));
172
178
modelflux = sum( itsMatModel ); // Performance hog ?
173
179
}
174
180
175
181
void SDAlgorithmMSClean::finalizeDeconvolver()
176
182
{
177
183
///MatrixCleaner does not modify the original residual image matrix
178
184
///so the first line is a dummy.
179
185
(itsImages->residual())->put( itsMatResidual );
180
186
(itsImages->model())->put( itsMatModel );
181
187
}