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.
Metadata
Release files for compas-surrogate.lnl-computer 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| compas_surrogate_lnl_computer-0.2.0.tar.gz | 61.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| compas_surrogate.lnl_computer-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 81.7 kB
Release files / compas_surrogate_lnl_computer-0.2.0.tar.gz
| Download URL | compas_surrogate_lnl_computer-0.2.0.tar.gz |
|---|---|
| Size | 61.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc5b9f1110468dca72c9d8b4cc211150beda024b49342b3b2a536eb23e2f956b
|
|
BLAKE2b-256 checksum How to use checksums |
35a06a628bf84ee287c6b3e79ac004d8f031908c7fb0452d0af82a3b09e8c6d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 12, 2024.
Transparency logRelease files / compas_surrogate.lnl_computer-0.2.0-py3-none-any.whl
| Download URL | compas_surrogate.lnl_computer-0.2.0-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8e2c40ddba13f49078aa395356c650f3949645513a947764ed4557eca652d9a
|
|
BLAKE2b-256 checksum How to use checksums |
2e77d1defb4d9d83f2c24c19270f51a85cea7d2eb7ddd6e5ed8b3709beca57f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 12, 2024.
Transparency log