bilby.gw.likelihood.roq.ROQGravitationalWaveTransient
- class bilby.gw.likelihood.roq.ROQGravitationalWaveTransient(interferometers, waveform_generator, priors, weights=None, linear_matrix=None, quadratic_matrix=None, roq_params=None, roq_params_check=True, roq_scale_factor=1, distance_marginalization=False, phase_marginalization=False, time_marginalization=False, jitter_time=True, delta_tc=None, distance_marginalization_lookup_table=None, reference_frame='sky', time_reference='geocenter', parameter_conversion=None)[source]
Bases:
GravitationalWaveTransient
A reduced order quadrature likelihood object
This uses the method described in Smith et al., (2016) Phys. Rev. D 94, 044031. A public repository of the ROQ data is available from https://git.ligo.org/lscsoft/ROQ_data.
- 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
- linear_matrix: str, array_like
Either a string point to the file from which to load the linear_matrix array, or the array itself.
- quadratic_matrix: str, array_like
Either a string point to the file from which to load the quadratic_matrix array, or the array itself.
- roq_params: str, array_like
Parameters describing the domain of validity of the ROQ basis.
- roq_params_check: bool
If true, run tests using the roq_params to check the prior and data are valid for the ROQ
- roq_scale_factor: float
The ROQ scale factor used.
- parameter_conversion: func, optional
Function to update self.parameters before bases are selected based on the values of self.parameters. This enables a user to switch bases based on the values of parameters which are not directly used for sampling.
- priors: dict, bilby.prior.PriorDict
A dictionary of priors containing at least the geocent_time prior 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().
- time_marginalization: bool, optional
If true, marginalize over time in the likelihood. The spacing of time samples can be specified through delta_tc. 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.
- 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.
- delta_tc: float, optional
The spacing of time samples for time marginalization. If not specified, it is determined based on the signal-to-noise ratio of signal.
- 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’
- 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 default - e.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 default
e.g., “H1”: sample in the time of arrival at H1
- __init__(interferometers, waveform_generator, priors, weights=None, linear_matrix=None, quadratic_matrix=None, roq_params=None, roq_params_check=True, roq_scale_factor=1, distance_marginalization=False, phase_marginalization=False, time_marginalization=False, jitter_time=True, delta_tc=None, distance_marginalization_lookup_table=None, reference_frame='sky', time_reference='geocenter', parameter_conversion=None)[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, ...[, weights, ...])Empty likelihood class to be subclassed by other likelihoods
cache_lookup_table
()calculate_snrs
(waveform_polarizations, ...)Compute the snrs for ROQ
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)load_weights
(filename[, format])Load ROQ weights.
- Returns:
Difference between log likelihood and noise log likelihood
- Returns:
perform_roq_params_check
([ifo])Perform checking that the prior and data are valid for the ROQ
phase_marginalized_likelihood
(d_inner_h, ...)save_weights
(filename[, format])Save ROQ weights into a single file.
time_marginalized_likelihood
(...)Attributes
basis_number_linear
basis_number_quadratic
cached_lookup_table_filename
interferometers
lal_version
lalsimulation_version
marginalized_parameters
meta_data
priors
reference_frame
waveform_generator
- calculate_snrs(waveform_polarizations, interferometer, return_array=True)[source]
Compute the snrs for ROQ
- Parameters:
- waveform_polarizations: waveform
- interferometer: bilby.gw.detector.Interferometer
- 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
- load_weights(filename, format=None)[source]
Load ROQ weights. format should be json, npz, or hdf5. json or npz file is assumed to contain weights from a single basis. Support for json format is deprecated as of
v2.1
and will be removed inv2.2
, another method should be used by default.- Parameters:
- filenamestr
The name of the file to save the weights to.
- formatstr
The format to save the data to, this should be one of
"hdf5"
,"npz"
, default=:code:”hdf5”.
- Returns:
- weights: dict
Dictionary containing the ROQ weights.
- log_likelihood_ratio()[source]
Difference between log likelihood and noise log likelihood
- Returns:
- float
- perform_roq_params_check(ifo=None)[source]
Perform checking that the prior and data are valid for the ROQ
- Parameters:
- ifo: bilby.gw.detector.Interferometer
The interferometer
- save_weights(filename, format='hdf5')[source]
Save ROQ weights into a single file. format should be npz, or hdf5. For weights from multiple bases, hdf5 is only the possible option. Support for json format is deprecated as of
v2.1
and will be removed inv2.2
, another method should be used by default.- Parameters:
- filenamestr
The name of the file to save the weights to.
- formatstr
The format to save the data to, this should be one of
"hdf5"
,"npz"
, default=:code:”hdf5”.