Skip to content

Commit

Permalink
CCL modes (#465)
Browse files Browse the repository at this point in the history
* Turning tests into a package to allow importing.
* Introducing CCL creation modes.
*  Adapting code from PR #458 to allow CCL MG models.
* Reorganized cobaya example in sub-directory.
* Handling experiment loading directories.
* Reorganized cosmosis example sub-directory.
* Renaming example files.
* Better path specification for Cobaya.
* Adding support for pure_ccl in numcosmo connector.
* Updated tests.
* Updated file names.
* Adding support for mu_sigma experiments.
* Updated README.md
* Improving integration tests.
* Updating documentation.
* Removing mu_sigma test from NumCosmo list.
* Testing new camb_extra_parameters.
* Testing Cobaya connector with ccl_pure mode.
* More testing for CCLFactory.
* Testing NumCosmo connector.
* Testing absolute path in DataSource.
* Testing cosmosis connector with pure ccl.
* Adding missing mass_split test check.
  • Loading branch information
vitenti authored Oct 29, 2024
1 parent 96b38ba commit ac77f81
Show file tree
Hide file tree
Showing 42 changed files with 1,459 additions and 164 deletions.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies:
- pip:
- autoclasstoc
- cobaya
- isitgr
- pygobject-stubs
- portalocker
- pybobyqa
Expand Down
78 changes: 58 additions & 20 deletions examples/des_y1_3x2pt/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,76 @@
# DES Y1 3x2pt Analysis

The code here will run a test sample for a Flat LCDM cosmology using either Cobaya or CosmoSIS.
The DES Y1 3x2pt analysis of the Dark Energy Survey (DES) Year 1 (Y1) data, focusing on
**cosmic shear**, **galaxy-galaxy lensing**, and **galaxy clustering**. This repository
demonstrates how to use the DES Y1 3x2pt data products to compute the likelihood with
the following tools:

## Running Cobaya
- **Cobaya**
- **CosmoSIS**
- **NumCosmo**

## Likelihood Factories

The **Firecrown** likelihoods can be customized through user-defined factories. In this
example, the following factory files are provided:

The Cobaya file `cobaya_evaluate.yaml` configures Cobaya to use the `des_y1_3x2pt.py` likelihood.
Run it using:
- `factory.py`: Factory for the DES Y1 3x2pt analysis.
- `factory_PT.py`: Factory for the DES Y1 3x2pt analysis using perturbation theory.

cobaya-run cobaya_evaluate.yaml
Alternatively, Firecrown’s **default factories** can be configured using experiment
configuration files:

This will produce the output files:
- `experiment.yaml`: Standard configuration for the DES Y1 3x2pt analysis.
- `pure_ccl_experiment.yaml`: Configuration for the DES Y1 3x2pt analysis in
**pure_ccl** mode.
- `mu_sigma_experiment.yaml`: Configuration for **mu_sigma_isitgr** mode.

cobaya_evaluate_output.input.yaml
cobaya_evaluate_output.updated.yaml
cobaya_evaluate_output.updated.dill_pickle
cobaya_evaluate_output.1.txt
Note that `mu_sigma_experiment.yaml` requires the
[`isitgr`](https://github.com/mishakb/ISiTGR) package to be installed. This package is
not installed by default in the Firecrown environment.

## Running CosmoSIS

The pipeline configuration file `des_y1_3x2pt.ini` and the related `des_y1_3x2pt_values.ini` configure CosmoSIS to use the `des_y1_3x2pt.py` likelihood.
Run this using:
For each likelihood factory, a corresponding **CosmoSIS** pipeline configuration file is
provided:

cosmosis des_y1_3x2pt.ini
- `cosmosis/factory.ini`: Pipeline for the standard DES Y1 3x2pt analysis.
- `cosmosis/factory_PT.ini`: Pipeline for the analysis with perturbation theory.
- `cosmosis/pure_ccl.ini`: Pipeline for the analysis in **pure CCL** mode.
- `cosmosis/mu_sigma.ini`: Pipeline for the analysis in **mu_sigma_isitgr** mode.

This will produce the output to the screen, showing the calculated likelihood.
It also creates the directory `des_y1_3x2pt_output` which is populated with the CosmoSIS datablock contents for the generated sample.
### Example Command

## Generating the `firecrown` Inputs
To run the CosmoSIS pipeline, use the following command:

```bash
cosmosis cosmosis/factory.ini
```

## Running Cobaya

Note, this code below only has to be run if you want to generate the firecrown input from the DES Y1 3x2pt data products.
This file is stored at `examples/des_y1_3x2pt/des_y1_3x2pt_sacc_data.fits`.
You do not have to make it yourself.
For Cobaya, the pipeline configuration files are:

- `cobaya/evaluate.yaml`: Pipeline for the standard DES Y1 3x2pt analysis.
- `cobaya/evaluate_PT.yaml`: Pipeline for the analysis with perturbation theory.
- `cobaya/evaluate_pure_ccl.yaml`: Pipeline for the analysis in **pure CCL** mode.
- `cobaya/evaluate_mu_sigma.yaml`: Pipeline for the analysis in **mu_sigma_isitgr** mode.

### Example Command

To run the Cobaya pipeline, use the following command:

```bash
cobaya-run cobaya/factory.yaml
```

## Generating the `firecrown` Inputs

To generate the `firecrown` inputs, first download the DES Y1 3x2pt data products [here](http://desdr-server.ncsa.illinois.edu/despublic/y1a1_files/chains/2pt_NG_mcal_1110.fits).
There is already a `sacc_data.fits` file in this directory that contains the DES Y1
3x2pt data products. If you want to regenerate the `firecrown` inputs, you can run
`generate_des_data.py`. To generate the `firecrown` inputs, first download the DES Y1
3x2pt data products
[here](http://desdr-server.ncsa.illinois.edu/despublic/y1a1_files/chains/2pt_NG_mcal_1110.fits).

Then run the script

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ theory:
likelihood:
des_y1_3x2pt:
external: !!python/name:firecrown.connector.cobaya.likelihood.LikelihoodConnector ''
firecrownIni: des_y1_3x2pt.py
firecrownIni: ${FIRECROWN_DIR}/examples/des_y1_3x2pt/factory.py
derived_parameters:
- TwoPoint__NumberCountsScale_lens0
- TwoPoint__NumberCountsScale_lens1
Expand Down Expand Up @@ -182,7 +182,7 @@ params:
sampler:
evaluate: null
stop_at_error: true
output: cobaya_evaluate_output
output: output
packages_path: null
test: false
debug: false
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ theory:
likelihood:
des_y1_3x2pt:
external: !!python/name:firecrown.connector.cobaya.likelihood.LikelihoodConnector ''
firecrownIni: des_y1_3x2pt_PT.py
firecrownIni: ${FIRECROWN_DIR}/examples/des_y1_3x2pt/factory_PT.py
params:
As:
prior:
Expand Down Expand Up @@ -96,7 +96,7 @@ params:
sampler:
evaluate: null
stop_at_error: true
output: cobaya_evaluate_output_PT
output: output_PT
packages_path: null
test: false
debug: false
176 changes: 176 additions & 0 deletions examples/des_y1_3x2pt/cobaya/evaluate_mu_sigma.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
likelihood:
des_y1_3x2pt:
external: !!python/name:firecrown.connector.cobaya.likelihood.LikelihoodConnector ''
firecrownIni: firecrown.likelihood.factories.build_two_point_likelihood
build_parameters:
likelihood_config: ${FIRECROWN_DIR}/examples/des_y1_3x2pt/mu_sigma_experiment.yaml
params:
sigma8:
prior:
min: 0.6
max: 1.0
ref: 0.8
proposal: 0.01
Omega_b: 0.05
Omega_c:
prior:
min: 0.05
max: 0.35
ref: 0.25
proposal: 0.01
Omega_k: 0.0
h: 0.682
Neff: 3.046
m_nu: 0.06
n_s: 0.971
w0: -1.0
wa: 0.0
T_CMB: 2.7255

# - MG Model
mg_musigma_mu:
ref: 1.0
prior:
min: 0.8
max: 1.2
mg_musigma_sigma:
ref: 1.0
prior:
min: 0.8
max: 1.2
mg_musigma_c1: 1.0
mg_musigma_c2: 1.0
mg_musigma_lambda0: 1.0
# Likelihood params
# - IA model
ia_bias:
ref: 0.5
prior:
min: -5.0
max: +5.0
alphaz:
ref: 0.0
prior:
min: -5.0
max: +5.0

# - these parameters are fixed
z_piv: 0.62

# - linear bias for lenses
lens0_bias:
ref: 1.4
prior:
min: 0.8
max: 3.0
lens1_bias:
ref: 1.6
prior:
min: 0.8
max: 3.0
lens2_bias:
ref: 1.6
prior:
min: 0.8
max: 3.0
lens3_bias:
ref: 1.9
prior:
min: 0.8
max: 3.0
lens4_bias:
ref: 2.0
prior:
min: 0.8
max: 3.0

# - photoz shifts for the lensing sources
src0_delta_z:
ref: -0.001
prior:
dist: norm
loc: -0.001
scale: 0.016
src1_delta_z:
ref: -0.019
prior:
dist: norm
loc: -0.019
scale: 0.013
src2_delta_z:
ref: +0.009
prior:
dist: norm
loc: 0.009
scale: 0.011
src3_delta_z:
ref: -0.018
prior:
dist: norm
loc: -0.018
scale: 0.022

# - photoz shifts for the lenses
lens0_delta_z:
ref: 0.001
prior:
dist: norm
loc: 0.001
scale: 0.008
lens1_delta_z:
ref: 0.002
prior:
dist: norm
loc: 0.002
scale: 0.007
lens2_delta_z:
ref: 0.001
prior:
dist: norm
loc: 0.001
scale: 0.007
lens3_delta_z:
ref: 0.003
prior:
dist: norm
loc: 0.003
scale: 0.01
lens4_delta_z:
ref: 0.0
prior:
dist: norm
loc: 0.0
scale: 0.01

# - shear errors
src0_mult_bias:
ref: 0.0
prior:
dist: norm
loc: 0.012
scale: 0.023
src1_mult_bias:
ref: 0.0
prior:
dist: norm
loc: 0.012
scale: 0.023
src2_mult_bias:
ref: 0.0
prior:
dist: norm
loc: 0.012
scale: 0.023
src3_mult_bias:
ref: 0.0
prior:
dist: norm
loc: 0.012
scale: 0.023
sampler:
evaluate: null
stop_at_error: true
output: output_mu_sigma
packages_path: null
test: false
debug: false
Loading

0 comments on commit ac77f81

Please sign in to comment.