Example #1
0
def get_geometry_regions(ncomp,n,res,hole_radius):
    tshape,twcs = enmap.geometry(pos=(0,0),shape=(n,n),res=res,proj='car')
    modrmap = enmap.modrmap(tshape,twcs)
    
    # Select the hole (m1) and context(m2) across all components
    amodrmap = np.repeat(modrmap.reshape((1,n,n)),ncomp,0)
    m1 = np.where(amodrmap.reshape(-1)<hole_radius)[0]
    m2 = np.where(amodrmap.reshape(-1)>=hole_radius)[0]
    return m1,m2
Example #2
0
                            proj='plain')

# Select the fiducial cluster profile from Hu, DeDeo, Vale 2007
massOverh = 2e14
z = 0.7
c = 3.2
cc = cutils.get_hdv_cc()


# Set up lensing
def lens_map(imap):
    return plensing.displace_map(imap, alpha, order=args.lens_order)


# Map of distances from center
modrmap = enmap.modrmap(shape, wcs)
# The convergence ~ projected mass density
kappa = lensing.nfw_kappa(massOverh,
                          modrmap,
                          cc,
                          zL=z,
                          concentration=c,
                          overdensity=180.,
                          critical=False,
                          atClusterZ=False)
if rank == 0: enmap.write_map(f'{savedir}kappa.fits', kappa)

# Deflection field
alpha = lensing.alpha_from_kappa(kappa)
# Fourier magnitude map
modlmap = enmap.modlmap(shape, wcs)
Example #3
0
    def test_thumbnails(self):
        print("Testing thumbnails...")

        # Make a geometry far away from the equator
        dec_min = 70 * u.degree
        dec_max = 80 * u.degree
        res = 0.5 * u.arcmin
        shape, wcs = enmap.band_geometry((dec_min, dec_max), res=res)

        # Create a set of point source positions separated by
        # 2 degrees but with 1 column wrapping around the RA
        # direction
        width = 120 * u.arcmin
        Ny = int((dec_max - dec_min) / (width))
        Nx = int((2 * np.pi / (width)))
        pys = np.linspace(0, shape[0], Ny)[1:-1]
        pxs = np.linspace(0, shape[1], Nx)[:-1]
        Ny = len(pys)
        Nx = len(pxs)
        xx, yy = np.meshgrid(pxs, pys)
        xx = xx.reshape(-1)
        yy = yy.reshape(-1)
        ps = np.vstack((yy, xx))
        decs, ras = enmap.pix2sky(shape, wcs, ps)

        # Simulate these sources with unit peak value and 2.5 arcmin FWHM
        N = ps.shape[1]
        srcs = np.zeros((N, 3))
        srcs[:, 0] = decs
        srcs[:, 1] = ras
        srcs[:, 2] = ras * 0 + 1
        sigma = 2.5 * u.fwhm * u.arcmin
        omap = pointsrcs.sim_srcs(shape, wcs, srcs, beam=sigma)

        # Reproject thumbnails centered on the sources
        # with gnomonic/tangent projection
        proj = "tan"
        r = 10 * u.arcmin
        ret = reproject.thumbnails(omap,
                                   srcs[:, :2],
                                   r=r,
                                   res=res,
                                   proj=proj,
                                   apod=2 * u.arcmin,
                                   order=3,
                                   oversample=2,
                                   pixwin=False)

        # Create a reference source at the equator to compare this against
        ishape, iwcs = enmap.geometry(shape=ret.shape,
                                      res=res,
                                      pos=(0, 0),
                                      proj=proj)
        imodrmap = enmap.modrmap(ishape, iwcs)
        model = np.exp(-imodrmap**2. / 2. / sigma**2.)

        # Make sure all thumbnails agree with the reference at the
        # sub-percent level
        for i in range(ret.shape[0]):
            diff = ret[i] - model
            assert np.all(np.isclose(diff, 0, atol=1e-3))