Esempio n. 1
0
 def _counts(self):
     cts = self.counts.copy()
     cts[self.mask < 0.9] = np.nan
     self.ngals = np.nansum(cts)
     self.nmean = np.nanmean(cts)
     area_sqdeg = enmap.area(self.shape, self.wcs) * (180. / np.pi)**2.
     self.frac = self.mask.sum() * 1. / self.mask.size
     self.area_sqdeg = self.frac * area_sqdeg
     self.ngal_per_arcminsq = self.ngals / (self.area_sqdeg * 60. * 60.)
Esempio n. 2
0
def fcov_to_rcorr(shape, wcs, p2d, N):
    """Convert a 2D PS into a pix-pix covariance
    """
    ncomp = p2d.shape[0]
    p2d *= np.prod(shape[-2:]) / enmap.area(shape, wcs)
    ocorr = enmap.zeros((ncomp, ncomp, N * N, N * N), wcs)
    for i in range(ncomp):
        for j in range(i, ncomp):
            dcorr = ps2d_to_mat(p2d[i, j].copy(), N).reshape((N * N, N * N))
            ocorr[i, j] = dcorr.copy()
            if i != j: ocorr[j, i] = dcorr.copy()
    return ocorr
Esempio n. 3
0
def sim_points(shape, wcs, info):
	# Simulate the point amplitudes
	N = enmap.area(shape, wcs) * info.density*(180/np.pi)**2
	n = N*(info.minamp/info.amp)**(info.alpha+1)
	amps = info.minamp*np.random.uniform(0,1,n)**(1/(info.alpha+1))
	amps = np.maximum(-100*np.abs(info.amp),np.minimum(100*np.abs(info.amp), amps))
	# Simulate the polarization
	psi  = np.random.uniform(0,np.pi,n)
	amps = amps[None,:] * np.array([psi*0+1,np.cos(2*psi)*info.pol,np.sin(2*psi)*info.pol])
	# Simulate positions uniformly in pixels
	ipos = np.array([np.random.uniform(0,shape[-2],n),np.random.uniform(0,shape[-1],n)])
	pos  = enmap.pix2sky(wcs, ipos)
	# Draw the points on a canvas using convolution. This requires all points
	# to have integer pixel positions and the same radius.
	rawmap = np.zeros(shape)
	for i in range(shape[0]):
		rawmap[i][tuple(ipos.astype(int))] = amps[i]
	l = np.sum(enmap.lmap(shape,wcs)**2,0)**0.5
	kernel = np.exp(-0.5*l**2*info.rad**2)
	# actually perform the convolution
	pmap = enmap.ifft(enmap.fft(rawmap)*kernel[None]).real
	print np.max(pmap), np.min(pmap)
	return pmap
Ly, Lx = enmap.extent(shape, wcs)
Ny, Nx = shape[-2:]

if not (do_mask):
    mask = mask * 0. + 1.
else:
    if do_apod:
        mask = nmt.mask_apodization_flat(mask,
                                         Lx,
                                         Ly,
                                         aposize=apod_width,
                                         apotype=apotype)

# Mask fraction
frac = np.sum(mask) * 1. / mask.size
area = enmap.area(shape, wcs) * frac * (180. / np.pi)**2.
print("Masked area sq.deg.: ", area)

w2 = np.mean(mask**2.)  # Naive power scaling factor

N = args.Nsims
s = stats.Stats()  # Stats collector

for i in range(N):
    if (i + 1) % 10 == 0: print(i + 1)

    # Get sim maps (npol,ny,nx) array
    imaps = mg.get_map(scalar=False, iau=iau)  #*mask

    if i == 0:
Esempio n. 5
0
iniFile = "input/recon.ini"
Config = SafeConfigParser()
Config.optionxform = str
Config.read(iniFile)

if rank == 0: print("Params...")

pol = False
shape_dat, wcs_dat = aio.enmap_from_config_section(Config,
                                                   analysis_section,
                                                   pol=pol)
analysis_resolution = np.min(
    enmap.extent(shape_dat, wcs_dat) / shape_dat[-2:]) * 60. * 180. / np.pi
if rank == 0:
    print(("px: ", analysis_resolution, "shape : ", shape_dat))
    area = enmap.area(shape_dat, wcs_dat) * (180. / np.pi)**2.
    print(("area: ", area, " sq.deg."))
    fsky = area / 41250.
    print(("fsky: ", fsky))
min_ell = fmaps.minimum_ell(shape_dat, wcs_dat)
if rank == 0: print("Ell bounds...")

lb = aio.ellbounds_from_config(Config, "reconstruction_alex", min_ell)
tellmin = lb['tellminY']
tellmax = lb['tellmaxY']
pellmin = lb['pellminY']
pellmax = lb['pellmaxY']
kellmin = lb['kellmin']
kellmax = lb['kellmax']

if rank == 0: print("Patches data...")