Commit 1f075b6a by Maude Le Jeune

`debug bin weighting`
parent 4ff18c12
 ... ... @@ -53,7 +53,7 @@ def get_binMatrix(bins, btype='flat', lmax=None): return Mbins def bin_covariance(covmat, bins, nmode=None): def bin_covariance(covmat, bins): """ Perform the averaging of spectral covariance matrices over flat bins. Matrices are weighted by their number of modes ie 2.ell+1. ... ... @@ -69,27 +69,24 @@ def bin_covariance(covmat, bins, nmode=None): nbin = bins.shape[0] ndet = covmat.shape[0] bincov = np.zeros((ndet, ndet, nbin)) lsize = np.zeros((nbin)) if bins.shape[1]==2: for q in range(nbin): lmin = bins[q,0] lmax = bins[q,1] rg = np.arange(lmin,lmax+1).astype(int32) nmodes = 2*rg+1 if nmode is None else nmode[rg] nmodes = 2*rg+1 tmpcov = covmat[:,:,rg].reshape(ndet*ndet, len(rg)) tmpcov = tmpcov*(np.ones((ndet*ndet,1))*nmodes) tmpcov = np.sum(tmpcov, axis=1).reshape(ndet, ndet) ll = np.sum(nmodes,axis=0) bincov[:,:,q] = tmpcov*(1.0/(1.0*ll)) lsize[q] = ll return [bincov,lsize] else: # use binning matrix for q in range(nbin): tmpcov = covmat.reshape(ndet*ndet, -1) tmpcov = tmpcov*(np.ones((ndet*ndet,1))*bins[q,:]) tmpcov = np.sum(tmpcov, axis=1).reshape(ndet, ndet) bincov[:,:,q] = tmpcov return bincov return bincov def uniformbin(lstart, lstop, deltal): """ Return description of flat bins of constant length. ... ...