Source
# joblist.append( self.PH.runcmd("toolsi.defineimage( impars=" + str( nimpars[str(fld)] ) + ", gridpars=" + str( ngridpars[str(fld)] ) + ")", node ) )
import os
import commands
import math
import shutil
import string
import time
import re;
from taskinit import *
import copy
import pdb
from imagerhelpers.imager_base import PySynthesisImager
from imagerhelpers.parallel_imager_helper import PyParallelImagerHelper
'''
An implementation of parallel continuum imaging, using synthesisxxxx tools
Datasets are partitioned by row and major cycles are parallelized.
Gathers and normalization are done before passing the images to a
non-parallel minor cycle. The output model image is them scattered to
all the nodes for the next parallel major cycle.
There are N synthesisimager objects.
There is 1 instance per image field, of the normalizer and deconvolver.
There is 1 iterbot.
'''
#############################################
#############################################
## Parallelize only major cycle.
#############################################
class PyParallelContSynthesisImager(PySynthesisImager):
def __init__(self,params=None):
PySynthesisImager.__init__(self,params)
self.PH = PyParallelImagerHelper()
self.NN = self.PH.NN
self.selpars = self.allselpars;
self.allselpars = self.PH.partitionContDataSelection(self.allselpars)
# self.allcflist = self.PH.partitionCFCacheList(self.cfcachepars['cflist']);
# self.allcflist = self.PH.partitionCFCacheList(self.allgridpars['0']);
self.listOfNodes = self.PH.getNodeList();
self.coordsyspars = {};
self.toolsi=None
#############################################
##
### TEMPORARY switch for CAS-9977.
##
def initializeImagers(self):
### Init all imagers only with 'csys'.
## There is no coord system mismatch
## There is startmodel confusion. Non 'startmodel' runs are all OK.
self.initializeImagers_Old()
### Drygridding, and Coordsys comes from a single imager on MAIN node.
### There is a coord system mismatch at scatter/gather, if the MAIN version already
### exists on disk. With startmodel, it's xxx.model. With aproject, it's xxx.residual.
### No startmodel confusion. It's created only once and then scattered.
#self.initializeImagers_New()
#############################################
def initializeImagersBase_New(self,thisSelPars,partialSelPars):
if partialSelPars==False: ## Init only on the zero'th node
#
# Use the already-created imager on MAIN node
#
##self.toolsi = casac.synthesisimager()
#
# Select data.
#
for mss in sorted( self.selpars.keys() ):
self.toolsi.selectdata( thisSelPars[mss] )
# Defineimage.
# This makes the global csys. Get csys to distribute to other nodes
# It also sets 'startmodel' if available (this is later scattered to nodes)
for fld in range(0,self.NF):
self.toolsi.defineimage( impars=self.allimpars[str(fld)], gridpars = self.allgridpars[str(fld)] )
fullcoords = self.toolsi.getcsys()
self.coordsyspars[str(fld)] = fullcoords
else: ## partialSelPars==True , The actual initialization on all nodes.
#