title: Smoothing Mask using healpy
body: <p>I am using healpy.sphtfunc.smoothing for apodization of my binary mask and I am having problem that, if I have temperature cut of 100K and I made a binary mask corresponding to cut, then after apodization of mask using above routine when I apply it on my map I get 120K or number more than 100K.  So I am confuse that does one do apodization on Binary mask or (map*Binary_mask) </p>
  
  <pre><code>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 &gt; limit) 
      mask[index] = 0.0
  
  
     for ipix in xrange(0, npix):
         theta1, phi = hp.pixelfunc.pix2ang(nside, ipix)
         if 70. &lt; np.degrees(theta1) &lt; 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) &lt; 90.0:
              if 0.0 &lt; np.degrees(phi)&lt; 60.0:
                  index1.append(ipix1)
              if 320.0 &lt; np.degrees(phi)&lt; 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 &lt; 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__":
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xR4po.jpg" rel="nofollow noreferrer">This is resulting map without apodization of binar mask</a></p>
  
  <p><a href="https://i.stack.imgur.com/gcCa3.jpg" rel="nofollow noreferrer">This is resulting map after 5 degree apodized of Binary mask</a></p>