def _createPrimarySplitCommand(self): if self._arg['createmms']: if self._arg['separationaxis'].lower() == 'scan': self._createScanSeparationCommands() elif self._arg['separationaxis'].lower() == 'spw': self._createSPWSeparationCommands() elif self._arg['separationaxis'].lower() == 'both': self._createDefaultSeparationCommands() else: # Single mms case singleCmd = copy.copy(self._arg) singleCmd['calmsselection'] = 'none' if scanList is not None: singleCmd['scan'] = ParallelTaskHelper.\ listToCasaString(scanList) self._executionList.append( simple_cluster.JobData(self._taskName, singleCmd))
def _createDefaultSeparationCommands(self): # This method is similar to the SPW Separation mode above, except # that if there are not enough SPW to satisfy the numSubMS it uses # self._selectMS() # Get the list of spectral windows spwList = self._getSPWList() # Check if we can just divide on SPW or if we need to do SPW and # scan numSubMS = self._arg['numsubms'] numSpwPartitions = min(len(spwList), numSubMS) numScanPartitions = int(math.ceil(numSubMS / float(numSpwPartitions))) if numScanPartitions > 1: # Check that the scanlist is not null scanList = self._selectionScanList if scanList is None: scanList = self._getScanList() # Check that the number of scans is enough for the partitions if len(scanList) < numScanPartitions: numScanPartitions = len(scanList) else: scanList = None partitionedSpws = self.__partition(spwList, numSpwPartitions) partitionedScans = self.__partition(scanList, numScanPartitions) for output in xrange(numSpwPartitions * numScanPartitions): mmsCmd = copy.copy(self._arg) mmsCmd['createmms'] = False mmsCmd['calmsselection'] = 'none' mmsCmd['scan'] = ParallelTaskHelper.listToCasaString \ (partitionedScans[output%numScanPartitions]) mmsCmd['spw'] = ParallelTaskHelper.listToCasaString\ (partitionedSpws[output/numScanPartitions]) mmsCmd['outputvis'] = self.dataDir+'/%s.%04d.ms' \ % (self.outputBase, output) self._executionList.append( simple_cluster.JobData(self._taskName, mmsCmd))
def _createCalMSCommand(self): ''' Create a command which will generate a MS with only those subMSs in the selected calibration ''' self._selectMS(True) self._calScanList = self._getScanList() # Now create the command dict. for this calCmd = copy.copy(self._arg) calCmd['createmms'] = False calCmd['calmsselection'] = 'none' calCmd['scan'] = ParallelTaskHelper.listToCasaString(self._calScanList) if self._arg['createmms']: calCmd['outputvis'] = self.dataDir + '/%s.cal.ms' % self.outputBase else: calCmd['outputvis'] = self._arg['calmsname'] self._executionList.append( simple_cluster.JobData(self._taskName, calCmd))
def generateJobs(self): """ This is the method which generates all of the actual jobs to be done. The default is to asume the input vis is a reference ms and build one job for each referenced ms. """ casalog.origin("ParallelTaskHelper") try: msTool = mstool() if not msTool.open(self._arg['vis']): raise ValueError, "Unable to open MS %s," % self._arg['vis'] if not msTool.ismultims(): raise ValueError, \ "MS is not a MultiMS, simple parallelization failed" subMs_idx = 0 for subMS in msTool.getreferencedtables(): localArgs = copy.deepcopy(self._arg) localArgs['vis'] = subMS for key in self._arguser: localArgs[key] = self._arguser[key][subMs_idx] subMs_idx += 1 if not self._mpi_cluster: self._executionList.append( simple_cluster.JobData(self._taskName, localArgs)) else: self._executionList.append( [self._taskName + '()', localArgs]) msTool.close() return True except Exception, instance: casalog.post( "Error handling MMS %s: %s" % (self._arg['vis'], instance), "WARN", "generateJobs") msTool.close() return False
def _createSPWSeparationCommands(self): # This method is to generate a list of commands to partition # the data based on SPW. self._selectMS() spwList = self._getSPWList() numSubMS = self._arg['numsubms'] numSubMS = min(len(spwList), numSubMS) partitionedSPWs = self.__partition(spwList, numSubMS) for output in xrange(numSubMS): mmsCmd = copy.copy(self._arg) mmsCmd['createmms'] = False mmsCmd['calmsselection'] = 'none' if self._selectionScanList is not None: mmsCmd['scan'] = ParallelTaskHelper.\ listToCasaString(self._selectionScanList) mmsCmd['spw'] = ParallelTaskHelper.\ listToCasaString(partitionedSPWs[output]) mmsCmd['outputvis'] = self.dataDir+'/%s.%04d.ms' \ % (self.outputBase, output) self._executionList.append( simple_cluster.JobData(self._taskName, mmsCmd))
def _createScanSeparationCommands(self): scanList = self._selectionScanList if scanList is None: self._selectMS() scanList = self._getScanList() # Make sure we have enough scans to create the needed number of # subMSs. If not change the total expected. numSubMS = self._arg['numsubms'] numSubMS = min(len(scanList), numSubMS) partitionedScans = self.__partition(scanList, numSubMS) for output in xrange(numSubMS): mmsCmd = copy.copy(self._arg) mmsCmd['createmms'] = False mmsCmd['calmsselection'] = 'none' mmsCmd['scan']= ParallelTaskHelper.\ listToCasaString(partitionedScans[output]) mmsCmd['outputvis'] = self.dataDir+'/%s.%04d.ms' \ % (self.outputBase, output) self._executionList.append( simple_cluster.JobData(self._taskName, mmsCmd))