Exemple #1
0
def plotWpRp(ipos, ppos, outbase, zmax=40., h=0.7, Lb=400, rmin=0.1, rmax=2, rstep=0.1, ax = None ):
    """
    Make a comparison plot between the input projected correlation function
    and the predicted projected correlation function
    """
    Lb = Lb / h
    nrbins = ( rmax - rmin ) / rstep
    rbins = np.logspace( rmin, rmax, nrbins )
    rcen = ( rbins[:-1] + rbins[1:] ) / 2

    iwprp, icov = projected_correlation( ipos, rbins, zmax, Lb, jackknife_nside=3 )
    pwprp, pcov = projected_correlation( ppos, rbins, zmax, Lb, jackknife_nside=3 )
    iwpe = np.sqrt( np.diagonal( icov ) )
    pwpe = np.sqrt( np.diagonal( pcov ) )

    if ax == None:
        f, ax = plt.subplots(1)
    
    ax.set_yscale( 'log', nonposy = 'clip' )
    ax.set_xscale( 'log', nonposx = 'clip' )
    ax.set_ylabel( r'$w_{p}(r_{p})$', fontsize=20 )
    ax.set_xlabel( r'$r_{p} [Mpc\cdot h^{-1}]$', fontsize=20 )

    ax.errorbar( rcen, iwprp, yerr = iwpe, label='Original Halos' )
    ax.errorbar( rcen, pwprp, yerr = pwpe, label='Added Halos' )

    plt.legend()
    #plt.tight_layout()
    plt.savefig( outbase+'_wprp.png' )
    
    wdtype = np.dtype( [ ('r', float), ('iwprp', float), ('pwprp', float), 
                         ('iwprpe', float), ('pwprpe', float ) ] )
    wprp = np.ndarray( len( rcen ), dtype = wdtype )
    wprp[ 'r' ] = rcen
    wprp[ 'iwprp' ] = iwprp
    wprp[ 'pwprp' ] = pwprp
    wprp[ 'iwprpe' ] = iwpe
    wprp[ 'pwprpe' ] = pwpe

    fitsio.write(outbase+'_wprp.fit', wprp)

    return f, ax
Exemple #2
0
def calculate_xi(cat):
    """
    Given a catalog of galaxies, compute the correlation function using
    approriate helper functions from CorrelationFunction.py
    """
    rbins = np.logspace(np.log10(rpmin), np.log10(rpmax), Nrp+1)
    pos = np.zeros((len(cat), 3), order='C')
    pos[:, 0] = cat['x']/h
    pos[:, 1] = cat['y']/h
    pos[:, 2] = cat['z']/h + cat['vz']/h/100.0
    xi, cov = projected_correlation(pos, rbins, zmax, L, jackknife_nside=3)
    return xi, cov
Exemple #3
0
def calculate_xi(gals, box_size, projected=True, jack_nside=3, rpmin=0.1,
                 rpmax=20, Nrp=25):
    """
    Given a catalog of galaxies, compute the correlation function using
    approriate helper functions from CorrelationFunction.py
    """
    rbins = np.logspace(np.log10(rpmin), np.log10(rpmax), Nrp+1)
    pos = np.zeros((len(gals), 3), order='C')
    if projected:
        coords = ['x', 'y', 'zp']
    else:
        coords = ['x', 'y', 'z']
    for i, coord in enumerate(coords):
        pos[:, i] = gals[coord]/h
    return projected_correlation(pos, rbins, zmax, box_size/h,
                                 jackknife_nside=jack_nside)