def get_correlation_function(self, k=None, pk=None, \ Sigma_nl=0., r=None, r0=1., inverse=0, update=0): if k is None or pk is None: k = self.k pk = self.pk #-- transform to log space for Hankel Transform klog = 10**N.linspace(N.log10(k.min()), N.log10(k.max()), k.size) pklog = N.interp(klog, k, pk) #-- apply isotropic damping pklog *= N.exp(-0.5 * klog**2 * Sigma_nl**2) rout, xiout = fftlog.HankelTransform(klog, pklog, q=1.5, mu=0.5, \ output_r_power=-3, output_r=r, r0=r0) norm = 1 / (2 * N.pi)**1.5 if inverse: xiout /= norm else: xiout *= norm if update: self.r = rout self.xi = xiout return rout, xiout
def get_correlation_function(self, k=None, pk=None, sigma_nl=0., r=None, r0=1., inverse=0): ''' This computes isotropic xi(r) from isotropic P(k) Currently not used by fitter but useful for tests ''' if k is None or pk is None: k = self.k pk = self.pk #-- transform to log space for Hankel Transform klog = 10**np.linspace( np.log10(k.min()), np.log10(k.max()), k.size) pklog = np.interp(klog, k, pk) #-- apply isotropic damping pklog *= np.exp(-0.5*klog**2*sigma_nl**2) rout, xiout = fftlog.HankelTransform(klog, pklog, q=1.5, mu=0.5, output_r_power=-3, output_r=r, r0=r0) norm = 1/(2*np.pi)**1.5 if inverse: xiout /= norm else: xiout *= norm return rout, xiout
def get_multipoles_from_pk(self, k, pk_mult, r0=1., r=None): xi_mult = pk_mult * 0 ell_max = xi_mult.shape[0] * 2 for ell in range(0, ell_max, 2): rout, xiout = fftlog.HankelTransform(k, pk_mult[ell/2], q=1.5, mu=0.5+ell, \ output_r_power=-3, output_r=r, r0=r0) norm = 1 / (2 * N.pi)**1.5 * (-1)**(ell / 2) xi_mult[ell / 2] = xiout * norm return rout, xi_mult
def get_xi_multipoles_from_pk(self, k, pk_mult, output_r=None, r0=1.): nell = len(pk_mult) xi_mult = [] for i in range(nell): pk = pk_mult[i] ell = i*2 r, xi = fftlog.HankelTransform(k, pk, mu=0.5+ell, output_r=output_r, output_r_power=-3, q=1.5, r0=r0) norm = 1/(2*np.pi)**1.5 * (-1)**(ell/2) xi_mult.append(xi*norm) xi_mult = np.array(xi_mult) return r, xi_mult
def get_pk_multipoles_from_xi(self, r, xi_mult, output_k=None, r0=1.): nell = len(xi_mult) pk_mult = [] for i in range(nell): xi = xi_mult[i] ell = i*2 k, pk = fftlog.HankelTransform(r, xi, mu=0.5+ell, output_r=output_k, output_r_power=-3, q=1.5, r0=r0) #norm = 1/(2*np.pi)**1.5 * (-1)**(ell/2) norm = 1/(2*np.pi)**1.5 * (-1)**(ell/2) * (2*np.pi)**3 pk_mult.append(pk*norm) pk_mult = np.array(pk_mult) return k, pk_mult
def get_xi_multipoles_from_pk(self, k, pk_mult, output_r=None, r0=1.): xi_mult = [] ell = 0 for pk in pk_mult: rout, xiout = fftlog.HankelTransform(k, pk, mu=0.5 + ell, output_r=output_r, output_r_power=-3, q=1.5, r0=r0) norm = 1 / (2 * np.pi)**1.5 * (-1)**(ell / 2) xi_mult.append(xiout * norm) ell += 2 return rout, np.array(xi_mult)