使用healpy平滑面膜

时间:2017-07-27 19:44:43

标签: healpy

我正在使用healpy.sphtfunc.smoothing对我的二进制掩码进行变迹处理我遇到的问题是,如果我有100K的温度切割并且我制作了一个对应于切割的二元掩模,那么在使用上述例程进行掩模变迹后我在地图上应用它我得到120K或数量超过100K。所以我很困惑,那就是在二元模板上做变迹或者(map * Binary_mask)

def getMapValue(map, ra, dec, theta):


    nSide = hp.pixelfunc.npix2nside(map.size)
    # Extract the region around the source
    vec = hp.pixelfunc.ang2vec(np.pi / 2 - np.deg2rad(dec), np.deg2rad(ra))
    vec = np.array(vec)
    innerPixels = hp.query_disc(nSide, vec, radius=np.radians(theta))
    return innerPixels


def masking_map(map1, nside, npix, limit):

    mask = np.ones(hp.nside2npix(nside), dtype=np.float64)
    index = (map1 > limit) 
    mask[index] = 0.0


   for ipix in xrange(0, npix):
       theta1, phi = hp.pixelfunc.pix2ang(nside, ipix)
       if 70. < np.degrees(theta1) < 110.:
           mask[ipix] = 0.0

   inner_pix = getMapValue(map1,329.6, 17.5, 54.0)
   outer_pix = getMapValue(map1,329.6, 17.5, 62.0)
   index = np.setdiff1d(outer_pix, inner_pix)
   index1 = []
   for ipix1 in  index:
       theta, phi = hp.pixelfunc.pix2ang(nside, ipix1)
        if np.degrees(theta) < 90.0:
            if 0.0 < np.degrees(phi)< 60.0:
                index1.append(ipix1)
            if 320.0 < np.degrees(phi)< 360.0:
                index1.append(ipix1)

    index1=np.asarray(index1)
    mask[index1]=0.0

    return mask

def apodiz(mask, theta):
    apodiz_mask = hp.sphtfunc.smoothing(mask, fwhm=np.radians(theta),
                                    iter=3, use_weights=True,
                                    verbose=False)

    index = (apodiz_mask < 0.0)
    apodiz_mask[index] = 0.000
    return apodiz_mask


def main():

    filename = 'haslam408_dsds_Remazeilles2014.fits'
    NSIDE = 512
    input_map = loadMap(fname)
    NPIX = hp.pixelfunc.nside2npix(NSIDE)

    LIMIT = 50 # for 50K cut

    theta_ap = 5.0 # FWHM for Apodization in degrees

    Binary_mask = masking_map(input_map, NSIDE, NPIX, LIMIT)

    imp_map = apodiz(Binary_mask, theta_ap)

    masked_map = input_map*imp_map

    hp.mollview(apoMask, xsize=2000, coord=['G'], unit=r'$T_{B}(K)$', nest=False, title='%s' % key[count])
    hp.mollview(imp_map, xsize=2000, coord=['G'], unit=r'$T_{B}(K)$', nest=False, title='%s' % key[count])
    hp.mollview(masked_map, xsize=2000, coord=['G'], unit=r'$T_{B}(K)$', nest=False, title='408 MHz,%s' % key[count])
    hp.mollview(input_map*Binary_mask, xsize=2000, coord=['G'], unit=r'$T_{B}(K)$', nest=False, title='408 MHz,%s' % key[count])

    count+=1
if __name__ == "__main__":

This is resulting map without apodization of binar mask

This is resulting map after 5 degree apodized of Binary mask

0 个答案:

没有答案