Skip to main content

code for fast simulations of galaxy clusters

Project description

DeepSZSim

Code for producing fast simulations of the SZ effect for galaxy halos of varying redshift and mass, based on average thermal pressure profile fits from Battaglia et al. 2012. Simulated submaps can include tSZ signal from these halos, simulated CMB, instrument beam convolution and white noise.

Code Overview

The code is structured as depicted here: DeepSZSim workflow The CMB simulations are handled by DeepCMBSim, based on CAMB (info), and further by pixell. The SZ cluster simluations are done in make_sz_cluster.py and instrumental effects are added in filters.py and noise.py.

Documentation is available via readthedocs.

Quickstart

Installation

From pypi

The simplest way to install deepszsim is via PyPI, using

pip install deepszsim

The project history and source files are available on PyPI here.

From Source

We provide an environment specification file for conda or mamba users at environment.yml, which will produce a new virtual environment called szsims with appropriate versions of major python packages, after which you can install with pip. With conda, the workflow to create the environment, activate it, and install the package is

conda env create -f environment.yml
conda activate szsims
pip install .

(With micromamba the env is omitted and a new environment is instead created with micromamba create -f environment.yml)

The simulated CMB signal relies on camb and pixell, cosmology relies on colossus (info), and utilities for saving rely on h5py. These are specified in the pyproject.toml file.

Usage

The usage of this code is documented in docs/source//demo_simulation.ipynb. A detailed walkthrough of the functions available in this code is in docs/source//demo_full_pipeline.ipynb.

A full list of potential inputs is documented in settings/config.yaml and you can edit settings/inputdata.yaml to reflect your desired simulation settings.

dm_halo_dist.py generates an array of mass and redshift. The functions in make_sz_cluster.py create pressure profiles, Compton-y, and SZ signal maps for a halo of a given mass and redshift, and produces the final simulated submaps. These submaps contain simulated CMB and simple instrument beam convolution from simtools.py and white noise from noise.py. Plotting tools are provided in visualization.py. Simulations of a large suite of clusters can be achieved easily with simclusters.py.

Tests

Tests are provided in the tests directory. Github actions runs a test to make sure key scientific libraries can be installed (workflows). Users can verify tests and coverage locally with python -m pytest tests/*. The tests verify the following functionalities: map and math tools (beam convolution, compton-y map creation, angular diameter distance calculation) and SZ functions (cosmology parameter generation, pressure profile and parameter generation, pressure profile conversion).

Example

Let's say you wanted to produce 100 mock halos distributed across the redshift range 0.2<z<0.4 and with masses in the range 1e14<M200<1e15. To generate these halos and produce their simulated maps with SZ signal (along with CMB signal and noise parameters as specified in Settings/inputdata.yaml) you would call

import deepszsim as dsz
tc0 = dsz.simulate_clusters(halo_params_dict={
                            'zmin':0.2, 'zmax':0.5,
                            'm200min_SM':1e14, 'm200max_SM':1e15
                            },
                            num_halos=100)
tc0.get_T_maps()

The clusters and their maps are now in a dictionary which is in a clusters attribute of the class instance tc0.

To access the clusters in this set, you can refer to the cluster ID, which itself is obtained from the first five digits of the cluster mass and two digits of the cluster redshift, followed by six random digits. For example, to access a dictionary of the maps and the parameters describing the eleventh cluster, you would do tc0.clusters[tc0.id_list[11]]. Alternately, to get the ''final'' temperature map (with noise) for the eleventh cluster, we also provide a convenience function: tc0.ith_T_map(11) is the same as tc0.clusters[tc0.id_list[11]]['maps']['final_map'].

For further examples, see the notebooks [1] [2]. To run these locally, you will need to install as described in the Installation section, and then do

python -m ipykernel install --user --name szsims --display-name "deepszsim"
cd docs/source/notebooks
Jupyter notebook

Citation

If you use this code in your research, please cite this GitHub repo and our JOSS paper. Please also make use of the citation instructions for camb provided here.

Contributing

If you would like to contribute, you find a bug, or you have a feature request, please open a new issue, and/or be in touch with the authors.

Contact

The code was developed by Eve M. Vavagiakis, Samuel D. McDermott, Humna Awan, Elaine Ran, Kush Banker, Samantha Usman, Camille Avestruz, and Brian Nord. This was done in collaboration with Hanzhi Tan, Brian Zhang, and Ioana Cristescu, and the code is maintained by the DeepSkies lab

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

deepszsim-0.1.2.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepszsim-0.1.2-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file deepszsim-0.1.2.tar.gz.

File metadata

  • Download URL: deepszsim-0.1.2.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for deepszsim-0.1.2.tar.gz
Algorithm Hash digest
SHA256 788180835cee38ef71de96e5d8618f6006063bb272a6f496ff0565f1fb4f6b63
MD5 061d9e481989bebd026ac80faacf51e9
BLAKE2b-256 ea1905131f87b0465bef882641c7750aa5ab6600de826dbdf37cb9c619ee0a73

See more details on using hashes here.

File details

Details for the file deepszsim-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: deepszsim-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for deepszsim-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f58102efad8ec25155ee4240a6d46bd3cd0235a8baa3fd41781523c64876a1c8
MD5 94a04f8043e53705dbcfc267b7711c47
BLAKE2b-256 2b8ba2b638f7fd54b756d72104cf512ee2221e87276d8868a8604391b9731dcb

See more details on using hashes here.

Supported by

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