Commits

Ville Suoranta authored dab2e431a25 Merge
Merge pull request #485 in CASA/casa from feature/CAS-10060 to master

* commit '2d527481ad4dff786021e4793cbdb60b55a613bb': in-line help edits Fixed nsigma not being set initially in initMinorCycle. This is a workaround for now and more proper handling is done later. save debugging for now Fixed typos in log messages Made nsigma threshold to be updated before the global exit tests Clean up some of debug messages Fixed inconsistent log messages for divergent exit conditions fixed global exit criteria tempoary mod. for debugging Removed the debug statements Added n-sigma threshold stopping initial modifications for N-sigma stopping threshold initial modification for n-sgima stopping n-sigma threshold - the first round of the modifications

code/synthesis/ImagerObjects/SDAlgorithmBase.cc

Modified
116 116 Int startiteration = loopcontrols.getIterDone(); // TODO : CAS-8767 key off subimage index
117 117 Float peakresidual=0.0;
118 118 Float modelflux=0.0;
119 119 Int iterdone=0;
120 120
121 121 ///itsMaskHandler.resetMask( itsImages ); //, (loopcontrols.getCycleThreshold()/peakresidual) );
122 122 Int stopCode=0;
123 123
124 124 Float startpeakresidual = 0.0;
125 125 Float startmodelflux = 0.0;
126 + Array<Double> robustrms;
127 +
126 128 Bool validMask = ( itsImages->getMaskSum() > 0 );
127 129
128 130 if( validMask ) peakresidual = itsImages->getPeakResidualWithinMask();
129 131 else peakresidual = itsImages->getPeakResidual();
130 132 modelflux = itsImages->getModelFlux();
131 133
132 134 startpeakresidual = peakresidual;
133 135 startmodelflux = modelflux;
134 136
137 + // returns as an Array but itsImages is already single plane so
138 + // the return rms contains only a single element
139 + robustrms = itsImages->calcRobustRMS();
140 + //Float nsigma = 150.0; // will set by user, fixed for 3sigma for now.
141 + Float nsigma = loopcontrols.getNsigma();
142 + Float nsigmathresh = nsigma * (Float)robustrms(IPosition(1,0));
143 +
144 + Float thresholdtouse;
145 + if (nsigma>0.0) {
146 + thresholdtouse = max( nsigmathresh, loopcontrols.getCycleThreshold());
147 + }
148 + else {
149 + thresholdtouse = loopcontrols.getCycleThreshold();
150 + }
151 + os << LogIO::DEBUG1<<"loopcontrols.getCycleThreshold()="<<loopcontrols.getCycleThreshold()<<LogIO::POST;
152 + os << LogIO::DEBUG1<< "thresholdtouse="<<thresholdtouse<<LogIO::POST;
153 + String thresholddesc = (thresholdtouse == loopcontrols.getCycleThreshold() ? "cyclethreshold" : "n-sigma");
154 +
155 + if (thresholddesc=="n-sigma") {
156 + os << LogIO::DEBUG1<< "Set nsigma thresh="<<nsigmathresh<<LogIO::POST;
157 + loopcontrols.setNsigmaThreshold(nsigmathresh);
158 + }
135 159 loopcontrols.setPeakResidual( peakresidual );
136 160 loopcontrols.resetMinResidual(); // Set it to current initial peakresidual.
161 +
162 +
137 163 stopCode = checkStop( loopcontrols, peakresidual );
138 164
165 +
139 166 // stopCode=0;
140 167
141 168 if( validMask && stopCode==0 )
142 169 {
143 170
144 171 // Record info about the start of the minor cycle iterations
145 172 loopcontrols.addSummaryMinor( deconvolverid, chanid+polid*nSubChans,
146 173 modelflux, peakresidual );
147 174 // loopcontrols.setPeakResidual( peakresidual );
148 175
149 176 // Init the deconvolver
150 177 initializeDeconvolver();
151 178
152 -
153 179 while ( stopCode==0 )
154 180 {
155 181
182 + if (nsigma>0.0) {
183 + os << "Using " << thresholddesc << " for threshold criterion: (cyclethreshold="<<loopcontrols.getCycleThreshold()<< ", nsigma threshold="<<nsigmathresh<<" )" << LogIO::POST;
184 + loopcontrols.setNsigmaThreshold(nsigmathresh);
185 + }
156 186 Int thisniter = loopcontrols.getCycleNiter() <5000 ? loopcontrols.getCycleNiter() : 2000;
157 187
158 188 loopcontrols.setPeakResidual( peakresidual );
159 189 takeOneStep( loopcontrols.getLoopGain(),
160 190 // loopcontrols.getCycleNiter(),
161 191 thisniter,
162 - loopcontrols.getCycleThreshold(),
192 + //loopcontrols.getCycleThreshold(),
193 + thresholdtouse,
163 194 peakresidual,
164 195 modelflux,
165 196 iterdone);
166 197
167 198 os << LogIO::NORMAL1 << "SDAlgoBase: After one step, dec : " << deconvolverid << " residual=" << peakresidual << " model=" << modelflux << " iters=" << iterdone << LogIO::POST;
168 199
169 200 SynthesisUtilMethods::getResource("In Deconvolver : one step" );
170 201
171 202 loopcontrols.incrementMinorCycleCount( iterdone ); // CAS-8767 : add subimageindex and merge with addSummaryMinor call later.
172 203
218 249 break;
219 250 case 3:
220 251 os << ", Zero iterations performed.";
221 252 break;
222 253 case 4:
223 254 os << ", Possible divergence. Peak residual increased by 10% from minimum.";
224 255 break;
225 256 case 5:
226 257 os << ", Exited " << itsAlgorithmName << " minor cycle without reaching any stopping criterion.";
227 258 break;
259 + case 6:
260 + os << ", Reached n-sigma threshold.";
228 261 default:
229 262 break;
230 263 }
231 264
232 265 os << LogIO::POST;
233 266
234 267 loopcontrols.resetCycleIter();
235 268
236 269 if( peakresidual > maxResidualAcrossPlanes )
237 270 {maxResidualAcrossPlanes=peakresidual; maxResChan=chanid; maxResPol=polid;}

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut