Source
#casalog.post("Deleting : " + namelist + ' from ' + self.getworkdir(imagename, node) + ' starting with ' + imagename)
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 synthesisutils
from casatasks import casalog
else:
from taskinit import *
synthesisutils = casac.synthesisutils
'''
A set of helper functions for the tasks tclean
Summary...
'''
#############################################
### Parallel Imager Helper.
#############################################
#casalog.post('Using clustermanager from MPIInterface', 'WARN')
try:
if is_CASA6:
from casampi.MPIInterface import MPIInterface as mpi_clustermanager
mpi_available = True
else:
from mpi4casa.MPIInterface import MPIInterface as mpi_clustermanager
mpi_available = True
except ImportError:
mpi_available = False
class PyParallelImagerHelper():
def __init__(self):
############### Cluster Info
self.CL=None
self.sc=None
self.nodeList=None;
# Initialize cluster, and partitioning.
############### Number of nodes to parallelize on
# self.nodeList gets filled by setupCluster()
self.NN = self.setupCluster()
def getNodeList(self):
return self.nodeList;
#############################################
def chunkify(self,lst,n):
return [ lst[i::n] for i in range(n) ]
def partitionCFCacheList(self,gridPars):
cfcName = gridPars['cfcache'];
cflist=[];
if (not (cfcName == '')):
cflist=[f for f in os.listdir(cfcName) if re.match(r'CFS*', f)];
nCF = len(cflist);
nProcs=len(self.nodeList);
if (nProcs > nCF):
n=nCF;
else:
n=nProcs;
if (nCF > 0):
casalog.post("########################################################");
casalog.post("nCF = " + str(nCF) + " nProcs = " + str(n) + " NodeList=" + str(self.nodeList));
casalog.post("########################################################");
xx=self.chunkify(cflist,n);
allcfs={};
for i in range(n):
allcfs[i+1]=xx[i];
return allcfs;
#############################################
# The above version works better (better balanced chunking).
# Keeping the code below in the file sometime, just in case...(SB).
# def partitionCFCacheList(self,gridPars):
# cfcName = gridPars['cfcache'];
# cflist=[];
# if (not (cfcName == '')):