aspire_bilby.plugin#
Plugin for the aspire sampler in bilby.
Classes#
Bilby wrapper for aspire. |
Module Contents#
- class aspire_bilby.plugin.Aspire(likelihood, priors, outdir='outdir', label='label', use_ratio=False, plot=False, skip_import_verification=False, injection_parameters=None, meta_data=None, result_class=None, likelihood_benchmark=False, soft_init=False, exit_code=130, npool=1, **kwargs)[source]#
Bases:
bilby.core.sampler.base_sampler.SamplerBilby wrapper for aspire.
Aspire: mj-will/bayesian-aspire
Since aspire is designed to be called in multiple steps, specific keyword arguments are used for each step: - fit_kwargs for the fit step - sample_kwargs for the sampling step In addition, there are custom arguments for handling e.g. logging: - aspire_log_level for the logging level of aspire - initial_conversion_function for a function to convert the initial samples. - sample_from_prior to specify parameters that should be sampled from the prior regardless of whether they are in the initial result file.
It also includes a method to read initial samples from a bilby result.
Aspire also supports checkpointing and resuming via the built-in checkpointing functionality. If
enable_checkpointingis set toTrue(default), a checkpoint file will be created in the output directory with the name{label}_aspire_checkpoint.h5. If you provide a custom checkpoint file via thecheckpoint_filekeyword argument insample_kwargs, that file will be used instead. The checkpoint file is updated everycheckpoint_everyiterations (default 1). If the checkpoint file already exists, Aspire will resume from the last checkpoint. If resume is set to False, the checkpoint file then any existing checkpoint file will be ignored and overwritten, and the sampler will start from scratch.- property external_sampler_name: str[source]#
The name of package that provides the sampler.
- Return type:
str
- get_conversion_function(conversion_function=None)[source]#
Get the conversion function from a string or return None.
- Parameters:
conversion_function (Callable | str)
- Return type:
Callable
- read_initial_samples(initial_result_file, sample_from_prior=None, conversion_function=None)[source]#
Read the initial samples from a bilby result file.
If parameters are missing, they will be drawn from the prior.
- Parameters:
initial_result_file (
str) – The path to the initial result file.parameters_to_sample (
list) – List of parameters to sample from the prior regardless of whether they are in the initial result file.sample_from_prior (
list[str], optional) – List of parameters to sample from the prior regardless of whether they are in the initial result file. If None, all parameters will be sampled from the initial result file.conversion_function (
Callable) – A function to convert the initial samples.
- Return type:
aspire.samples.Samples
- add_samples_to_result(samples)[source]#
Add samples to the result object.
Handles different types of samples objects and adds the appropriate attributes to the result.
- Parameters:
samples (aspire.samples.Samples)
- classmethod get_expected_outputs(outdir=None, label=None)[source]#
Get lists of the expected outputs directories and files.
These are used by
bilby_pipewhen transferring files via HTCondor. Both can be empty.- Parameters:
outdir (
str) – The output directory.label (
str) – The label for the run.
- Returns:
list– List of file names.list– List of directory names.