COMPAS detection Likelihood computer
Project description
COMPAS Detection Likelihood computer
Utils to run the COMPAS cosmic-integration code in batches and compute the LnL given SF params and set of observations.
More specifically, this package:
- runs COMPAS's
cosmic-integratorcode for SF params - saves the detection rate matrices given the SF params
- computes the LnL (and bootstrapped uncertainty) given a set of observations
- saves the LnL and uncertainty for the SF params and observations
Installation
pip install compas_python_utils@git+https://github.com/TeamCOMPAS/COMPAS.git
pip install compas-surrogate.lnl_computer
Example
from lnl_computer.cosmic_integration.mcz_grid import McZGrid
from lnl_computer.mock_data import generate_mock_data
SF_SAMPLE = dict(aSF=0.01, dSF=4.70, mu_z=-0.23, sigma_z=0.0)
mock_data = generate_mock_data(outdir='temp', sf_params=SF_SAMPLE)
lnl, unc = McZGrid.lnl(
mcz_obs=mock_data.observations.mcz,
compas_h5_path=mock_data.compas_filename,
sf_sample=SF_SAMPLE,
n_bootstraps=0,
outdir='temp',
save_plots=False, # Set to True to save plots for diagnostics
)
CLI Interface
!batch_lnl_generation --help
Usage: batch_lnl_generation [OPTIONS] MCZ_OBS COMPAS_H5_PATH PARAMETER_TABLE
Given observations (MCZ_OBS, npz-file), COMPAS output (COMPAS_H5_PATH, h5
file), and a table of SF parameters (PARAMETER_TABLE, csv file), generate
McZ grids and compute likelihoods.
The likelihoods are saved to OUTDIR/*_lnl.csv
Options:
--n_bootstraps INTEGER Number of bootstraps to generate for each parameter
set (used for error estimation) [default: 100]
--plots / --no_plots Save diagnostic plots for each parameter set
[default: plots]
--outdir TEXT Outdir for mcz-grids [default: out_mcz_grids]
--help Show this message and exit.
!combine_lnl_data --help
Usage: combine_lnl_data [OPTIONS] [OUTDIR]
Combine the likelihood data in 'OUTDIR/*_lnl.csv' -> FNAME
OUTDIR: Output directory with likelihood files (csvs)
Options:
--fname TEXT Output filename (must be a .csv)
--help Show this message and exit.
!make_mock_obs --help
Usage: make_mock_obs [OPTIONS] COMPAS_H5_PATH
Generate a set of 'mock' observations for the sf-sample and compas output
file (COMPAS_H5_PATH).
Options:
--sf_sample TEXT Star formation parameters [default: aSF:0.01 dSF:0.01
muz:0.01 sigma0:0.01]
--fname TEXT Output filename (must be a .npz)
--help Show this message and exit.
!make_sf_table --help
Usage: make_sf_table [OPTIONS]
Parses the table of parameters to generate mcz-grids for.
Options:
-p, --parameters TEXT List of parameters to generate mcz-grids for
-n, --n INTEGER Number of samples to generate
-g, --grid_parameterspace Whether to grid the parameter space
-f, --fname TEXT Output filename (must be a .csv)
--help Show this message and exit.
!make_mock_compas_output --help
Usage: make_mock_compas_output [OPTIONS]
Generate a mock COMPAS output file at FNAME
Options:
--fname TEXT Output filename (must be a .h5)
--help Show this message and exit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file compas_surrogate_lnl_computer-0.2.0.tar.gz.
File metadata
- Download URL: compas_surrogate_lnl_computer-0.2.0.tar.gz
- Upload date:
- Size: 61.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc5b9f1110468dca72c9d8b4cc211150beda024b49342b3b2a536eb23e2f956b
|
|
| MD5 |
375ab30d466598407c4a1f989e75c3b1
|
|
| BLAKE2b-256 |
35a06a628bf84ee287c6b3e79ac004d8f031908c7fb0452d0af82a3b09e8c6d4
|
Provenance
The following attestation bundles were made for compas_surrogate_lnl_computer-0.2.0.tar.gz:
Publisher:
release.yml on COMPAS-Surrogate/lnl_computer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compas_surrogate_lnl_computer-0.2.0.tar.gz -
Subject digest:
cc5b9f1110468dca72c9d8b4cc211150beda024b49342b3b2a536eb23e2f956b - Sigstore transparency entry: 154903057
- Sigstore integration time:
-
Permalink:
COMPAS-Surrogate/lnl_computer@533c9ba109ebc7608a7f1fcc878f2cf83807a27b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/COMPAS-Surrogate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@533c9ba109ebc7608a7f1fcc878f2cf83807a27b -
Trigger Event:
push
-
Statement type:
File details
Details for the file compas_surrogate.lnl_computer-0.2.0-py3-none-any.whl.
File metadata
- Download URL: compas_surrogate.lnl_computer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8e2c40ddba13f49078aa395356c650f3949645513a947764ed4557eca652d9a
|
|
| MD5 |
1b9cce29f219cdb97898b76f704316da
|
|
| BLAKE2b-256 |
2e77d1defb4d9d83f2c24c19270f51a85cea7d2eb7ddd6e5ed8b3709beca57f2
|
Provenance
The following attestation bundles were made for compas_surrogate.lnl_computer-0.2.0-py3-none-any.whl:
Publisher:
release.yml on COMPAS-Surrogate/lnl_computer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compas_surrogate_lnl_computer-0.2.0-py3-none-any.whl -
Subject digest:
f8e2c40ddba13f49078aa395356c650f3949645513a947764ed4557eca652d9a - Sigstore transparency entry: 154903062
- Sigstore integration time:
-
Permalink:
COMPAS-Surrogate/lnl_computer@533c9ba109ebc7608a7f1fcc878f2cf83807a27b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/COMPAS-Surrogate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@533c9ba109ebc7608a7f1fcc878f2cf83807a27b -
Trigger Event:
push
-
Statement type: