Commits

Srikrishna Sekhar authored a3f52b7c17d
CAS-14184 : Fixed masking params

Some auto-multithresh parameters were missing from the _gclean input, added those in. The order of masking was also incorrect, the auto-mask growing was happening _prior_ to deconvolution rather than after. This has also been fixed.

casatasks/src/private/imagerhelpers/_gclean.py

Modified
186 186 else:
187 187 if isinstance(self._threshold, str):
188 188 if "mJy" in self._threshold:
189 189 self._threshold = float(self._threshold.replace("mJy", "")) / 1e3
190 190 elif "uJy" in self._threshold:
191 191 self._threshold = float(self._threshold.replace("uJy", "")) / 1e6
192 192 elif "Jy" in self._threshold:
193 193 self._threshold = float(self._threshold.replace("Jy", ""))
194 194
195 195
196 - def __init__( self, vis, imagename, field='', spw='', timerange='', uvrange='', antenna='', scan='', observation='', intent='', datacolumn='corrected',
197 - imsize=[100], cell=[ ], phasecenter='', stokes='I', startmodel='', specmode='cube', reffreq='', nchan=-1, start='', width='',
198 - outframe='LSRK', veltype='radio', restfreq='', interpolation='linear', perchanweightdensity=True, gridder='standard', wprojplanes=int(1),
199 - mosweight=True, psterm=False, wbawp=True, conjbeams=False, usepointing=False, pointingoffsetsigdev=[ ], pblimit=0.2, deconvolver='hogbom',
200 - smallscalebias=0.0, niter=0, threshold='0.1Jy', nsigma=0.0, cycleniter=-1, nmajor=1, cyclefactor=1.0, minpsffraction=0.05, maxpsffraction=0.8,
201 - scales=[], restoringbeam='', pbcor=False, nterms=int(2), weighting='natural', robust=float(0.5), npixels=0, gain=float(0.1),
202 - sidelobethreshold=3.0, noisethreshold=5.0, lownoisethreshold=1.5, negativethreshold=0.0, minbeamfrac=0.3, growiterations=75, dogrowprune=True,
203 - minpercentchange=-1.0, fastnoise=True, savemodel='none', usemask='user', mask='', parallel=False,
204 - history_filter=lambda index, arg, history_value: history_value ):
196 + def __init__( self, vis, imagename, field='', spw='', timerange='', uvrange='', antenna='', scan='', observation='', intent='', datacolumn='corrected', imsize=[100], cell=[ ],
197 + phasecenter='', stokes='I', startmodel='', specmode='cube', reffreq='', nchan=-1, start='', width='', outframe='LSRK', veltype='radio', restfreq='', interpolation='linear',
198 + perchanweightdensity=True, gridder='standard', wprojplanes=int(1), mosweight=True, psterm=False, wbawp=True, conjbeams=False, usepointing=False, pointingoffsetsigdev=[ ],
199 + pblimit=0.2, deconvolver='hogbom', smallscalebias=0.0, niter=0, threshold='0.1Jy', nsigma=0.0, cycleniter=-1, nmajor=1, cyclefactor=1.0, minpsffraction=0.05,
200 + maxpsffraction=0.8, scales=[], restoringbeam='', pbcor=False, nterms=int(2), weighting='natural', robust=float(0.5), npixels=0, gain=float(0.1), pbmask=0.2, sidelobethreshold=3.0,
201 + noisethreshold=5.0, lownoisethreshold=1.5, negativethreshold=0.0, smoothfactor=1.0, minbeamfrac=0.3, cutthreshold=0.01, growiterations=75, dogrowprune=True,
202 + minpercentchange=-1.0, verbose=False, fastnoise=True, savemodel='none', usemask='user', mask='', parallel=False, history_filter=lambda index, arg, history_value: history_value ):
203 +
205 204 self._vis = vis
206 205 self._imagename = imagename
207 206 self._imsize = imsize
208 207 self._cell = cell
209 208 self._phasecenter = phasecenter
210 209 self._stokes = stokes
211 210 self._startmodel = startmodel
212 211 self._specmode = specmode
213 212 self._reffreq = reffreq
214 213 self._nchan = nchan
252 251 self._uvrange = uvrange
253 252 self._antenna = antenna
254 253 self._scan = scan
255 254 self._observation = observation
256 255 self._intent = intent
257 256 self._datacolumn = datacolumn
258 257 self._weighting = weighting
259 258 self._robust = robust
260 259 self._npixels = npixels
261 260 self._gain = gain
261 + self._pbmask = pbmask
262 262 self._sidelobethreshold = sidelobethreshold
263 263 self._noisethreshold = noisethreshold
264 264 self._lownoisethreshold = lownoisethreshold
265 265 self._negativethreshold = negativethreshold
266 + self._smoothfactor = smoothfactor,
266 267 self._minbeamfrac = minbeamfrac
268 + self._cutthreshold = cutthreshold
267 269 self._growiterations = growiterations
268 270 self._dogrowprune = dogrowprune
269 271 self._minpercentchange = minpercentchange
272 + self._verbose = verbose
270 273 self._fastnoise = fastnoise
271 274 self._savemodel = savemodel
272 275 self._parallel = parallel
273 276 self._usemask = usemask
274 277
275 278 ###
276 279 ### 'self._mask' always contains the mask as supplied by the user while 'self._effective_mask' is
277 280 ### the mask currently in play as interactive clean progresses. When the user has supplied a mask,
278 281 ### it should be the same as 'self._mask' but when the mask is managed internally by iclean/gclean
279 282 ### the two will diverge.
435 438 field=self._field, spw=self._spw, timerange=self._timerange, uvrange=self._uvrange, antenna=self._antenna,
436 439 scan=self._scan, observation=self._observation, intent=self._intent, datacolumn=self._datacolumn,
437 440 weighting=self._weighting, robust=self._robust, npixels=self._npixels, interactive=False, niter=0,
438 441 gain=self._gain, calcres=True, calcpsf=True, restoration=False, parallel=self._parallel, fullsummary=True)
439 442
440 443
441 444 deconv_ret = self._deconvolve(imagename=self._imagename, startmodel=self._startmodel,
442 445 deconvolver=self._deconvolver, restoration=False,
443 446 threshold=self._threshold, niter=0,
444 447 nsigma=self._nsigma, fullsummary=True, fastnoise=self._fastnoise, usemask=self._usemask,
445 - mask=self._mask, noisethreshold=self._noisethreshold)
448 + mask=self._mask, pbmask=self._pbmask, sidelobethreshold=self._sidelobethreshold, noisethreshold=self._noisethreshold,
449 + lownoisethreshold=self._lownoisethreshold, negativethreshold=self._negativethreshold, smoothfactor=self._smoothfactor,
450 + minbeamfrac=self._minbeamfrac, cutthreshold=self._cutthreshold, growiterations=self._growiterations,
451 + dogrowprune=self._dogrowprune, minpercentchange=self._minpercentchange, verbose=self._verbose)
446 452
447 453 self.current_imdict.returndict = self.current_imdict.merge(tclean_ret, deconv_ret)
448 454 self.global_imdict.returndict = self.current_imdict.returndict
449 455
450 456 ## Initial call where niterleft and nmajorleft are same as original input values.
451 457 self.hasit, self.stopdescription = self.global_imdict.has_converged(self._niter, self._threshold, self._nmajor)
452 458
453 459 self.current_imdict.returndict['stopcode'] = self.hasit
454 460 self.current_imdict.returndict['stopDescription'] = self.stopdescription
455 461 self._major_done = 0
470 476 #self.current_imdict.returndict['stopDescription'] = self.stopdescription
471 477
472 478 # Has not, i.e., not converged
473 479 if self.hasit ==0 :
474 480 use_cycleniter, cyclethreshold = self._calc_deconv_controls(self.current_imdict, self._niter, self._threshold, self._cycleniter)
475 481
476 482 print("No convergence, running deconvolve + tclean")
477 483 # Run the minor cycle
478 484 deconv_ret = self._deconvolve(imagename=self._imagename, startmodel=self._startmodel,
479 485 deconvolver=self._deconvolver, restoration=False,
480 - threshold=cyclethreshold, niter=use_cycleniter, gain=self._gain, usemask=self._usemask,
481 - nsigma=self._nsigma, fullsummary=True, fastnoise=self._fastnoise, noisethreshold=self._noisethreshold)
486 + threshold=cyclethreshold, niter=use_cycleniter, gain=self._gain, fullsummary=True)
482 487
483 488 # Run the major cycle
484 489 tclean_ret = self._tclean( vis=self._vis, imagename=self._imagename, imsize=self._imsize, cell=self._cell,
485 490 phasecenter=self._phasecenter, stokes=self._stokes, specmode=self._specmode, reffreq=self._reffreq,
486 491 gridder=self._gridder, wprojplanes=self._wprojplanes, mosweight=self._mosweight, psterm=self._psterm,
487 492 wbawp=self._wbawp, conjbeams=self._conjbeams, usepointing=self._usepointing, interpolation=self._interpolation,
488 493 perchanweightdensity=self._perchanweightdensity, nchan=self._nchan, start=self._start,
489 494 width=self._width, veltype=self._veltype, restfreq=self._restfreq, outframe=self._outframe,
490 495 pointingoffsetsigdev=self._pointingoffsetsigdev, pblimit=self._pblimit, deconvolver=self._deconvolver,
491 496 smallscalebias=self._smallscalebias, cyclefactor=self._cyclefactor, scales=self._scales,
518 523 self.hasit, self.stopdescription = self.global_imdict.has_converged(self._niter, self._threshold, self._nmajor, masksum=0)
519 524 else:
520 525 self.hasit, self.stopdescription = self.global_imdict.has_converged(self._niter, self._threshold, self._nmajor)
521 526
522 527
523 528 self.global_imdict.returndict['stopcode'] = self.hasit
524 529 self.global_imdict.returndict['stopDescription'] = self.stopdescription
525 530
526 531 if not self.hasit:
527 532 # If we haven't converged, run deconvolve to update the mask
528 - self._deconvolve(imagename=self._imagename, niter=0, deconvolver=self._deconvolver, usemask=self._usemask, restoration=False)
533 + #print("no convergence, updating mask")
534 +
535 + self._deconvolve(imagename=self._imagename, startmodel=self._startmodel, deconvolver=self._deconvolver, restoration=False, threshold=self._threshold, niter=0,
536 + nsigma=self._nsigma, fullsummary=True, fastnoise=self._fastnoise, usemask=self._usemask, mask=self._mask, pbmask=self._pbmask,
537 + sidelobethreshold=self._sidelobethreshold, noisethreshold=self._noisethreshold, lownoisethreshold=self._lownoisethreshold,
538 + negativethreshold=self._negativethreshold, smoothfactor=self._smoothfactor, minbeamfrac=self._minbeamfrac, cutthreshold=self._cutthreshold,
539 + growiterations=self._growiterations, dogrowprune=self._dogrowprune, minpercentchange=self._minpercentchange, verbose=self._verbose)
540 +
529 541
530 - #print('\nGLOBAL returndict : ',self.global_imdict.returndict)
531 542 if len(self.global_imdict.returndict) > 0 and 'summaryminor' in self.global_imdict.returndict and sum(map(len,self.global_imdict.returndict['summaryminor'].values())) > 0:
532 - # self.current_imdict only contains the latest tclean/deconvolve results
533 - # Passing in self.global_imdict will pull out the cumulative results everytime, breaking the convergence plot.
534 543 self._convergence_result = ( self.global_imdict.returndict['stopDescription'] if 'stopDescription' in self.global_imdict.returndict else '',
535 544 self.global_imdict.returndict['stopcode'] if 'stopcode' in self.global_imdict.returndict else 0,
536 545 self._major_done,
537 546 self._nmajor,
538 547 self._niter,
539 548 self.__add_per_major_items( self.global_imdict.returndict,
540 549 self._convergence_result[5]['major'],
541 550 self.__update_convergence()))
542 551 else:
543 552 self._convergence_result = ( f'tclean returned an empty result',

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

Add shortcut