def _finalize(self, imap): return maps.crop_center(imap, self.cN) * self.crossfade
ptmap2d1 = pfunc(ktmap1,ktmap1) ptmap2d2 = pfunc(ktmap2,ktmap2) cents, pcross1 = bin(pcross2d1) cents, psim1 = bin(psim2d1) cents, ptmap1 = bin(ptmap2d1) cents, pcross2 = bin(pcross2d2) cents, psim2 = bin(psim2d2) cents, ptmap2 = bin(ptmap2d2) r = (pcross2d1/np.sqrt(psim2d1*ptmap2d1) + pcross2d2/np.sqrt(psim2d2*ptmap2d2))/2 r[~np.isfinite(r)] = 0 fitcrop = 500 data = maps.crop_center(np.fft.fftshift(r),fitcrop) fitfunc = lambda a,x,y,z : maps.crop_center(np.fft.fftshift(model(a,x,y,z)),fitcrop).ravel() X = maps.crop_center(np.fft.fftshift(lxmap),fitcrop) Y = maps.crop_center(np.fft.fftshift(lymap),fitcrop) xdata = np.vstack((X.ravel(), Y.ravel())) ydata = data.ravel() from scipy.optimize import curve_fit popt,pcov = curve_fit(fitfunc,xdata,ydata,p0=[20,0.5,3000],bounds=([1,0,100],[100,1,8000])) print(popt) x,y,z = popt fit = model(0,x,y,z) cents,r1d1 = bin(r) # r1d2 = pcross/np.sqrt(psim*ptmap)
def crop_main(self, img): #return maps.crop_center(img,self.pix_width+self.pix_pad) # very restrictive return maps.crop_center(img, self.pix_width)
lmin, lmax, hybrid, radial, friend, cfreq, fgroup, wrfit = aspecs(qid) weight[modlmap < lmin] = np.nan weight[modlmap > lmax] = np.nan if tutils.is_lfi(qid): N = 40 elif tutils.is_hfi(qid): N = 350 else: N = 500 if i == 0: binner = stats.bin2D(modlmap, bin_edges) Ny, Nx = weight.shape[-2:] M = maps.crop_center(np.fft.fftshift(modlmap), N, int(N * Nx / Ny)) # print(M.max()) # io.plot_img(maps.crop_center(np.fft.fftshift(weight),N,int(N*Nx/Ny)),"%s/weight2d_%s.pdf" % (os.environ['WORK'],qid),aspect='auto',xlabel='$\\ell_x$',ylabel='$\\ell_y$',arc_width=2*M[0,0]) # io.plot_img(np.log10(maps.crop_center(np.fft.fftshift(cov),N,int(N*Nx/Ny))),"%s/cov2d_%s.pdf" % (os.environ['WORK'],qid),aspect='auto',xlabel='$\\ell_x$',ylabel='$\\ell_y$',arc_width=2*M[0,0]) cents, w1d = binner.bin(weight) w1ds.append(w1d) actmap = { "d56_01": "D56_1_150", "d56_02": "D56_2_150", "d56_03": "D56_3_150", "d56_04": "D56_4_150", "d56_05": "D56_5_098",
def power_crop(p2d, N, fname, ftrans=True, **kwargs): from orphics import maps pmap = maps.ftrans(p2d) if ftrans else p2d Ny, Nx = p2d.shape pimg = maps.crop_center(pmap, N, int(N * Nx / Ny)) plot_img(pimg, fname, aspect='auto', **kwargs)
import os, sys from tilec import utils as tutils, covtools import numpy as np from orphics import io, stats, cosmology, maps from pixell import enmap shape, wcs = maps.rect_geometry(width_deg=50., height_deg=30, px_res_arcmin=0.5) modlmap = enmap.modlmap(shape, wcs) ells = np.arange(0, 8000, 1) theory = cosmology.default_theory() cltt2d = enmap.enmap(theory.lCl('TT', modlmap), wcs) cltt2d[modlmap < 50] = 0 cltt = theory.lCl('TT', ells) ndown = covtools.signal_average(cltt2d, bin_width=40) ny = int(shape[0] * 5. / 100.) nx = int(shape[1] * 5. / 100.) diff = maps.crop_center(np.fft.fftshift((ndown - cltt2d) / cltt2d), ny, nx) io.plot_img(diff, "diff2d.png", aspect='auto', lim=[-0.1, 0.1])
ivars = dm.get_splits_ivar(season=season,patch=patch,arrays=dm.array_freqs[array]) n2d_xflat = noise.get_n2d_data(splits,ivars,mask,coadd_estimator=True, flattened=False, plot_fname=None, dtype=dm.dtype) modlmap = splits.modlmap() bin_edges = np.arange(20,8000,20) binner = stats.bin2D(modlmap,bin_edges) n2d = n2d_xflat[3,3] cents,n1d = binner.bin(n2d) pl = io.Plotter(xyscale='linlog',scalefn = lambda x: x**2,xlabel='l',ylabel='D*2pi') pl.add(cents,n1d) pl.done('n1d.png') nsplits = 4 delta_ell = 400 n2d_xflat_smoothed,_,_ = covtools.noise_block_average(n2d,nsplits,delta_ell,lmin=300,lmax=8000,wnoise_annulus=500,bin_annulus=20, lknee_guess=3000,alpha_guess=-4,nparams=None,log=True,radial_fit=False) print(n2d_xflat.shape,n2d_xflat_smoothed.shape) N = 1200 Ny,Nx = n2d_xflat_smoothed.shape[-2:] M = maps.crop_center(np.fft.fftshift(modlmap),N,int(N*Nx/Ny)) d = maps.crop_center(np.fft.fftshift(n2d_xflat_smoothed),N,int(N*Nx/Ny)) # io.hplot(np.log10(d),'fig_hnoise',colorbar=True) # io.plot_img(np.log10(np.fft.fftshift(n2d_xflat_smoothed)),'fig_tlognoise.png',aspect='auto') io.plot_img(maps.crop_center(np.log10(np.fft.fftshift(n2d_xflat_smoothed)),N,int(N*Nx/Ny)),"fig_noise.pdf" ,aspect='auto',xlabel='$\\ell_x$',ylabel='$\\ell_y$',arc_width=2*M[0,0],lim=[-4.39,-3.46],label="$\\rm{log}_{10}(N ~\\mu{\\rm K}^2\\cdot {\\rm sr})$")