def read_maps(nsimu, maps_dir, pol=True): """cut high multipoles of input map and degrade it to low resolution Parameters ---------- nsimu:integer mumber of samples qml_nside : integer nisde of low multipoles maps mapsA, mapsB: numpy.ndarray mapsA noise maps of chanel A mapsB noise maps of chanel B(optional) Returns ---------- maps: Return a degrade maps with Nside = qml_nside """ print() print("Read maps from %s"%maps_dir) maps=[] for n in np.arange(nsimu): progress_bar(n, nsimu) n1=n+1 if pol == True: map_in = hp.read_map(maps_dir+"%d.fits"%n1,field=(0,1,2),dtype=float,verbose=0) else: map_in = hp.read_map(maps_dir+"%d.fits"%n1,field=0,dtype=float,verbose=0) maps.append(map_in) maps=np.array(maps) return maps
def crosBP(self, mapsA, mapsB=()): """ Return the unbiased spectra Parameters ---------- map1 : 1D array Pixel map number 1 map2 : 2D array Pixel map number 2 Returns ---------- cl : array or sequence of arrays Returns cl or a list of cl's (TT, EE, BB, TE, EB, TB) # Should compute auto-spectra if map2 == None ? # Define conditions based on the map size """ allcl = [] nsimu=min(mapsA.shape[0],mapsB.shape[0]) if mapsB != () else mapsA.shape[0] if mapsB != (): for n in np.arange(nsimu): progress_bar(n, nsimu) mapA=mapsA[n] mapB=mapsB[n] allcl.append(self.estimator.get_spectra(mapA,mapB)) else: print("crosBP need another map.") hcl = np.mean(allcl, 0) return hcl
def autoBP(self, mapsA): """ Return the unbiased spectra Parameters ---------- map1 : 1D array Pixel map number 1 map2 : 2D array Pixel map number 2 Returns ---------- cl : array or sequence of arrays Returns cl or a list of cl's (TT, EE, BB, TE, EB, TB) # Should compute auto-spectra if map2 == None ? # Define conditions based on the map size """ allcl = [] nsimu = mapsA.shape[0] for n in np.arange(nsimu): progress_bar(n, nsimu) mapA=mapsA[n] allcl.append(self.estimator.get_spectra(mapA)) hcl = np.mean(allcl, 0) return hcl
def degrade_maps(nsimu, nside, qml_nside, maps_dir, pol, qml_mask=None): """cut high multipoles of input map and degrade it to low resolution Parameters ---------- nsimu:integer mumber of samples qml_nside : integer nisde of low multipoles maps mapsA, mapsB: numpy.ndarray mapsA noise maps of chanel A mapsB noise maps of chanel B(optional) Returns ---------- maps: Return a degrade maps with Nside = qml_nside """ print() print("degrade maps to Nside = %d"%qml_nside) ALM = hp.Alm maps=[] for n in np.arange(nsimu): progress_bar(n, nsimu) n1=n+1 #map_out = hp.read_map(maps_dir+"%d.fits"%n1,field=(0,1,2),dtype=float,verbose=0) map_in = hp.read_map(maps_dir+"%d.fits"%n1,field=(0,1,2),dtype=np.float64,verbose=0) Slmax_old=3*nside Slmax_new=3*qml_nside alm_old=hp.map2alm(map_in,lmax=Slmax_old,pol=pol,use_weights=True,iter=3) alm_new=np.zeros_like(np.array(alm_old)[:,:ALM.getsize(Slmax_new)]) for l in np.arange(Slmax_new+1) : for m in np.arange(l+1) : idx_new = ALM.getidx(Slmax_new, l, m) idx_old = ALM.getidx(Slmax_old, l, m) if l<=qml_nside: alm_new[:,idx_new]=alm_old[:,idx_old] elif l<=Slmax_new: alm_new[:,idx_new]=alm_old[:,idx_old]*0.5*(1+np.sin(l*np.pi/2/qml_nside)) map_out = hp.alm2map(alm_new, nside= qml_nside, pixwin=False) if qml_mask != (): npix= hp.nside2npix(qml_nside) if npix == len(qml_mask): map_out = map_out*qml_mask else: print("The nside of qml_mask inconsistent with qml_nside.") # hp.write_map(output_dir+"/map_out_%d.fits"%n1,map_out,dtype=np.float64) # hp.mollview(map_out[1], cmap=plt.cm.jet, title='Q map output') # plt.savefig(output_dir+'/map_out_%d.eps'%n1,bbox_inches='tight',pad_inches=0.1) maps.append(map_out) maps=np.array(maps) return maps