ligo.em_bright module

Module containing tools for EM-Bright classification of compact binaries using trained supervised classifier

ligo.em_bright.get_redshifts(distances, N=10000)[source]

Compute redshift using the Planck15 cosmology.

Parameters
  • distances (float or numpy.ndarray) – distance(s) in Mpc

  • N (int, optional) – Number of steps for the computation of the interpolation function

Example

>>> distances = np.linspace(10, 100, 10)
>>> em_bright.get_redshifts(distances)
array([0.00225566, 0.00450357, 0.00674384, 0.00897655,
       0.01120181, 0.0134197 , 0.01563032, 0.01783375
       0.02003009, 0.02221941])

Notes

This function accepts HDF5 posterior samples file and computes redshift by interpolating the distance-redshift relation.

ligo.em_bright.source_classification(m1, m2, chi1, chi2, snr, ns_classifier=None, emb_classifier=None)[source]

Computes HasNS and HasRemnant probabilities from point mass, spin and signal to noise ratio estimates.

Parameters
  • m1 (float) – primary mass

  • m2 (float) – secondary mass

  • chi1 (float) – dimensionless primary spin

  • chi2 (float) – dimensionless secondary spin

  • snr (float) – signal to noise ratio of the signal

  • ns_classifier (object, optional) – pickled object for NS classification

  • emb_classifier (object, optional) – pickled object for EM brightness classification

Returns

(P_NS, P_EMB) predicted values.

Return type

tuple

Notes

By default the classifiers are trained using the KNearestNeighbor algorithm from scikit-learn, data is used to make predictions. Custom ns_classifier, emb_classifier can be supplied so long as they provide predict_proba method and the feature set is [[mass1, mass2, spin1z, spin2z, snr]].

Examples

>>> from ligo import em_bright
>>> em_bright.source_classification(2.0 ,1.0 ,0. ,0. ,10.0)
(1.0, 1.0)
ligo.em_bright.source_classification_pe(posterior_samples_file, hdf5=True, threshold=3.0, sourceframe=True)[source]

Compute HasNS and HasRemnant probabilities from posterior samples.

Parameters
  • posterior_samples_file (str) – Posterior samples file

  • hdf5 (bool, optional) – Supply when not using HDF5 format

  • threshold (float, optional) – Maximum neutron star mass for HasNS computation

  • sourceframe (bool, optional) – Supply to use detector frame quantities

Returns

(P_NS, P_EMB) predicted values.

Return type

tuple

Examples

>>> from ligo import em_bright
>>> em_bright.source_classification_pe('posterior_V1H1L1_1240327333.3365-0.hdf5')
(1.0, 0.9616727412238634)
>>> em_bright.source_classification_pe('posterior_samples_online.dat', hdf5=False)
(0.0, 0.0)