Exemplo n.º 1
0
def cutsky_pole_gausscov(pkmu, ells, cosmo, zbins, nbar_spline, P0, fsky, kmin=-np.inf, kmax=np.inf):
    """
    Compute the gaussian covariance for a set of cutsky multipole measurements,
    from the measured P(k,mu) simulation boxes
    
    Parameters
    ----------
    pkmu : nbodykit.PkmuResult
        the mean P(k,mu) periodic measurement, on the finely-binned grid
    ells : array_like, (Nell,)
        the desired multipole numbers
    cosmo : pygcl.Cosmology
        the cosmology instance used in the volume calculation
    zbins : array_like
        bins in redshift, used in the volume calculation
    nbar_spline : callable
        a function returning n(z)
    P0 : float
        the value of P0 used in the FKP weight
    fsky : float
        the fraction of the sky area covered
    kmin : {float, array_like}, optional
        minimum wavenumber to trim by (inclusively), in h/Mpc
    kmax : {float, array_like}, optional
        maximum wavenumber to trim by (inclusively), in h/Mpc
        
    Returns
    -------
    cov : (N, N)
        the covariance matrix for the multipole measurements
    coords : list
        list of the flat coordinates corresponding to the the cov

    """    
    # initialize the grid transfer
    data = pkmu.data.copy()
    grid = PkmuGrid.from_structured([pkmu.coords['k_cen'], pkmu.coords['mu_cen']], data)
    
    # return the Gaussian covariance components
    power = data['power'] - tools.get_Pshot(pkmu)    
    transfer = PolesTransfer(grid, ells, kmin=kmin, kmax=kmax, power=power)

    coords = transfer.coords_flat
    C = transfer.to_cutsky_covariance(cosmo, zbins, nbar_spline, P0, fsky)
    return C, coords
Exemplo n.º 2
0
def data_pole_gausscov(pkmu, ells, kmin=-np.inf, kmax=np.inf, components=False):
    """
    Compute the gaussian covariance for a set of multipole measurements,
    from the measured P(k,mu) observation
    
    Parameters
    ----------
    pkmu : nbodykit.PkmuResult
        the mean P(k,mu) measurement, on the finely-binned grid
    ells : array_like, (Nell,)
        the desired multipole numbers
    kmin : {float, array_like}, optional
        minimum wavenumber to trim by (inclusively), in h/Mpc
    kmax : {float, array_like}, optional
        maximum wavenumber to trim by (inclusively), in h/Mpc
    components : bool, optional
        If `True`, return only the ``mean_power`` and ``modes``
        
    Returns
    -------
    if components == False
        cov : (N, N)
            the covariance matrix for the multipole measurements
    else
        mean_power : (N, N), optional
            the mean power, cov = 2 * mean_power**2 / modes
        modes : (N, N), optional
            the number of modes
    """    
    # initialize the grid transfer
    data = pkmu.data.copy()
    grid = PkmuGrid.from_structured([pkmu.coords['k_cen'], pkmu.coords['mu_cen']], data)
    
    # return the Gaussian covariance components
    kw = {'ells':ells, 'kmin':kmin, 'kmax':kmax, 'power':data['power'], 'components':components}
    return _return_covariance('pole', grid, **kw)
Exemplo n.º 3
0
def data_pkmu_gausscov(pkmu, mu_bounds, kmin=-np.inf, kmax=np.inf, components=False):
    """
    Compute the gaussian covariance for a set of P(k,mu) measurements
    
    Parameters
    ----------
    pkmu : nbodykit.PkmuResult
        the mean P(k,mu) measurement, on the finely-binned grid
    mu_bounds : array_like
        a list of tuples specifying (lower, upper) for each desired
        mu bin, i.e., [(0., 0.2), (0.2, 0.4), (0.4, 0.6), (0.6, 0.8), (0.8, 1.0)]
    kmin : {float, array_like}, optional
        minimum wavenumber to trim by (inclusively), in h/Mpc
    kmax : {float, array_like}, optional
        maximum wavenumber to trim by (inclusively), in h/Mpc
    components : bool, optional
        If `True`, return only the ``mean_power`` and ``modes``
        
    Returns
    -------
    if components == False
        cov : (N, N)
            the covariance matrix for the multipole measurements
    else
        mean_power : (N, N), optional
            the mean power, cov = 2 * mean_power**2 / modes
        modes : (N, N), optional
            the number of modes
    """           
    # initialize the grid transfer
    data = pkmu.data.copy()
    grid = PkmuGrid.from_structured([pkmu.coords['k_cen'], pkmu.coords['mu_cen']], data)
    
    # return the Gaussian covariance components
    kw = {'mu_bounds':mu_bounds, 'kmin':kmin, 'kmax':kmax, 'power':data['power'], 'components':components}
    return _return_covariance('pkmu', grid, **kw)