Source
stopreasons = ['iteration limit', 'threshold', 'force stop','no change in peak residual across two major cycles', 'peak residual increased by more than 3 times from the previous major cycle','peak residual increased by more than 3 times from the minimum reached','zero mask', 'any combination of n-sigma and other valid exit criterion']
from __future__ import absolute_import
from __future__ import print_function
import os
import math
import shutil
import string
import time
import re
import copy
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import synthesisdeconvolver, iterbotsink, ctsys, table
from casatasks import casalog
from casatasks.private.imagerhelpers.summary_minor import SummaryMinor
ctsys_hostinfo = ctsys.hostinfo
_tb = table() # TODO is this necessary?
else:
from taskinit import *
from imagerhelpers.summary_minor import SummaryMinor
synthesisdeconvolver = casac.synthesisdeconvolver
# make it look like the CASA6 version even though it's using the CASA5 named tool not present in CASA6
iterbotsink = casac.synthesisiterbot
ctsys_hostinfo = casac.cu.hostinfo
_tb = tb # TODO is this necessary?
'''
A set of helper functions for deconvolve.
Summary...
'''
#############################################
class PyDeconvolver:
def __init__(self,params):
################ Tools
self.initDefaults()
# Check all input parameters, after partitioning setup.
# Imaging/Deconvolution parameters. Same for serial and parallel runs
self.alldecpars = params.getDecPars()
self.allimpars = params.getImagePars()
# Iteration parameters
self.iterpars = params.getIterPars() ## Or just params.iterpars
# Not necessary for deconvolver:
## self.allselpars = params.getSelPars()
## self.allgridpars = params.getGridPars()
## self.allnormpars = params.getNormPars()
## self.weightpars = params.getWeightPars()
## Number of fields ( main + outliers )
self.NF = len(self.allimpars.keys())
self.stopMinor = {} ##[0]*self.NF
for immod in range(0,self.NF):
self.stopMinor[str(immod)]=1.0
## for debug mode automask incrementation only
self.ncycle = 0
self.initrecs = []
self.exrecs = []
#############################################
def initializeDeconvolvers(self):
for immod in range(0,self.NF):
self.SDtools.append(synthesisdeconvolver())
decpars = self.alldecpars[str(immod)]
decpars['noRequireSumwt'] = True
self.SDtools[immod].setupdeconvolution(decpars=decpars)
#############################################
def initializeIterationControl(self):
# note that in CASA5 this is casac.synthesisiterbot
self.IBtool = iterbotsink()
itbot = self.IBtool.setupiteration(iterpars=self.iterpars)
#############################################
def estimatememory(self):
griddermem = 0 # no major cycle memory needed
deconmem=0
for immod in range(0,self.NF):
ims= self.allimpars[str(immod)]['imsize']
if(type(ims)==int) :
ims=[ims, ims]
if(len(ims) ==1):
ims.append(ims[0])