Skip to main content

COMPAS detection Likelihood computer

Project description

Coverage Status PyPI version

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-integrator code 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compas_surrogate_lnl_computer-0.2.0.tar.gz (61.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compas_surrogate.lnl_computer-0.2.0-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file compas_surrogate_lnl_computer-0.2.0.tar.gz.

File metadata

File hashes

Hashes for compas_surrogate_lnl_computer-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cc5b9f1110468dca72c9d8b4cc211150beda024b49342b3b2a536eb23e2f956b
MD5 375ab30d466598407c4a1f989e75c3b1
BLAKE2b-256 35a06a628bf84ee287c6b3e79ac004d8f031908c7fb0452d0af82a3b09e8c6d4

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_surrogate.lnl_computer-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for compas_surrogate.lnl_computer-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8e2c40ddba13f49078aa395356c650f3949645513a947764ed4557eca652d9a
MD5 1b9cce29f219cdb97898b76f704316da
BLAKE2b-256 2e77d1defb4d9d83f2c24c19270f51a85cea7d2eb7ddd6e5ed8b3709beca57f2

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page