Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joss #233

Merged
merged 37 commits into from
Jul 17, 2024
Merged

Joss #233

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
71f548d
updated demo_full_pipeline to reflect code changes
elaine-ran Apr 16, 2024
cc564ca
Update run_tests.yml
samueldmcdermott May 22, 2024
145ed0a
added main text of paperp
bnord Jun 23, 2024
c36b876
added references to bib file
bnord Jun 23, 2024
28fc3b7
added sz workflow diagram
bnord Jun 23, 2024
8c707d9
Update paper.md
bnord Jun 23, 2024
64fb64f
added workflow diagram to paper
bnord Jun 23, 2024
01cf06c
added sz and cmb image examples
bnord Jun 23, 2024
401b052
added and linked example science images
bnord Jun 23, 2024
92ce47d
Update figures
bnord Jun 23, 2024
051b8ea
upload png of cmb spectra
bnord Jun 23, 2024
f69633a
made all the figures work
bnord Jun 23, 2024
4ceacf6
added auth info and updated acknowledg
bnord Jul 2, 2024
ec8526d
updated auth affil and orcid;
bnord Jul 2, 2024
696f620
fixed indentation error
bnord Jul 2, 2024
4bfbda0
updated affil
bnord Jul 2, 2024
8b9affc
Update run_tests.yml
samueldmcdermott Jul 3, 2024
f1ed271
Update run_tests.yml
samueldmcdermott Jul 3, 2024
3e1c64d
Update run_tests.yml
samueldmcdermott Jul 3, 2024
b9f4007
Update run_tests.yml
samueldmcdermott Jul 3, 2024
8377720
Update run_tests.yml
samueldmcdermott Jul 3, 2024
0142a01
Update run_tests.yml
samueldmcdermott Jul 3, 2024
55bfc4b
Update run_tests.yml
samueldmcdermott Jul 3, 2024
ef3f93e
Update run_tests.yml
samueldmcdermott Jul 3, 2024
c58f267
Update run_tests.yml
samueldmcdermott Jul 3, 2024
c32957b
Update run_tests.yml
samueldmcdermott Jul 3, 2024
ca92245
Update run_tests.yml
samueldmcdermott Jul 3, 2024
2418041
Update pyproject.toml
samueldmcdermott Jul 3, 2024
1f14a73
rearranged text; updated affils
bnord Jul 4, 2024
eb30777
Update and rename paper.yml to draft-pdf.yml
bnord Jul 4, 2024
0f7b71b
updatd paths for paper workflow
bnord Jul 8, 2024
900ac11
added a usage example in `README.md`
samueldmcdermott Jul 16, 2024
37bfce5
added workflow description
samueldmcdermott Jul 16, 2024
98bba18
corrected path to figure in workflow description
samueldmcdermott Jul 16, 2024
717f913
Delete paper/figures/DeepSZSim_Workflow.png
bnord Jul 17, 2024
f433387
Uploaded correct version of workflow
bnord Jul 17, 2024
ee61d2c
Merge branch 'dev' into joss
samueldmcdermott Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/paper.yml → .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
on: [push]
name: Draft PDF
on:
push:
paths:
- paper/**
- .github/workflows/draft-pdf.yml

jobs:
paper:
runs-on: ubuntu-latest
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: paper/paper.md
- name: Upload
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v3
with:
name: paper
# This is the output path where Pandoc will write the compiled
# PDF. Note, this should be the same directory as the input
# paper.md
path: paper/paper.pdf
path: paper/paper.pdf
21 changes: 13 additions & 8 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ jobs:
max-parallel: 5

steps:
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
- run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- run: python -m pip install --upgrade pip setuptools wheel
- run: python -m pip install .
- run: |
activate-environment: base-test
- name: Install dependencies
run: |
# conda env update --file=../environment.yml --name=base-test
python -m pip install colossus pixell camb
python -m pip install .
- name: Test with pytest
run: |
conda install pytest
pytest
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,45 @@

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](https://ui.adsabs.harvard.edu/abs/2012ApJ...758...75B/abstract). Simulated submaps can include tSZ signal from these halos, simulated CMB, instrument beam convolution and white noise.

## Installation
## Code Overview

The code is structured as depicted here: ![DeepSZSim workflow](paper/figures/DeepSZSim_Workflow.png)
The CMB simulations are handled by [DeepCMBSim](https://www.github.com/deepskies/deepcmbsim), based on [CAMB](https://camb.info), and further by [pixell](https://github.com/simonsobs/pixell). The SZ cluster simluations are done in `make_sz_cluster.py` and instrumental effects are added in `filters.py` and `noise.py`.

## Quickstart

### Installation

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. With `conda`, this environment is created by `conda env create -f environment.yml`. 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`, and utilities for saving rely on `h5py`. These are specified in the `pyproject.toml` file.

From the top-level directory, you can do `pip install .` to install the package.

## Usage
### Usage

The usage of this code is documented in `notebooks/demo_simulation.ipynb`. A detailed walkthrough of the functions available in this code is in `notebooks/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`.

### 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
```commandline
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']`.

## 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](https://camb.info).
Expand Down
Binary file added deepszsim/.DS_Store
Binary file not shown.
229 changes: 132 additions & 97 deletions notebooks/demo_full_pipeline.ipynb

Large diffs are not rendered by default.

Binary file added notebooks/massdist.h5
Binary file not shown.
Binary file added notebooks/sz_sim_data.h5
Binary file not shown.
Binary file added paper/figures/CMBSpectra_Examples.pdf
Binary file not shown.
Binary file added paper/figures/CMBSpectra_Examples.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added paper/figures/DeepSZSim_Workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added paper/figures/SZCluster_Examples.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading