Skip to main content

Using emulators to implement baryonic effects.

Project description

BCemu

A python package for modelling baryonic effects in cosmological simulations.

Package details

The package provides emulators to model the suppression in the power spectrum due to baryonic feedback processes. These emulators are based on the baryonification model [1], where gravity-only N-body simulation results are manipulated to include the impact of baryonic feedback processes. For detailed description, see Ref. [2].

INSTALLATION

One can install a stable version of this package using pip by running the following command::

pip install BCemu

In order to use the latest version, one can clone this package running the following::

git clone https://github.com/sambit-giri/BCemu.git

To install the package in the standard location, run the following in the root directory::

python setup.py install

In order to install it in a separate directory::

python setup.py install --home=directory

One can also install it using pip by running the following command::

pip install git+https://github.com/sambit-giri/BCemu.git

The dependencies should be installed automatically during the installation process. If they fail for some reason, you can install them manually before installing BCemu. The list of required packages can be found in the requirements.txt file present in the root directory.

Tests

For testing, one can use pytest or nosetests. Both packages can be installed using pip. To run all the test script, run the either of the following::

python -m pytest tests

nosetests -v

USAGE

Script to get the baryonic power suppression.

import numpy as np 
import matplotlib.pyplot as plt
import BCemu

bfcemu = BCemu.BCM_7param(Ob=0.05, Om=0.27)
bcmdict = {'log10Mc': 13.32,
           'mu'     : 0.93,
           'thej'   : 4.235,  
           'gamma'  : 2.25,
           'delta'  : 6.40,
           'eta'    : 0.15,
           'deta'   : 0.14,
           }

z = 0
k_eval = 10**np.linspace(-1,1.08,50)
p_eval = bfcemu.get_boost(z, bcmdict, k_eval)

plt.semilogx(k_eval, p_eval, c='C0', lw=3)
plt.axis([1e-1,12,0.73,1.04])
plt.yticks(fontsize=14)
plt.xticks(fontsize=14)
plt.xlabel(r'$k$ (h/Mpc)', fontsize=14)
plt.ylabel(r'$\frac{P_{\rm DM+baryon}}{P_{\rm DM}}$', fontsize=21)
plt.tight_layout()
plt.show()

The package also has a three parameter barynification model. Model A assumes all the three parameters to be independent of redshift while model B assumes the parameters to be redshift dependent via the following form:

.

Below an example fit to the BAHAMAS simulation result is shown.

import numpy as np 
import matplotlib.pyplot as plt
import BCemu
import pickle

BAH = pickle.load(open('examples/BAHAMAS_data.pkl', 'rb'))

bfcemu = BCemu.BCM_3param(Ob=0.0463, Om=0.2793)
bcmdict = {'log10Mc': 13.25, 
           'thej'   : 4.711,  
           'deta'   : 0.097}

zs = [0,0.5]
k_eval  = 10**np.linspace(-1,1.08,50)
p0_eval1 = bfcemu.get_boost(zs[0], bcmdict, k_eval)
p1_eval1 = bfcemu.get_boost(zs[1], bcmdict, k_eval)

bfcemu = BCemu.BCM_3param(Ob=0.0463, Om=0.2793)
bcmdict = {'log10Mc': 13.25, 
           'thej'   : 4.711,  
           'deta'   : 0.097,
           'nu_Mc'  : 0.038,
           'nu_thej': 0.0,
           'nu_deta': 0.060}

zs = [0,0.5]
k_eval  = 10**np.linspace(-1,1.08,50)
p0_eval2 = bfcemu.get_boost(zs[0], bcmdict, k_eval)
p1_eval2 = bfcemu.get_boost(zs[1], bcmdict, k_eval)

plt.figure(figsize=(10,4.5))
plt.subplot(121); plt.title('z=0')
plt.semilogx(BAH['z=0']['k'], BAH['z=0']['S'], '-', c='k', lw=5, alpha=0.2, label='BAHAMAS')
plt.semilogx(k_eval, p0_eval1, c='C0', lw=3, label='A', ls='--')
plt.semilogx(k_eval, p0_eval1, c='C2', lw=3, label='B', ls=':')
plt.axis([1e-1,12,0.73,1.04])
plt.yticks(fontsize=14)
plt.xticks(fontsize=14)
plt.legend()
plt.xlabel(r'$k$ (h/Mpc)', fontsize=14)
plt.ylabel(r'$\frac{P_{\rm DM+baryon}}{P_{\rm DM}}$', fontsize=21)
plt.subplot(122); plt.title('z=0.5')
plt.semilogx(BAH['z=0.5']['k'], BAH['z=0.5']['S'], '-', c='k', lw=5, alpha=0.2, label='BAHAMAS')
plt.semilogx(k_eval, p1_eval1, c='C0', lw=3, label='A', ls='--')
plt.semilogx(k_eval, p1_eval2, c='C2', lw=3, label='B', ls=':')
plt.axis([1e-1,12,0.73,1.04])
plt.yticks(fontsize=14)
plt.xticks(fontsize=14)
plt.xlabel(r'$k$ (h/Mpc)', fontsize=14)
plt.ylabel(r'$\frac{P_{\rm DM+baryon}}{P_{\rm DM}}$', fontsize=21)
plt.tight_layout()
plt.show()

CONTRIBUTING

If you find any bugs or unexpected behavior in the code, please feel free to open a Github issue. The issue page is also good if you seek help or have suggestions for us.

References

[1] Schneider, A., Teyssier, R., Stadel, J., Chisari, N. E., Le Brun, A. M., Amara, A., & Refregier, A. (2019). Quantifying baryon effects on the matter power spectrum and the weak lensing shear correlation. Journal of Cosmology and Astroparticle Physics, 2019(03), 020. arXiv:1810.08629.

[2] Giri, S. K. & Schneider, A. (2021). Emulation of baryonic effects on the matter power spectrum and constraints from galaxy cluster data. Journal of Cosmology and Astroparticle Physics, 2021(12), 046. arXiv:2108.08863.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BCemu-1.1.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

BCemu-1.1.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file BCemu-1.1.1.tar.gz.

File metadata

  • Download URL: BCemu-1.1.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for BCemu-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f408404e045b87fa8ceda34c3522c76b8688290b0c57b2f24a348709e2736a07
MD5 7a01605d625c958bf8a06f0333e3431f
BLAKE2b-256 47ad674b5671077be4a20b278a05ec28c05539fb2255e370a053efc90701cd68

See more details on using hashes here.

File details

Details for the file BCemu-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: BCemu-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for BCemu-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f97f9fe9d6ab5a7942f7b24d1291006523fe4c3b24170e8a514bc227874071d
MD5 b116b437e491ca51adb08e41e42ba4d6
BLAKE2b-256 66f197d71aa76c3e7ba50dc6181a8660a045aa19291b21121ca77f71594dd934

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page