Skip to content

Commit

Permalink
new readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetanfacchinetti committed Feb 2, 2024
1 parent c35cfc2 commit 6a25a1a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 23 deletions.
45 changes: 30 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,48 @@
# 21cmCAST

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/py21cmcast)](https://pypi.org/project/py21cmcast/)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Build Status](https://github.com/gaetanfacchinetti/21cmCAST/actions/workflows/python-package.yml/badge.svg?branch=main)](https://github.com/gaetanfacchinetti/21cmCAST/actions/workflows/CI.yml?query=branch%3Amain)

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/py21cmcast)](https://pypi.org/project/py21cmcast/)
[![PyPi Version](https://img.shields.io/pypi/v/py21cmcast.svg)](https://pypi.python.org/pypi/py21cmcast/)
[![License: GPL v3](https://img.shields.io/badge/license-GPLv3-green.svg)](https://www.gnu.org/licenses/gpl-3.0)

[![Static Badge](https://img.shields.io/badge/physics-cosmology-darkblue)](https://en.wikipedia.org/wiki/Cosmology)
[![Static Badge](https://img.shields.io/badge/physics-21cm-yellow)](https://en.wikipedia.org/wiki/Hydrogen_line)
[![Static Badge](https://img.shields.io/badge/stats-fisher-green)](https://en.wikipedia.org/wiki/Fisher_information)



This package provides tools to perform Fisher fore**CAST**s from 21cmFAST outputs. It has been built on / complementarily to the [21cmFish](https://21cmfish.readthedocs.io/en/latest/) package[^1]. A detailed example of how it works can be found in [**scripts/exec/fisher.ipynb**](./scripts/exec/fisher.ipynb).
This lightweight package provides tools to perform automated analysis of [21cmFAST](https://21cmfast.readthedocs.io/en/latest/)[^1][^2] outputs and in particular run Fisher fore**CAST**s. It has initially been built on / complementarily to the [21cmFish](https://21cmfish.readthedocs.io/en/latest/) package[^3].

In order to work properly, the codes requires to have a working installation of
- [**21cmFAST**](https://21cmfast.readthedocs.io/en/latest/)[^2][^3]
- [**21cmSense**](https://21cmsense.readthedocs.io/en/latest/)[^4]
---
⚠️ **If you are using this code**, please cite the following work for which it has been developped
> *Gaétan Facchinetti, Laura Lopez-Honorez, Yuxiang Qin, Andrei Mesinger*, 21cm signal sensitivity to dark matter decay [[JCAP 01 (2024) 005]](https://iopscience.iop.org/article/10.1088/1475-7516/2024/01/005) [[arXiv:2308.16656]](https://arxiv.org/abs/2308.16656)
If you are considering using this code, please cite the following work for which it has been developped
- *G. Facchinetti, L. Lopez-Honorez, Y. Qin, A. Mesinger*, 21cm signal sensitivity to dark matter decay [[arXiv:2308.16656]](https://arxiv.org/abs/2308.16656)
</br>

<p align="center">
<img src="illustration.png" width="430" height="450" />
</p>


## Installation

In order to install the code you can install it with pip running
In order to install the code you can install it with pip, running
```
pip install py21cmcast
```
In order to use and modify the code clone this repository and run
To install a modified version of the code (or the latest version, available on github) clone this repository and run
```
pip install -e .
```
in the main folder.
in the main folder. In addition, `meta.yaml` and `build.sh` files are provided for a manual installation with conda. However, the conda install is not garanteed to succeed since it has not been tested.

Although the installation should proceed and you should be able to import the package into your python environement, in order to analyse 21cmFAST raw data, the codes requires to have a working installation of 21cmFAST. For Fisher forcasts, you will need to install [21cmSense](https://21cmsense.readthedocs.io/en/latest/)[^4] in order to evaluate the sensitivity of instruments (current version works with 21cmSense version 2.0.0).


## Quick start guide

Examples on how to run the code are available [here](./examples/) along with an example of input config file.
Examples on how to run the code are available [here](./examples/) along with an minimal example of input config file.


## Ongoing work
Expand All @@ -39,10 +52,12 @@ To do list:
- [ ] uniformely use astropy units throughout the entire code
- [ ] add docstrings to the classes

[^1]: *Charlotte A. Mason, Julian B. Muñoz, Bradley Greig, Andrei Mesinger, and Jaehong Park*, 21cmfish: Fisher-matrix framework for fast parameter forecasts from the cosmic 21-cm signal [[arXiv:2212.09797]](https://arxiv.org/abs/2212.09797)

[^2]: *Andrei Mesinger, Steven Furlanetto, and Renyue Cen*, 21cmFAST: A Fast, Semi-Numerical Simulation of the High-Redshift 21-cm Signal [[arXiv:1003.3878]](https://arxiv.org/abs/1003.3878)
---
[^1]: *Andrei Mesinger, Steven Furlanetto, and Renyue Cen*, 21cmFAST: A Fast, Semi-Numerical Simulation of the High-Redshift 21-cm Signal [[arXiv:1003.3878]](https://arxiv.org/abs/1003.3878)

[^2]: *Andrei Mesinger and Steven Furlanetto*, Efficient Simulations of Early Structure Formation and Reionization [[arXiv:0704.0946]](https://arxiv.org/abs/0704.0946)

[^3]: *Andrei Mesinger and Steven Furlanetto*, Efficient Simulations of Early Structure Formation and Reionization [[arXiv:0704.0946]](https://arxiv.org/abs/0704.0946)
[^3]: *Charlotte A. Mason, Julian B. Muñoz, Bradley Greig, Andrei Mesinger, and Jaehong Park*, 21cmfish: Fisher-matrix framework for fast parameter forecasts from the cosmic 21-cm signal [[arXiv:2212.09797]](https://arxiv.org/abs/2212.09797)

[^4]: *Jonathan C. Pober, Adrian Liu, Joshua S. Dillon, James E. Aguirre, Judd D. Bowman et al.*, What Next-Generation 21 cm Power Spectrum Measurements Can Teach Us About the Epoch of Reionization [[arXiv:1310.7031]](https://arxiv.org/abs/1310.7031)
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$PYTHON setup.py install # Python command to install the script.
13 changes: 5 additions & 8 deletions examples/fisher.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
"from astropy import units\n",
"\n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\", category=np.VisibleDeprecationWarning)\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2"
"warnings.filterwarnings(\"ignore\", category=np.VisibleDeprecationWarning)"
]
},
{
Expand Down Expand Up @@ -66,7 +63,7 @@
"metadata": {},
"outputs": [],
"source": [
"z_bins, z_centers, k_bins = p21c.define_grid_modes_redshifts(6., 8 * units.MHz, z_max = 22, k_min = 0.1 / units.Mpc, k_max = 1 / units.Mpc)\n",
"z_bins, z_array, k_bins = p21c.define_grid_modes_redshifts(6., 8 * units.MHz, z_max = 22, k_min = 0.1 / units.Mpc, k_max = 1 / units.Mpc)\n",
"print(\"The redshift bin edges are:\", z_bins)\n",
"print(\"The mode bin edges are:\", k_bins)"
]
Expand All @@ -78,7 +75,7 @@
"source": [
"## III. Define the fiducial model and get its power spectrum\n",
"\n",
"A **Fiducial** object can be defined by specifying the path where the lightcones are saved (depends on what was set on the config file) as well as the redshifts and modes bin edges. Note that we must set by hand whether the mode bins are linearly of logarithmically spaced with the option **logk** that is by default **False** as the output mode bin deges returned by **define\\_grid\\_modes\\_redshits()** are linearly spaced. Further options can be specified, such as an **observation** and a fraction of modeling error **frac\\_mod** (see below)."
"A **Fiducial** object can be defined by specifying the path where the lightcones are saved (depends on what was set on the config file) as well as the redshifts and modes bin edges. Note that we must set by hand whether the mode bins are linearly of logarithmically spaced with the option **logk** that is by default **False** as the output mode bin deges returned by **define\\_grid\\_modes\\_redshits()** are linearly spaced. Further options can be specified, such as a fraction of modeling error **frac\\_mod** (see below)."
]
},
{
Expand All @@ -87,7 +84,7 @@
"metadata": {},
"outputs": [],
"source": [
"fiducial = p21c.Fiducial(\"../runs/CONSTRAINT_BKR_MINIHALOS\", z_bins, z_centers, k_bins, False, load=True)"
"fiducial = p21c.Fiducial(\"../runs/CONSTRAINT_BKR_MINIHALOS\", z_bins, z_array, k_bins, False, load=True)"
]
},
{
Expand Down Expand Up @@ -123,7 +120,7 @@
"source": [
"## IV. Evaluate experimental noise\n",
"\n",
"The experimental noise is derived using **21cmSense**. To that end one simply has to fix the 'observation' attribute of the fiducial object. The only valid input for now is 'HERA' but other can be added straightforwardly."
"The experimental noise is derived using **21cmSense**. To that end one simply has to pass an 'observation_set' attribute to the compute_sensitivity() method of the fiducial object. If none are passed the default is used `default_HERA`. To use a custom instrument create a list of 21cmSense Observations objects the length of 'fiducial.z_array' (each observation corresponding to the redshift in `fiducial.z_array`)."
]
},
{
Expand Down
Binary file added illustration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% set name = "py21cmcast" %}
{% set version = "1.0.2" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/py21cmcast-{{ version }}.tar.gz
sha256: ac4716cf9817bd9d11ef4a3217b5c6825c1f683f2dc716d6f28e21cb9dbc8cf4

build:
noarch: python
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
number: 0

requirements:
host:
- python >=3.6
- setuptools >=61.0.0
- wheel
- pip
run:
- python >=3.6
- numpy >=1.16.5
- matplotlib-base >=3.4.3
- powerbox >=0.7.3
- configparser >=6.0.0
- astropy >=5.0.0
- scipy

test:
imports:
- py21cmcast
commands:
- pip check
requires:
- pip

about:
summary: Fisher forecasts with 21cm experiments
license: GPL-3.0
license_file: LICENSE
home:
dev_url: https://github.com/gaetanfacchinetti/21cmCAST

extra:
recipe-maintainers:
- gaetanfacchinetti

0 comments on commit 6a25a1a

Please sign in to comment.