Example #1
0
    def test_pospix(self):
        # Posmap separable and non-separable on CAR
        for res in [6,12,24]:
            shape,wcs = enmap.fullsky_geometry(res=np.deg2rad(res/60.),proj='car')
            posmap1 = enmap.posmap(shape,wcs)
            posmap2 = enmap.posmap(shape,wcs,separable=True)
            assert np.all(np.isclose(posmap1,posmap2))

        # Pixmap plain
        pres = 0.5
        shape,wcs = enmap.geometry(pos=(0,0),shape=(30,30),res=pres*u.degree,proj='plain')
        yp,xp = enmap.pixshapemap(shape,wcs)
        assert np.all(np.isclose(yp,pres*u.degree))
        assert np.all(np.isclose(xp,pres*u.degree))
        yp,xp = enmap.pixshape(shape,wcs)
        parea = enmap.pixsize(shape,wcs)
        assert np.isclose(parea,(pres*u.degree)**2)
        assert np.isclose(yp,pres*u.degree)
        assert np.isclose(xp,pres*u.degree)
        pmap = enmap.pixsizemap(shape,wcs)
        assert np.all(np.isclose(pmap,(pres*u.degree)**2))

        # Pixmap CAR
        pres = 0.1
        dec_cut = 89.5 # pixsizemap is not accurate near the poles currently
        shape,wcs = enmap.band_geometry(dec_cut=dec_cut*u.degree,res=pres*u.degree,proj='car')
        # Current slow and general but inaccurate near the poles implementation
        pmap = enmap.pixsizemap(shape,wcs)
        # Fast CAR-specific pixsizemap implementation
        dra, ddec = wcs.wcs.cdelt*u.degree
        dec = enmap.posmap([shape[-2],1],wcs)[0,:,0]
        area = np.abs(dra*(np.sin(np.minimum(np.pi/2.,dec+ddec/2))-np.sin(np.maximum(-np.pi/2.,dec-ddec/2))))
        Nx = shape[-1]
        pmap2 = enmap.ndmap(area[...,None].repeat(Nx,axis=-1),wcs)
        assert np.all(np.isclose(pmap,pmap2))
Example #2
0
def interp_enmap(emap, nshape, nwcs, method='cubic', fill_value=np.nan):
    # interpolate enmap to the new shape, and override wcs
    oshape, owcs = emap.shape, emap.wcs
    if nshape == oshape: return emap
    oxm, oym = enmap.posmap(oshape, owcs)
    nxm, nym = enmap.posmap(nshape, nwcs)

    oxm, oym = oxm[:, 0], oym[0, :]
    nxm, nym = nxm[:, 0], nym[0, :]

    f2 = RectBivariateSpline(oxm, oym, emap)
    ndata = f2(nxm, nym)

    return enmap.enmap(ndata, nwcs)
Example #3
0
def get_offset_result(res=1.,dtype=np.float64,seed=1):
    shape,wcs  = enmap.fullsky_geometry(res=np.deg2rad(res))
    shape = (3,) + shape
    obs_pos = enmap.posmap(shape, wcs)
    np.random.seed(seed)
    grad = enmap.enmap(np.random.random(shape),wcs)*1e-3
    raw_pos = enmap.samewcs(lensing.offset_by_grad(obs_pos, grad, pol=shape[-3]>1, geodesic=True), obs_pos)
    return obs_pos,grad,raw_pos
Example #4
0
from orphics import maps,io,cosmology,stats
from pixell import enmap
import numpy as np
import os,sys
import symlens


nsims = 40
deg = 25.
px = 2.0

shape,wcs = maps.rect_geometry(width_deg=deg,px_res_arcmin=px,proj='plain')


modlmap = enmap.modlmap(shape,wcs)
ymap,xmap = enmap.posmap(shape,wcs)

omap = np.sin(ymap/np.pi*100) + np.cos(xmap/np.pi*100)
mfact = 10
afact = 20
rms = (omap - omap.min())*mfact + afact
# io.hplot(rms,colorbar=True)

pmap = enmap.pixsizemap(shape,wcs)

ivar = maps.ivar(shape,wcs,rms,ipsizemap=pmap)
# io.hplot(ivar,colorbar=True)

my_tasks = range(nsims)

theory = cosmology.default_theory()