Source
#casalog.post("Model visibilities may not have been saved in the MS even though you have asked for it. Please check the logger for the phrases 'Run (Last) Major Cycle' and '" + wstr +"'. If these do not appear, then please save the model via a separate tclean run with niter=0,calcres=F,calcpsf=F. It will pick up the existing model from disk and save/predict it. Reason for this : For performance reasons model visibilities are saved only in the last major cycle. If the X button on the interactive GUI is used to terminate a run before this automatically detected 'last' major cycle, the model isn't written. However, a subsequent tclean run as described above will predict and save the model. ","WARN")
from __future__ import absolute_import
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 synthesisimager, synthesisdeconvolver, synthesisnormalizer, iterbotsink, ctsys, table
from casatasks import casalog
ctsys_hostinfo = ctsys.hostinfo
_tb = table()
else:
from taskinit import *
synthesisimager = casac.synthesisimager
synthesisdeconvolver = casac.synthesisdeconvolver
synthesisnormalizer = casac.synthesisnormalizer
# 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
'''
A set of helper functions for tclean.
Summary...
'''
#############################################
class PySynthesisImager:
def __init__(self,params):
################ Tools
self.initDefaults()
# Check all input parameters, after partitioning setup.
# Selection Parameters. Dictionary of dictionaries, indexed by 'ms0','ms1',...
self.allselpars = params.getSelPars()
# Imaging/Deconvolution parameters. Same for serial and parallel runs
self.alldecpars = params.getDecPars()
self.allimpars = params.getImagePars()
self.allgridpars = params.getGridPars()
self.allnormpars = params.getNormPars()
self.weightpars = params.getWeightPars()
# Iteration parameters
self.iterpars = params.getIterPars() ## Or just params.iterpars
# CFCache params
self.cfcachepars = params.getCFCachePars()
## 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
## Number of nodes. This gets set for parallel runs
## It can also be used serially to process the major cycle in pieces.
self.NN = 1
## for debug mode automask incrementation only
self.ncycle = 0
# isvalid = self.checkParameters()
# if isvalid==False:
# casalog.post('Invalid parameters')
#############################################
# def checkParameters(self):
# # Copy the imagename from impars to decpars, for each field.
# for immod in range(0,self.NF):
# self.alldecpars[str(immod)]['imagename'] = self.allimpars[str(immod)]['imagename']
# return True
#############################################
def makeCFCache(self,exists):
# Make the CFCache and re-load it. The following calls become
# NoOps (in SynthesisImager.cc) if the gridder is not one
# which uses CFCache.
if (exists):
casalog.post("CFCache already exists")
else:
self.dryGridding();
self.fillCFCache();
self.reloadCFCache();
#############################################