cogwheel.likelihood.likelihood.CBCLikelihood¶
- class cogwheel.likelihood.likelihood.CBCLikelihood(event_data, waveform_generator)¶
Bases:
JSONMixinClass that accesses the event data and waveform generator.
Provides methods for computing likelihood as a function of compact binary coalescence parameters without using relative binning, and also the asd-drift correction.
Subclassed by
RelativeBinningLikelihood.- Parameters:
- event_datadata.EventData
- waveform_generatorwaveform.WaveformGenerator
Methods
Estimate local standard deviation of the matched-filter output at the time of the event for each detector.
Return average frequency in Hz.
Return dictionary with keyword arguments to __init__.
Name of the module that defines the instance's class.
Return log likelihood computed on the FFT grid, without using relative binning.
Plot the whitened strain and waveform model in the time domain in all detectors.
Placeholder method that will be called after sampling and may be overriden by subclasses.
Return a new instance of the class, possibly updating init_kwargs.
Write class instance to json file.
Attributes
Array of length ndetectors with ASD drift-correction.
Parameters expected in par_dic for likelihood evaluation.
subclass_registry- property asd_drift¶
Array of length ndetectors with ASD drift-correction.
Values > 1 mean local noise variance is higher than average.
- compute_asd_drift(par_dic, tol=0.02, max_tcorr_contiguous_low=16.0, **kwargs)¶
Estimate local standard deviation of the matched-filter output at the time of the event for each detector.
Note: all harmonic_modes of the approximant are used even if waveform_generator.harmonic_modes is set differently. This is so that asd_drift does not change and one can make apples-to- apples comparisons of the likelihood toggling harmonic modes on and off.
- Parameters:
- par_dicdict
Waveform parameters, keys should match
self.waveform_generator.params.- tolfloat
Stochastic measurement error tolerance, used to decide the number of samples.
- max_tcorr_contiguous_lowfloat
Maximum number of contiguous correlation times with values below the average noise level to allow (these are classified as a hole and disregarded in the average).
- **kwargs
Passed to safe_std, keys include:
expected_high,reject_nearby.
- get_average_frequency(par_dic, ref_det_name=None, moment=1.0)¶
Return average frequency in Hz.
The average frequency is defined as
(avg(f^moment))^(1/moment)whereavgis the frequency-domain average with weight~ |h(f)|^2 / PSD(f).The answer is rounded to nearest Hz to ease reporting.
- Parameters:
- par_dicdict
Waveform parameters, keys should match
self.waveform_generator.params.- ref_det_namestr or None
Name of the detector from which to get the PSD, e.g. ‘H’ for Hanford, or None (default) to combine the PSDs of all detectors.
- momentnonzero float
Controls the frequency weights in the average.
- get_init_dict(**kwargs)¶
Return dictionary with keyword arguments to __init__.
Only works if the class stores its init parameters as attributes with the same names. Otherwise, the subclass should override this method.
- Parameters:
- **kwargs
Allows to manually override some keys. The remaining ones will be read from the instance’s attributes. All keywords must be in the __init__ signature. It’s mostly here to facilitate overriding by subclasses.
- get_module_name()¶
Name of the module that defines the instance’s class.
- lnlike_fft(par_dic)¶
Return log likelihood computed on the FFT grid, without using relative binning.
- Parameters:
- par_dicdict
Waveform parameters, keys should match
self.waveform_generator.params.
- property params¶
Parameters expected in par_dic for likelihood evaluation.
- plot_whitened_wf(par_dic, trng=(-0.7, 0.1), plot_data=True, fig=None, figsize=None, by_m=False, **wf_plot_kwargs)¶
Plot the whitened strain and waveform model in the time domain in all detectors.
- Parameters:
- par_dicdict
Waveform parameters, keys should match
self.waveform_generator.params.- trng(float, float)
Range of time to plot relative to self.tgps (s).
- plot_databool
Whether to include detector data in plot.
- figmatplotlib.figure.Figure, optional
None(default) creates a new figure.- figsize(float, float)
Figure width and height in inches, used if fig=None.
- **wf_plot_kwargs
Keyword arguments passed to
plt.plot()for waveform. Additionally, keyword arguments for the data plot can be passed as a dictdata_plot_kwargs.
- Returns:
- matplotlib.figure.Figure
Figure with plots.
- postprocess_samples(samples)¶
Placeholder method that will be called after sampling and may be overriden by subclasses. (E.g. marginalized likelihoods demarginalize the distribution in postprocessing.)
- Parameters:
- samplespandas.DataFrame
Rows are samples, columns must contain .params.
- reinstantiate(**new_init_kwargs)¶
Return a new instance of the class, possibly updating init_kwargs.
Values not passed will be taken from the current instance.
- to_json(dirname, basename=None, *, dir_permissions=493, file_permissions=420, overwrite=False)¶
Write class instance to json file.
It can then be loaded with read_json.