cogwheel.likelihood.relative_binning.RelativeBinningLikelihood¶
- class cogwheel.likelihood.relative_binning.RelativeBinningLikelihood(event_data, waveform_generator, par_dic_0, fbin=None, pn_phase_tol=None, spline_degree=3)¶
Bases:
BaseRelativeBinningGeneralization of CBCLikelihood that implements computation of likelihood with the relative binning method (fast).
Subclassed by
ReferenceWaveformFinder.- Parameters:
- event_dataInstance of data.EventData
- waveform_generatorInstance of waveform.WaveformGenerator.
- par_dic_0dict
Parameters of the reference waveform, should be close to the maximum likelihood waveform. Keys should match waveform_generator.params.
- fbin1-d array or None
Array with edges of the frequency bins used for relative binning [Hz]. Alternatively, pass pn_phase_tol.
- pn_phase_tolfloat or None
Tolerance in the post-Newtonian phase [rad] used for defining frequency bins. Alternatively, pass fbin.
- spline_degreeint
Degree of the spline used to interpolate the ratio between waveform and reference waveform for relative binning.
Methods
Estimate local standard deviation of the matched-filter output at the time of the event for each detector.
Instantiate with help from a ReferenceWaveformFinder instance, which provides waveform_generator, event_data and par_dic_0 objects.
Return average frequency in Hz.
Return dictionary of ancillary information ("blob").
Return keyword arguments to reproduce the class instance.
Name of the module that defines the instance's class.
Return log-likelihood (float).
Return log likelihood using relative binning.
Return an array of length n_detectors with the values of (d|h) - (h|h)/2, no ASD-drift correction applied, using relative binning.
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.
Edges of the frequency bins for relative binning [Hz].
Dictionary with reference waveform parameters.
Parameters expected in par_dic for likelihood evaluation.
Tolerance in the post-Newtonian phase [rad] used for defining frequency bins.
Integer between 1 and 5, degree of the spline used to interpolate waveform ratios.
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.
- property fbin¶
Edges of the frequency bins for relative binning [Hz]. Setting this will automatically round them to fall in the FFT array, recompute the splines and summary data, and set
._pn_phase_toltoNoneto keep logs clean.
- classmethod from_reference_waveform_finder(reference_waveform_finder, approximant, fbin=None, pn_phase_tol=0.05, spline_degree=3, **kwargs)¶
Instantiate with help from a ReferenceWaveformFinder instance, which provides waveform_generator, event_data and par_dic_0 objects.
- Parameters:
- reference_waveform_finderlikelihood.ReferenceWaveformFinder
- approximantstr
Approximant name.
- fbin1-d array or None
Array with edges of the frequency bins used for relative binning [Hz]. Alternatively, pass pn_phase_tol.
- pn_phase_tolfloat or None
Tolerance in the post-Newtonian phase [rad] used for defining frequency bins. Alternatively, pass fbin.
- spline_degreeint
Degree of the spline used to interpolate the ratio between waveform and reference waveform for relative binning.
- **kwargs
Keyword arguments, in case a subclass needs them.
- Returns:
- Instance of
cls.
- Instance of
- 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_blob(metadata)¶
Return dictionary of ancillary information (“blob”). This will be appended to the posterior samples as extra columns.
- get_init_dict(**kwargs)¶
Return keyword arguments to reproduce the class instance.
- get_module_name()¶
Name of the module that defines the instance’s class.
- lnlike(par_dic)¶
Return log-likelihood (float). Mainly for backwards compatibility.
- lnlike_and_metadata(par_dic)¶
Return log likelihood using relative binning.
- lnlike_detectors_no_asd_drift(par_dic)¶
Return an array of length n_detectors with the values of (d|h) - (h|h)/2, no ASD-drift correction applied, using relative binning.
- Parameters:
- par_dicdict
Waveform parameters, keys should match
self.params.
- 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 par_dic_0¶
Dictionary with reference waveform parameters.
- 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.
- property pn_phase_tol¶
Tolerance in the post-Newtonian phase [rad] used for defining frequency bins. Setting this will recompute frequency bins such that across each frequency bin the change in the post-Newtonian waveform phase with respect to the fiducial waveform is bounded by pn_phase_tol [rad].
- 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.
- property spline_degree¶
Integer between 1 and 5, degree of the spline used to interpolate waveform ratios. Editing it will automatically recompute the splines and summary data.
- 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.