Пример #1
0
    def predictKernelPolCluster(self,
                                DicoData,
                                SM,
                                iDirection=None,
                                ApplyJones=None,
                                ApplyTimeJones=None,
                                Noise=None):

        DicoData = NpShared.DicoToShared("%sDicoMemChunk" % (self.IdMemShared),
                                         DicoData,
                                         DelInput=False)
        if ApplyTimeJones != None:
            ApplyTimeJones = NpShared.DicoToShared("%sApplyTimeJones" %
                                                   (self.IdMemShared),
                                                   ApplyTimeJones,
                                                   DelInput=False)

        nrow, nch, _ = DicoData["data"].shape

        RowList = np.int64(np.linspace(0, nrow, self.NCPU + 1))
        row0 = RowList[0:-1]
        row1 = RowList[1::]

        work_queue = multiprocessing.Queue()
        result_queue = multiprocessing.Queue()

        workerlist = []
        NCPU = self.NCPU

        NpShared.DelArray("%sPredictData" % (self.IdMemShared))
        PredictArray = NpShared.SharedArray.create(
            "%sPredictData" % (self.IdMemShared),
            DicoData["data"].shape,
            dtype=DicoData["data"].dtype)

        for ii in range(NCPU):
            W = WorkerPredict(work_queue,
                              result_queue,
                              self.IdMemShared,
                              SM=SM,
                              DoSmearing=self.DoSmearing,
                              BeamAtFacet=self._BeamAtFacet)
            workerlist.append(W)
            workerlist[ii].start()

        NJobs = row0.size
        for iJob in range(NJobs):
            ThisJob = row0[iJob], row1[iJob]
            work_queue.put(ThisJob)

        while int(result_queue.qsize()) < NJobs:
            time.sleep(0.1)
            continue

        for ii in range(NCPU):
            workerlist[ii].shutdown()
            workerlist[ii].terminate()
            workerlist[ii].join()

        return PredictArray
Пример #2
0
    def GiveCovariance(self,
                       DicoDataIn,
                       ApplyTimeJones,
                       SM,
                       Mode="DDECovariance"):

        DicoData = NpShared.DicoToShared("%sDicoMemChunk" % (self.IdMemShared),
                                         DicoDataIn,
                                         DelInput=False)

        if ApplyTimeJones != None:
            ApplyTimeJones = NpShared.DicoToShared("%sApplyTimeJones" %
                                                   (self.IdMemShared),
                                                   ApplyTimeJones,
                                                   DelInput=False)

        nrow, nch, _ = DicoData["data"].shape

        RowList = np.int64(np.linspace(0, nrow, self.NCPU + 1))
        row0 = RowList[0:-1]
        row1 = RowList[1::]

        work_queue = multiprocessing.Queue()
        result_queue = multiprocessing.Queue()

        workerlist = []
        NCPU = self.NCPU

        # NpShared.DelArray("%sCorrectedData"%(self.IdMemShared))
        # CorrectedData=NpShared.SharedArray.create("%sCorrectedData"%(self.IdMemShared),DicoData["data"].shape,dtype=DicoData["data"].dtype)
        # CorrectedData=

        for ii in range(NCPU):
            W = WorkerPredict(work_queue,
                              result_queue,
                              self.IdMemShared,
                              Mode=Mode,
                              DoSmearing=self.DoSmearing,
                              SM=SM,
                              BeamAtFacet=self._BeamAtFacet)
            workerlist.append(W)
            workerlist[ii].start()

        NJobs = row0.size
        for iJob in range(NJobs):
            ThisJob = row0[iJob], row1[iJob]
            work_queue.put(ThisJob)

        while int(result_queue.qsize()) < NJobs:
            time.sleep(0.1)
            continue

        for ii in range(NCPU):
            workerlist[ii].shutdown()
            workerlist[ii].terminate()
            workerlist[ii].join()

        DicoDataIn["W"] = DicoData["W"]