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")
import os
import commands
import math
import shutil
import string
import time
import re;
from taskinit import *
import copy
'''
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:
# print '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):
print "CFCache already exists";
else:
self.dryGridding();
self.fillCFCache();
self.reloadCFCache();
#############################################
def initializeImagers(self):
## Initialize the tool for the current node
self.SItool = casac.synthesisimager()
##print 'impars ', self.allimpars['0']['specmode'], 'frame', self.allimpars['0']['outframe']
## Send in selection parameters for all MSs in the list.
for mss in sorted( (self.allselpars).keys() ):
# if(self.allimpars['0']['specmode']=='cubedata'):
# self.allselpars[mss]['outframe']='Undefined'
self.SItool.selectdata( self.allselpars[mss] )
# self.SItool.selectdata( **(self.allselpars[mss]) )
## For each image-field, define imaging parameters
# nimpars = copy.deepcopy(self.allimpars)
# for fld in range(0,self.NF):
# self.SItool.defineimage( **( nimpars[str(fld)] ) )