bilby.gw.likelihood.base.GravitationalWaveTransient
- class bilby.gw.likelihood.base.GravitationalWaveTransient(interferometers, waveform_generator, time_marginalization=False, distance_marginalization=False, phase_marginalization=False, calibration_marginalization=False, priors=None, distance_marginalization_lookup_table=None, calibration_lookup_table=None, number_of_response_curves=1000, starting_index=0, jitter_time=True, reference_frame='sky', time_reference='geocenter')[source]
Bases:
Likelihood
A gravitational-wave transient likelihood object
This is the usual likelihood object to use for transient gravitational wave parameter estimation. It computes the log-likelihood in the frequency domain assuming a colored Gaussian noise model described by a power spectral density. See Thrane & Talbot (2019), arxiv.org/abs/1809.02293.
- Parameters:
- interferometers: list, bilby.gw.detector.InterferometerList
A list of bilby.detector.Interferometer instances - contains the detector data and power spectral densities
- waveform_generator: `bilby.waveform_generator.WaveformGenerator`
An object which computes the frequency-domain strain of the signal, given some set of parameters
- distance_marginalization: bool, optional
If true, marginalize over distance in the likelihood. This uses a look up table calculated at run time. The distance prior is set to be a delta function at the minimum distance allowed in the prior being marginalised over.
- time_marginalization: bool, optional
If true, marginalize over time in the likelihood. This uses a FFT to calculate the likelihood over a regularly spaced grid. In order to cover the whole space the prior is set to be uniform over the spacing of the array of times. If using time marginalisation and jitter_time is True a “jitter” parameter is added to the prior which modifies the position of the grid of times.
- phase_marginalization: bool, optional
If true, marginalize over phase in the likelihood. This is done analytically using a Bessel function. The phase prior is set to be a delta function at phase=0.
- calibration_marginalization: bool, optional
If true, marginalize over calibration response curves in the likelihood. This is done numerically over a number of calibration response curve realizations.
- priors: dict, optional
If given, used in the distance and phase marginalization. Warning: when using marginalisation the dict is overwritten which will change the the dict you are passing in. If this behaviour is undesired, pass priors.copy().
- distance_marginalization_lookup_table: (dict, str), optional
If a dict, dictionary containing the lookup_table, distance_array, (distance) prior_array, and reference_distance used to construct the table. If a string the name of a file containing these quantities. The lookup table is stored after construction in either the provided string or a default location: ‘.distance_marginalization_lookup_dmin{}_dmax{}_n{}.npz’
- calibration_lookup_table: dict, optional
If a dict, contains the arrays over which to marginalize for each interferometer or the filepaths of the calibration files. If not provided, but calibration_marginalization is used, then the appropriate file is created to contain the curves.
- number_of_response_curves: int, optional
Number of curves from the calibration lookup table to use. Default is 1000.
- starting_index: int, optional
Sets the index for the first realization of the calibration curve to be considered. This, coupled with number_of_response_curves, allows for restricting the set of curves used. This can be used when dealing with large frequency arrays to split the calculation into sections. Defaults to 0.
- jitter_time: bool, optional
Whether to introduce a time_jitter parameter. This avoids either missing the likelihood peak, or introducing biases in the reconstructed time posterior due to an insufficient sampling frequency. Default is False, however using this parameter is strongly encouraged.
- reference_frame: (str, bilby.gw.detector.InterferometerList, list), optional
Definition of the reference frame for the sky location.
sky
: sample in RA/dec, this is the defaulte.g.,
"H1L1", ["H1", "L1"], InterferometerList(["H1", "L1"])
: sample in azimuth and zenith, azimuth and zenith defined in the frame where the z-axis is aligned the the vector connecting H1 and L1.
- time_reference: str, optional
Name of the reference for the sampled time parameter.
geocent
/geocenter
: sample in the time at the Earth’s center, this is the defaulte.g.,
H1
: sample in the time of arrival at H1
- Returns:
- Likelihood: bilby.core.likelihood.Likelihood
A likelihood object, able to compute the likelihood of the data given some model parameters
- __init__(interferometers, waveform_generator, time_marginalization=False, distance_marginalization=False, phase_marginalization=False, calibration_marginalization=False, priors=None, distance_marginalization_lookup_table=None, calibration_lookup_table=None, number_of_response_curves=1000, starting_index=0, jitter_time=True, reference_frame='sky', time_reference='geocenter')[source]
Empty likelihood class to be subclassed by other likelihoods
- Parameters:
- parameters: dict
A dictionary of the parameter names and associated values
- __call__(*args, **kwargs)
Call self as a function.
Methods
__init__
(interferometers, waveform_generator)Empty likelihood class to be subclassed by other likelihoods
cache_lookup_table
()calculate_snrs
(waveform_polarizations, ...)Compute the snrs
calibration_marginalized_likelihood
(...)compute_log_likelihood_from_snrs
(total_snrs)compute_per_detector_log_likelihood
()distance_marginalized_likelihood
(d_inner_h, ...)generate_calibration_sample_from_marginalized_likelihood
([...])Generate a single sample from the posterior distribution for the set of calibration response curves when explicitly marginalizing over the calibration uncertainty.
generate_distance_sample_from_marginalized_likelihood
([...])Generate a single sample from the posterior distribution for luminosity distance when using a likelihood which explicitly marginalises over distance.
Generate a single sample from the posterior distribution for phase when using a likelihood which explicitly marginalises over phase.
Reconstruct the distance posterior from a run which used a likelihood which explicitly marginalised over time/distance/phase.
Generate a single sample from the posterior distribution for coalescence time when using a likelihood which explicitly marginalises over time.
get_calibration_log_likelihoods
([...])get_sky_frame_parameters
([parameters])Generate ra, dec, and geocenter time for
parameters
load_lookup_table
(filename)- Returns:
Difference between log likelihood and noise log likelihood
- Returns:
phase_marginalized_likelihood
(d_inner_h, ...)time_marginalized_likelihood
(...)Attributes
cached_lookup_table_filename
interferometers
lal_version
lalsimulation_version
marginalized_parameters
meta_data
priors
reference_frame
- calculate_snrs(waveform_polarizations, interferometer, return_array=True)[source]
Compute the snrs
- Parameters:
- waveform_polarizations: dict
A dictionary of waveform polarizations and the corresponding array
- interferometer: bilby.gw.detector.Interferometer
The bilby interferometer object
- return_array: bool
If true, calculate and return internal array objects (d_inner_h_array and optimal_snr_squared_array), otherwise these are returned as None.
- Returns:
- calculated_snrs: _CalculatedSNRs
An object containing the SNR quantities and (if return_array=True) the internal array objects.
- generate_calibration_sample_from_marginalized_likelihood(signal_polarizations=None)[source]
Generate a single sample from the posterior distribution for the set of calibration response curves when explicitly marginalizing over the calibration uncertainty.
- Parameters:
- signal_polarizations: dict, optional
Polarizations modes of the template.
- Returns:
- new_calibration: dict
Sample set from the calibration posterior
- generate_distance_sample_from_marginalized_likelihood(signal_polarizations=None)[source]
Generate a single sample from the posterior distribution for luminosity distance when using a likelihood which explicitly marginalises over distance.
See Eq. (C29-C32) of https://arxiv.org/abs/1809.02293
- Parameters:
- signal_polarizations: dict, optional
Polarizations modes of the template. Note: These are rescaled in place after the distance sample is generated to allow further parameter reconstruction to occur.
- Returns:
- new_distance: float
Sample from the distance posterior.
- generate_phase_sample_from_marginalized_likelihood(signal_polarizations=None)[source]
Generate a single sample from the posterior distribution for phase when using a likelihood which explicitly marginalises over phase.
See Eq. (C29-C32) of https://arxiv.org/abs/1809.02293
- Parameters:
- signal_polarizations: dict, optional
Polarizations modes of the template.
- Returns:
- new_phase: float
Sample from the phase posterior.
Notes
This is only valid when assumes that mu(phi) propto exp(-2i phi).
- generate_posterior_sample_from_marginalized_likelihood()[source]
Reconstruct the distance posterior from a run which used a likelihood which explicitly marginalised over time/distance/phase.
See Eq. (C29-C32) of https://arxiv.org/abs/1809.02293
- Returns:
- sample: dict
Returns the parameters with new samples.
Notes
This involves a deepcopy of the signal to avoid issues with waveform caching, as the signal is overwritten in place.
- generate_time_sample_from_marginalized_likelihood(signal_polarizations=None)[source]
Generate a single sample from the posterior distribution for coalescence time when using a likelihood which explicitly marginalises over time.
In order to resolve the posterior we artificially upsample to 16kHz.
See Eq. (C29-C32) of https://arxiv.org/abs/1809.02293
- Parameters:
- signal_polarizations: dict, optional
Polarizations modes of the template.
- Returns:
- new_time: float
Sample from the time posterior.
- get_sky_frame_parameters(parameters=None)[source]
Generate ra, dec, and geocenter time for
parameters
This method will attempt to convert from the reference time and sky parameters, but if they are not present it will fall back to ra and dec.
- Parameters:
- parameters: dict, optional
The parameters to be converted. If not specified
self.parameters
will be used.
- Returns:
- dict: dictionary containing ra, dec, and geocent_time