def get_maps_cl(frec, fconv=None, lmin=20, delta_ell=40, apodization_degrees=5.): mrec, resid, seenmap = get_maps_residuals(frec, fconv=fconv) sh = np.shape(mrec) print(sh, np.shape(resid)) nbsub = sh[1] ns = hp.npix2nside(sh[2]) from qubic import apodize_mask mymask = apodize_mask(seenmap, apodization_degrees) # Create XPol object from qubic import Xpol lmax = 2 * ns xpol = Xpol(mymask, lmin, lmax, delta_ell) ell_binned = xpol.ell_binned nbins = len(ell_binned) # Pixel window function pw = hp.pixwin(ns) pwb = xpol.bin_spectra(pw[:lmax + 1]) # Calculate all crosses and auto m_autos = np.zeros((nbsub, 6, nbins)) s_autos = np.zeros((nbsub, 6, nbins)) m_cross = np.zeros((nbsub, 6, nbins)) s_cross = np.zeros((nbsub, 6, nbins)) fact = ell_binned * (ell_binned + 1) / 2. / np.pi for isub in range(nbsub): m_autos[isub, :, :], s_autos[isub, :, :], m_cross[isub, :, :], s_cross[isub, :, :] = \ allcross_par(xpol, mrec[:, isub, :, :], silent=False, verbose=0) return mrec, resid, seenmap, ell_binned, m_autos * fact / pwb ** 2, \ s_autos * fact / pwb ** 2, m_cross * fact / pwb ** 2, s_cross * fact / pwb ** 2
def get_xpol(seenmap, ns, lmin=20, delta_ell=20, apodization_degrees=5.): """ Returns a Xpoll object to get spectra, the bin used and the pixel window function. """ # Create a mask mymask = apodize_mask(seenmap, apodization_degrees) # Create XPol object lmax = 2 * ns xpol = Xpol(mymask, lmin, lmax, delta_ell) ell_binned = xpol.ell_binned # Pixel window function pw = hp.pixwin(ns) pwb = xpol.bin_spectra(pw[:lmax + 1]) return xpol, ell_binned, pwb
# mean_rms_cov = np.sqrt(np.mean(rmsmap_cov**2, axis=2)) # plt.plot(nsubvals, np.sqrt(nsubvals), 'k', label='Optimal $\sqrt{N}$', lw=2) # for i in xrange(3): # plt.plot(nsubvals, mean_rms_cov[:,i] / mean_rms_cov[0,i] * np.sqrt(nsubvals), label=stokes[i], lw=2, ls='--') # plt.xlabel('Number of sub-frequencies') # plt.ylabel('Relative maps RMS') # plt.legend() #======================= Apply Xpoll to get spectra ============================ lmin = 20 lmax = 2 * ns delta_ell = 20 #Xpoll needs a mask mymask = apodize_mask(seenmap_conv, 5) xpol = Xpol(mymask, lmin, lmax, delta_ell) ell_binned = xpol.ell_binned nbins = len(ell_binned) print('nbins = {}'.format(nbins)) mcls, mcls_in = [], [] scls, scls_in = [], [] #Input : what we should find mapsconv = np.zeros((12 * ns**2, 3)) #Output, what we find maps_recon = np.zeros((12 * ns**2, 3)) for isub in xrange(len(nsubvals)):
# compute apodization mask nside = 256 lmin = 20 lmax = 2*nside-1 delta_ell = 20 racenter = 0.0 deccenter = -57.0 maxang = 20. center = equ2gal(racenter, deccenter) veccenter = hp.ang2vec(pi/2-np.radians(center[1]), np.radians(center[0])) vecpix = hp.pix2vec(nside, np.arange(12*nside**2)) cosang = np.dot(veccenter, vecpix) maskok = np.degrees(np.arccos(cosang)) < maxang maskmap = apodize_mask(maskok, 5) hp.gnomview(maskmap, rot=[racenter, deccenter], coord=['G', 'C'], reso=15) # Xpol estimation through MC np.random.seed(0) xpol = Xpol(maskmap, lmin, lmax, delta_ell) ell_binned = xpol.ell_binned spectra_binned = xpol.bin_spectra(spectra) nbins = len(ell_binned) nbmc = 100 allclsout = np.zeros((nbmc, 6, nbins)) allcls = np.zeros((nbmc, 6, lmax+1)) bar = progress_bar(nbmc) for i in np.arange(nbmc):
# compute apodization mask nside = 256 lmin = 20 lmax = 2 * nside - 1 delta_ell = 20 racenter = 0.0 deccenter = -57.0 maxang = 20. center = equ2gal(racenter, deccenter) veccenter = hp.ang2vec(pi / 2 - np.radians(center[1]), np.radians(center[0])) vecpix = hp.pix2vec(nside, np.arange(12 * nside**2)) cosang = np.dot(veccenter, vecpix) maskok = np.degrees(np.arccos(cosang)) < maxang maskmap = apodize_mask(maskok, 5) hp.gnomview(maskmap, rot=[racenter, deccenter], coord=['G', 'C'], reso=15) # Xpol estimation through MC np.random.seed(0) xpol = Xpol(maskmap, lmin, lmax, delta_ell) ell_binned = xpol.ell_binned spectra_binned = xpol.bin_spectra(spectra) nbins = len(ell_binned) nbmc = 100 allclsout = np.zeros((nbmc, 6, nbins)) allcls = np.zeros((nbmc, 6, lmax + 1)) bar = progress_bar(nbmc) for i in np.arange(nbmc): maps = hp.synfast(spectra,