def smoothing(m, fwhm, nest=True):
    full_map = np.ones(npix)
    full_map[total_mask] = m
    if fwhm <= 0:
        return m
    if nest:
        smoothed_map = hpf.reorder(hp.smoothing(hpf.reorder(full_map, n2r=True), fwhm=fwhm), r2n=True)
    else:
        smoothed_map = hp.smoothing(full_map, fwhm=fwhm)
    return smoothed_map[total_mask]
示例#2
0
def get_faces_par(im, nested=False, num_cores=None):
    npix = np.shape(im)[0]
    assert npix % 12 == 0

    nside = npix2nside(npix)

    if not nested:
        new_im = reorder(im, r2n=True)
    else:
        new_im = im

    # index = np.array([xyf2pix(nside, x, range(nside), 0, True)
    #                     for x in range(nside-1, -1, -1)])
    index = make_index_par(nside, num_cores)

    CubeFace = sm.empty((12, nside, nside))
    with sharedmem_pool(num_cores, numexpr=False) as pool:
        # for face in range(12):
        #     CubeFace[face] = np.resize(new_im[index + nside**2 * face],
        #                                (nside, nside))
        def work(i):
            CubeFace[i] = np.resize(new_im[index + nside**2 * i],
                                    (nside, nside))

        pool.map(work, range(12))

    return np.array(CubeFace)
示例#3
0
def set_faces_par(CubeFace, nested=False, num_cores=None):
    npix = np.size(CubeFace)
    assert npix % 12 == 0

    nside = npix2nside(npix)

    index = make_index_par(nside, num_cores)
    # index = np.array([xyf2pix(nside, x, range(nside), 0, True)
    #                     for x in range(nside-1, -1, -1)])

    imag = sm.empty((npix))
    with sharedmem_pool(num_cores, numexpr=False) as pool:

        def work(i):
            for face in range(12):
                imag[index + nside**2 * face] = np.resize(
                    CubeFace[face], (nside, nside))

        #imag[index + nside**2 * face] = np.resize(CubeFace[face],
        #                                          (nside,nside))

        pool.map(work, range(12))

    imag = np.array(imag)

    if not nested:
        new_im = reorder(imag, n2r=True)
    else:
        new_im = imag

    return new_im
示例#4
0
def get_faces(Imag, nested=False, num_cores=None):
    npix = np.shape(Imag)[0]
    assert npix % 12 == 0

    nside = npix2nside(npix)
    CubeFace = np.zeros((12, nside, nside))

    if not nested:
        NewIm = reorder(Imag, r2n=True)
    else:
        NewIm = Imag

    # index = np.array([xyf2pix(nside, x, range(nside), 0, True)
    #                     for x in range(nside-1, -1, -1)
    #                 ])
    index = make_index_par(nside, num_cores)

    for face in range(12):
        CubeFace[face] = np.resize(NewIm[index + nside**2 * face],
                                   (nside, nside))

    return CubeFace
示例#5
0
def set_faces(CubeFace, nested=False):
    npix = np.size(CubeFace)
    assert npix % 12 == 0

    nside = npix2nside(npix)
    Imag = np.zeros((npix))

    index = np.array([
        xyf2pix(nside, x, range(nside), 0, True)
        for x in range(nside - 1, -1, -1)
    ])

    for face in range(12):
        Imag[index + nside**2 * face] = np.resize(CubeFace[face],
                                                  (nside, nside))

    if not nested:
        NewIm = reorder(Imag, n2r=True)
    else:
        NewIm = Imag

    return NewIm
if os.path.isfile(partial_psf_name):
    partial_psfs = np.fromfile(partial_psf_name, dtype='float64')
    partial_psfs.shape = (npix_nonzero, np.sum(low_sub_mask))
else:
    print "Computing partial PSF, predicted %.1fmin."%(8. * np.sum(low_sub_mask) / 50), datetime.datetime.now()
    sys.stdout.flush()
    timer = time.time()
    partial_psfs = AtNiAi.dot(AtNiA_sum[:, low_sub_mask])
    print "%f minutes used" % (float(time.time() - timer) / 60.)
    sys.stdout.flush()
    partial_psfs.astype('float64').tofile(partial_psf_name)

map_resolution = np.zeros(low_npix) + np.pi / 10.
# map_resolution[low_sub_self_mask] = la.norm([fwhm(partial_psfs[:, c]) for c in range(partial_psfs.shape[1])], axis=-1)
map_resolution[low_sub_self_mask] = np.array([fwhm2(partial_psfs[:, c]) for c in range(partial_psfs.shape[1])])
smoothed_map_resolution = hpf.reorder(hp.smoothing(hpf.reorder(map_resolution, n2r=True), fwhm=2 * hpf.nside2resol(low_nside)), r2n=True)
map_resolution_full = hpf.get_interp_val(smoothed_map_resolution, thetas, phis, nest=True)
map_resolution_full[~total_mask] = np.nan
map_resolution_full.astype('float64').tofile(AtNiAi_filename + '_resolution_nside%i'%low_nside)

#########
####rescale using the rows of the PSF matrix, which I call point collect function (pcf) rather than psf
###########
partial_pcf_name = AtNiAi_filename + '_partialPCF_nside%i'%low_nside
if os.path.isfile(partial_pcf_name):
    partial_pcfs = np.fromfile(partial_pcf_name, dtype='float64')
    partial_pcfs.shape = (npix_nonzero, np.sum(low_sub_mask))
else:
    print "Computing partial PCF, predicted %.1fmin."%(8. * np.sum(low_sub_mask) / 50), datetime.datetime.now()
    sys.stdout.flush()
    timer = time.time()