Ejemplo n.º 1
0
def hankel_spline_lognormal_cl(ells, cl, plot=False, ell_min=90, ell_max=1e5):

    ft = SymmetricFourierTransform(ndim=2, N=200, h=0.03)
    # transform to angular correlation function with inverse hankel transform and spline interpolated C_ell
    spline_cl = interpolate.InterpolatedUnivariateSpline(
        np.log10(ells), np.log10(cl))
    f = lambda ell: 10**(spline_cl(np.log10(ell)))
    thetas = np.pi / ells
    w_theta = ft.transform(f, thetas, ret_err=False, inverse=True)
    # compute lognormal angular correlation function
    w_theta_g = np.log(1. + w_theta)
    # convert back to multipole space
    spline_w_theta_g = interpolate.InterpolatedUnivariateSpline(
        np.log10(np.flip(thetas, 0)), np.flip(w_theta_g, 0))
    g = lambda theta: spline_w_theta_g(np.log10(theta))
    cl_g = ft.transform(g, ells, ret_err=False)
    spline_cl_g = interpolate.InterpolatedUnivariateSpline(
        np.log10(ells), np.log10(np.abs(cl_g)))

    # plotting is just for validation if ever unsure
    if plot:
        plt.figure()
        plt.loglog(ells, cl, label='$C_{\\ell}$', marker='.')
        plt.loglog(ells, cl_g, label='$C_{\\ell}^G$', marker='.')
        plt.loglog(np.linspace(ell_min, ell_max, 1000),
                   10**spline_cl_g(
                       np.log10(np.linspace(ell_min, ell_max, 1000))),
                   label='spline of $C_{\\ell}^G$')
        plt.legend(fontsize=14)
        plt.xlabel('$\\ell$', fontsize=16)
        plt.title('Angular power spectra', fontsize=16)
        plt.show()

    return cl_g, spline_cl_g
Ejemplo n.º 2
0
    def _realspace_power(self, nu1, nu2):
        r = np.logspace(-3, 3, 1000)

        ht1 = SymmetricFourierTransform(ndim=2,
                                        N=1000,
                                        h=0.003,
                                        a=0,
                                        b=2 * np.pi)
        gres = ht1.transform(
            lambda u: np.sqrt(self.point_source_power_spec(2 * np.pi * u)) * np
            .sqrt(self.point_source_power_spec(2 * np.pi * u)),
            k=r,
            inverse=True,
            ret_err=False)
        # *nu1*nu2
        xir = spline(np.log(r), np.log(gres))
        return lambda r: np.exp(xir(np.log(r)))