for ipix in xrange(0, npix): Bis += Esti_Map[i, ipix] * Esti_Map[ j, ipix] * Esti_Map[k, ipix] #*Binary_Mask[ipix] # All sky correction Bis /= (4.0 * np.pi * npix) #np.sum(Binary_Mask)) # Counting triplets in given bin tripCount = count_triplet(i1, i3) Bis /= (1.0 * tripCount) # Angle avg Bispectrum Assumes statistical isotropy in angle like in CMB angAvg_bis = Bis / alpha # Normalized bispectrum Given in Komatsu et. al.1998 COBE DMR norm_bis = abs(angAvg_bis) / (Cl[i1] * Cl[i2] * Cl[i3])**0.5 # Variance in Bispectrum still not sure about this calcualtion varb = g(i1, i2, i3) * ( ((2 * i1 + 1) * (2 * i2 + 1) * (2 * i3 + 1)) / (4. * np.pi)) * wigner**2 * Cl[i1] * Cl[i2] * Cl[i3] varb /= (1.0 * tripCount**2.0) f.write( "%0.6e\t%0.6e\t%0.6e\t%0.6e\t%0.6e\t%0.6e\t%0.6e\t%d\t%d\t%d\t%d\n" % (Bis, angAvg_bis, norm_bis, varb, Cl[i1], Cl[i2], Cl[i3], i1, i2, i3, tripCount)) wig.wig_temp_free() wig.wig_table_free()
class binned_bispectrum: map_making.nside_f_est = 512 map_making.masking = 'No' map_making.apodization = 'No' wig.wig_table_init(1000) wig.wig_temp_init(1000) # binned map equation(6) casaponsa et. al. def __init__(self, Inp_alm_l, Inp_alm_nl, inp_bin, inp_fNL, NSIDE=1024, LMAX=2500): self.Inp_alm_l = Inp_alm_l self.Inp_alm_nl = Inp_alm_nl self.inp_bin = inp_bin self.Nbins = len(inp_bin) self.LMAX = LMAX self.FNL = inp_fNL self.NSIDE = NSIDE test1 = map_making(self.NSIDE) self.esti_map, self.ap_ma, self.binL = test1.binned_map( self.Nbins, self.LMAX, self.inp_bin, self.FNL, self.Inp_alm_l, self.Inp_alm_nl, beam=None, map_type='Non gaussian', beam_corr=None) self.nbin = len(inp_bin) self.npix = hp.nside2npix(self.NSIDE) self.bis = list() self.I = list() self.J = list() self.K = list() self.trip_count = list() def bispectrum(self): """ :rtype: object :return: """ for i in xrange(0, self.nbin - 1): for j in xrange(i, self.nbin - 1): for k in xrange(j, self.nbin - 1): if np.min(self.binL[k]) - np.max(self.binL[j]) <= np.max(self.binL[i]) <= np.max(self.binL[k]) \ + np.max(self.binL[j]): temp = summation(self.esti_map[i, :], self.esti_map[j, :], self.esti_map[k, :], self.ap_ma, self.npix) self.trip_count.append( count_triplet(np.min(self.binL[k]), np.max(self.binL[i]))) self.bis.append(temp) self.I.append(i) self.J.append(j) self.K.append(k) self.bis = np.asarray(self.bis) self.I = np.asarray(self.I) self.J = np.asarray(self.J) self.K = np.asarray(self.K) self.trip_count = np.asarray(self.trip_count) return self.bis, self.I, self.J, self.K, self.trip_count wig.wig_temp_free() wig.wig_table_free()