Skip to main content

TabCorr: Tabulated Correlation Functions

PyPI Version License: MIT Language: Python

This Python module provides extremely efficient and precise calculations of galaxy correlation functions in halotools using tabulated values. It is specifically intended for Markov chain monte carlo (MCMC) exploration of the galaxy-halo connection. It implements the method described in Zheng & Guo (2016) of tabulating correlation functions that only need to be convolved with the mean halo occupation to obtain the full correlation function of galaxies.

Installation

The package can be installed via pip.

pip install tabcorr

Usage

The following code demonstrates the basic usage of TabCorr.

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from halotools.empirical_models import PrebuiltHodModelFactory
from halotools.mock_observables import wp
from halotools.sim_manager import CachedHaloCatalog
from tabcorr import TabCorr

# First, we tabulate the correlation functions in the halo catalog. Note that
# by default, TabCorr applies redshift-space distortions (RSDs) in the
# tabulation of correlation functions.
rp_bins = np.logspace(-1, 1, 20)

halocat = CachedHaloCatalog(simname='bolplanck')
halotab = TabCorr.tabulate(halocat, wp, rp_bins, pi_max=40, verbose=True,
                           num_threads=4)

# We can save the result for later use.
halotab.write('bolplanck_wp.hdf5')

# We could read it in like this. Thus, we can skip the previous steps in the
# future.
halotab = TabCorr.read('bolplanck_wp.hdf5')

# Now, we're ready to calculate correlation functions for a specific model.
model = PrebuiltHodModelFactory('zheng07', threshold=-18)

rp_ave = 0.5 * (rp_bins[1:] + rp_bins[:-1])

ngal, wp = halotab.predict(model)
plt.plot(rp_ave, wp, label='total')

ngal, wp = halotab.predict(model, separate_gal_type=True)
for key in wp.keys():
    plt.plot(rp_ave, wp[key], label=key, ls='--')

plt.xscale('log')
plt.yscale('log')
plt.xlabel(r'$r_{\rm p} \ [h^{-1} \ \mathrm{Mpc}]$')
plt.ylabel(r'$w_{\rm p} \ [h^{-1} \ \mathrm{Mpc}]$')
plt.legend(loc='lower left', frameon=False)
plt.tight_layout(pad=0.3)
plt.savefig('wp_decomposition.png', dpi=300)
plt.close()

# Studying how the clustering predictions change as a function of galaxy-halo
# parameters is straightforward.
sm = mpl.cm.ScalarMappable(
    cmap=mpl.cm.viridis, norm=mpl.colors.Normalize(vmin=12.0, vmax=12.8))

for logm1 in np.linspace(12.0, 12.8, 1000):
    model.param_dict['logM1'] = logm1
    ngal, wp = halotab.predict(model)
    plt.plot(rp_ave, wp, color=sm.to_rgba(logm1), lw=0.1)

cb = plt.colorbar(sm, ax=plt.gca())
cb.set_label(r'$\log M_1$')
plt.xscale('log')
plt.yscale('log')
plt.xlabel(r'$r_{\rm p} \ [h^{-1} \ \mathrm{Mpc}]$')
plt.ylabel(r'$w_{\rm p} \ [h^{-1} \ \mathrm{Mpc}]$')
plt.tight_layout(pad=0.3)
plt.savefig('wp_vs_logm1.png', dpi=300)
plt.close()

Author

Johannes Ulf Lange

Citations

The method implemented in TabCorr has first been described in earlier work, particularly Neistein et al. (2011) and Zheng & Guo (2016). In Lange et al. (2019a), we developed a generalized framework for this method that also takes into account assembly bias. Finally, a good reference for the TabCorr code itself is Lange et al. (2019b).

License

TabCorr is licensed under the MIT License.

Release files for tabcorr 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tabcorr 1.2.1
File Size Uploaded
tabcorr-1.2.1.tar.gz 26.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tabcorr 1.2.1
File Interpreter ABI Platform
tabcorr-1.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 53.4 kB

Release files / tabcorr-1.2.1.tar.gz

Download URL tabcorr-1.2.1.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
85a51bd306232873db4c657877c40b299d82c79e746f0a1f572b433a8c12bf7c
BLAKE2b-256 checksum
How to use checksums
9cfc5f894b90908617812444da9babe5322e76ca7f5c5cca87ada0f54ec99a52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release files / tabcorr-1.2.1-py2.py3-none-any.whl

Download URL tabcorr-1.2.1-py2.py3-none-any.whl
Size 27.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c59346306e84c53564724aa2ab0231eb0d94e3ea4ed6f2757b1a493e8f1a017d
BLAKE2b-256 checksum
How to use checksums
4905b38d1e6e605ebe8828b6f8f61f4dbdfc67207fcc740fee45529890393e85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page