def MakeSphe(Support, NpixIm, factorSup=1): #x,y,CF=Gaussian.Gaussian(3,Support,1) CF = ModTaper.Sphe1D(Support, factor=factorSup) CF = np.complex128(CF) #np.array(np.complex128(CF),order="F") zCF = ZeroPad(CF, CF.shape[0]) fCF = fft(CF) fzCF = fft(zCF) zfCF = ZeroPad(fCF, NpixIm) ifzfCF = ifft(zfCF) # pylab.figure(3) # pylab.clf() # pylab.subplot(2,3,1) # pylab.plot(CF) # pylab.title("CF") # pylab.subplot(2,3,2) # pylab.plot(fCF.real) # pylab.plot(fCF.imag) # pylab.title("fCF") # pylab.subplot(2,3,3) # pylab.plot(zCF.real) # pylab.plot(zCF.imag) # pylab.title("zCF") # pylab.subplot(2,3,4) # pylab.plot(fzCF.real) # pylab.plot(fzCF.imag) # pylab.title("fzCF") # pylab.subplot(2,3,5) # pylab.plot(zfCF.real) # pylab.plot(zfCF.imag) # pylab.title("zfCF") # pylab.subplot(2,3,6) # pylab.plot(ifzfCF.real) # pylab.plot(ifzfCF.imag) # pylab.plot(ModTaper.Sphe1D(ifzfCF.shape[0])) # pylab.title("ifzfCF") # pylab.draw() # pylab.show()#False) # pylab.figure(1) return CF, fCF, ifzfCF
def MakeSphe(Support, NpixIm): # x,y,CF=Gaussian.Gaussian(3,Support,1) import ClassTimeIt T = ClassTimeIt.ClassTimeIt() SupportSphe = 111 xc = SupportSphe / 2 CF = ModTaper.Sphe2D(SupportSphe) T.timeit("0") CF = np.complex128(CF) # np.array(np.complex128(CF),order="F") fCF = fft2(CF) fCF = fCF[xc - Support / 2:xc + Support / 2 + 1, xc - Support / 2:xc + Support / 2 + 1].copy() zfCF = ZeroPad(fCF, NpixIm) T.timeit("1") ifzfCF = ifft2(zfCF) # ############" # import pylab # pylab.clf() # pylab.subplot(3,2,1) # lpar=list(pylab.imshow.__defaults__) # lpar[3]="nearest" # pylab.imshow.__defaults__=tuple(lpar) # pylab.imshow(CF.real) # pylab.colorbar() # pylab.subplot(3,2,2) # pylab.imshow(CF.imag) # pylab.colorbar() # pylab.subplot(3,2,3) # pylab.imshow(fCF.real) # pylab.colorbar() # pylab.subplot(3,2,4) # pylab.imshow(fCF.imag) # pylab.colorbar() # pylab.subplot(3,2,5) # pylab.imshow(ifzfCF.real) # pylab.colorbar() # pylab.subplot(3,2,6) # pylab.imshow(ifzfCF.imag) # pylab.colorbar() # pylab.draw() # pylab.show(False) # pylab.pause(0.1) # stop return CF, fCF, ifzfCF
def init_degridders(dir_CFs, dir_DCs, CFs_dict, freqs, subregion_index, lmShift, dname, nfreqbands, DataCorrelationFormat, sems, npix, should_init_cf, wmax, GD, gmachines=None): """ Dummy initialization method to be executed on process pool """ if cw.num_threads > 1: old_omp_setting = os.environ.get("OMP_NUM_THREADS", str(multiprocessing.cpu_count())) # OMP is not fork safe.... we have to force serialization in case the solvers are already set up # to use threading os.environ["OMP_NUM_THREADS"] = "1" dir_CFs = dir_CFs.instantiate() dir_DCs = dir_DCs.instantiate() CFs_dict = CFs_dict.instantiate() gmach = ClassDDEGridMachine.ClassDDEGridMachine(GD, ChanFreq = freqs, Npix = npix, lmShift = lmShift, IDFacet = dir_CFs[dname][subregion_index], SpheNorm = False, # Depricated, set ImToGrid True in .get!! NFreqBands = nfreqbands, DataCorrelationFormat=DataCorrelationFormat, ExpectedOutputStokes=[1], # Stokes I ListSemaphores=sems, cf_dict=CFs_dict, compute_cf=should_init_cf, wmax=wmax) (gmachines is not None) and gmachines.append(gmach) if should_init_cf: wnd_detaper = MT.Sphe2D(npix) wnd_detaper[wnd_detaper != 0] = 1.0 / wnd_detaper[wnd_detaper != 0] dir_DCs["facet_{}".format(dir_CFs[dname][subregion_index])] = wnd_detaper if cw.num_threads > 1: os.environ["OMP_NUM_THREADS"] = old_omp_setting
def setSmall_fCF(self): Support = self.Support SupportSphe = self.SupportSpheCalc if self.Type == "Sphe": xc = SupportSphe // 2 CF = ModTaper.Sphe2D(SupportSphe) # CF.fill(1) CF = np.complex128(CF) # np.array(np.complex128(CF),order="F") fCF = fft2(CF) fCF = fCF[xc - Support // 2:xc + Support // 2 + 1, xc - Support // 2:xc + Support // 2 + 1].copy() if_cut_fCF = ifft2(fCF) elif self.Type == "Gauss": x, y, CF = Gaussian.Gaussian(3, Support, 1) CF = np.complex128(CF) # np.array(np.complex128(CF),order="F") fCF = fft2(CF) self.Small_fCF = fCF self.Small_CF = CF self.if_cut_fCF = if_cut_fCF
def init_degridders(dir_CFs, dir_DCs, CFs_dict, freqs, subregion_index, lmShift, dname, nfreqbands, DataCorrelationFormat, sems, npix, should_init_cf, wmax, GD, gmachines=None): """ Dummy initialization method to be executed on process pool """ dir_CFs = dir_CFs.instantiate() dir_DCs = dir_DCs.instantiate() CFs_dict = CFs_dict.instantiate() gmach = ClassDDEGridMachine.ClassDDEGridMachine( GD, ChanFreq=freqs, Npix=npix, lmShift=lmShift, IDFacet=dir_CFs[dname][subregion_index], SpheNorm=False, # Depricated, set ImToGrid True in .get!! NFreqBands=nfreqbands, DataCorrelationFormat=DataCorrelationFormat, ExpectedOutputStokes=[1], # Stokes I ListSemaphores=sems, cf_dict=CFs_dict, compute_cf=should_init_cf, wmax=wmax) (gmachines is not None) and gmachines.append(gmach) if should_init_cf: wnd_detaper = MT.Sphe2D(npix) wnd_detaper[wnd_detaper != 0] = 1.0 / wnd_detaper[wnd_detaper != 0] dir_DCs["facet_{}".format( dir_CFs[dname][subregion_index])] = wnd_detaper