code: def get_source_kernel(gta, name, kernel=None):
      
  
      sm = []
      zs = 0
      for c in gta.components:
          z = c.model_counts_map(name).data.astype('float')
          if kernel is not None:
              shape = (z.shape[0],) + kernel.shape
              z = np.apply_over_axes(np.sum, z, axes=[1, 2]) * np.ones(
                  shape) * kernel[np.newaxis, :, :]
              zs += np.sum(z)
          else:
              zs += np.sum(z)
  
          sm.append(z)
  
      sm2 = 0
      for i, m in enumerate(sm):
          sm[i] /= zs
          sm2 += np.sum(sm[i] ** 2)
  
      for i, m in enumerate(sm):
          sm[i] /= sm2
  
      return sm
docs: Get the PDF for the given source.