ml4gw.gw
Tools for manipulating raw gravitational waveforms and projecting them onto interferometer responses. Much of the projection code is an extension of the implementation made available in bilby. Specifically code from this module.
Functions
|
|
|
Compute the antenna pattern factors of a batch of waveforms as a function of the sky parameters of their sources as well as the detector tensors of the interferometers whose response is being calculated. |
|
Compute the SNRs of a batch of interferometer responses |
|
Compute the total SNR from a gravitational waveform from a network of interferometers. |
|
Compute the strain timeseries \(h(t)\) observed by a network of interferometers from the given polarization timeseries corresponding to gravitational waveforms from sources with the indicated sky parameters. |
|
|
|
For a given list of interferometer names, retrieve and concatenate the associated detector tensors and vertices of those interferometers. |
|
Compute the outer product of two batches of vectors |
|
|
|
Scale interferometer responses such that they have a desired SNR |
|
- ml4gw.gw.breathing(m, n)
- Return type:
Float[Tensor, 'batch space space']
- Parameters:
m (Float[Tensor, 'batch space'])
n (Float[Tensor, 'batch space'])
- ml4gw.gw.compute_antenna_responses(theta, psi, phi, detector_tensors, modes)
Compute the antenna pattern factors of a batch of waveforms as a function of the sky parameters of their sources as well as the detector tensors of the interferometers whose response is being calculated.
- Parameters:
theta (
Float[Tensor, 'batch']
) -- Angle of each source in radians relative to the celestial equatorpsi (
Float[Tensor, 'batch']
) -- Angle in radians between each source's natural polarization basis and the basis which has the 0th unit vector pointing along the celestial equatorphi (
Float[Tensor, 'batch']
) -- Angle in radians between each source's right ascension and the right ascension of the geocenterdetector_tensors (
Float[Tensor, 'num_ifos 3 3']
) -- Detector tensor for each of the interferometers for which a response is being calculated, stacked along the 0th axismodes (
List
[str
]) -- Which polarization modes to compute the response for
- Return type:
Float[Tensor, 'batch polarizations num_ifos']
- Returns:
- A tensor representing interferometer antenna pattern
factors for each of the polarizations of each of the waveforms, for each interferometer.
- ml4gw.gw.compute_ifo_snr(responses, psd, sample_rate, highpass=None, lowpass=None)
Compute the SNRs of a batch of interferometer responses
Compute the signal to noise ratio (SNR) of individual interferometer responses to gravitational waveforms with respect to a background PSD for each interferometer. The SNR of the \(i\) th waveform at the \(j\) th interferometer is computed as:
\[\rho_{ij} = 4 \int_{f_{\text{min}}}^{f_{\text{max}}} \frac{\tilde{h_{ij}}(f)\tilde{h_{ij}}^*(f)} {S_n^{(j)}(f)}df\]Where \(f_{\text{min}}\) is a minimum frequency denoted by
highpass
, \(f_{\text{max}}\) is the maximum frequency denoted bylowpass
, which defaults to the Nyquist frequency dictated bysample_rate
; \(\tilde{h}_{ij}\) and \(\tilde{h}_{ij}^*\) indicate the fourier transform of the \(i\) th waveform at the \(j\) th inteferometer and its complex conjugate, respectively; and \(S_n^{(j)}\) is the backround PSD at the \(j\) th interferometer.- Parameters:
responses (
Float[Tensor, 'batch num_ifos time']
) -- A batch of interferometer responses to a batch of raw gravitational waveformspsd (
Float[Tensor, 'num_ifos frequency']
) -- The one-sided power spectral density of the background noise at each interferometer to which a response inresponses
has been calculated. If 2D, each row ofpsd
will be assumed to be the background PSD for each channel of _every_ batch element inresponses
. If 3D, this should contain a background PSD for each channel of each element inresponses
, and therefore the first two dimensions ofpsd
andresponses
should match.sample_rate (
float
) -- The frequency at which the waveform responses timeseries have been sampled. Upon fourier transforming, should match the frequency resolution of the provided PSDs.highpass (
Union
[float
,Float[Tensor, 'frequency']
,None
]) -- The minimum frequency above which to compute the SNR. If a tensor is provided, it will be assumed to be a pre-computed mask used to 0-out low frequency components. If a float, it will be used to compute such a mask. If left asNone
, all frequencies up tolowpass
will contribute to the SNR calculation.lowpass (
Union
[float
,Float[Tensor, 'frequency']
,None
]) -- The maximum frequency below which to compute the SNR. If a tensor is provided, it will be assumed to be a pre-computed mask used to 0-out high frequency components. If a float, it will be used to compute such a mask. If left asNone
, all frequencies fromhighpass
up to the Nyquist freqyency will contribute to the SNR calculation.
- Return type:
Float[Tensor, 'batch num_ifos']
- Returns:
Batch of SNRs computed for each interferometer
- ml4gw.gw.compute_network_snr(responses, psd, sample_rate, highpass=None, lowpass=None)
Compute the total SNR from a gravitational waveform from a network of interferometers. The total SNR for the \(i\) th waveform is computed as
\[\rho_i = \sqrt{\sum_{j}^{N}\rho_{ij}^2}\]where \(\rho_{ij}\) is the SNR for the \(i\) th waveform at the \(j\) th interferometer in the network and \(N\) is the total number of interferometers.
- Parameters:
responses (
Float[Tensor, 'batch num_ifos time']
) -- A batch of interferometer responses to a batch of raw gravitational waveformsbackgrounds -- The one-sided power spectral density of the background noise at each interferometer to which a response in
responses
has been calculated. If 2D, each row ofpsd
will be assumed to be the background PSD for each channel of every batch element inresponses
. If 3D, this should contain a background PSD for each channel of each element inresponses
, and therefore the first two dimensions ofpsd
andresponses
should match.sample_rate (
float
) -- The frequency at which the waveform responses timeseries have been sampled. Upon fourier transforming, should match the frequency resolution of the provided PSDs.highpass (
Union
[float
,Float[Tensor, 'frequency']
,None
]) -- The minimum frequency above which to compute the SNR. If a tensor is provided, it will be assumed to be a pre-computed mask used to 0-out low frequency components. If a float, it will be used to compute such a mask. If left asNone
, all frequencies up tosample_rate / 2
will contribute to the SNR calculation.lowpass (
Union
[float
,Float[Tensor, 'frequency']
,None
]) -- The maximum frequency below which to compute the SNR. If a tensor is provided, it will be assumed to be a pre-computed mask used to 0-out high frequency components. If a float, it will be used to compute such a mask. If left asNone
, all frequencies fromhighpass
up to the Nyquist freqyency will contribute to the SNR calculation.psd (Float[Tensor, 'num_ifos frequency'])
- Return type:
Float[Tensor, 'batch']
- Returns:
Batch of SNRs for each waveform across the interferometer network
- ml4gw.gw.compute_observed_strain(dec, psi, phi, detector_tensors, detector_vertices, sample_rate, **polarizations)
Compute the strain timeseries \(h(t)\) observed by a network of interferometers from the given polarization timeseries corresponding to gravitational waveforms from sources with the indicated sky parameters.
- Parameters:
dec (
Float[Tensor, 'batch']
) -- Declination of each source in radians relative to the celestial northpsi (
Float[Tensor, 'batch']
) -- Angle in radians between each source's natural polarization basis and the basis which has the 0th unit vector pointing along the celestial equatorphi (
Float[Tensor, 'batch']
) -- Angle in radians between each source's right ascension and the right ascension of the geocenterdetector_tensors (
Float[Tensor, 'num_ifos 3 3']
) -- Detector tensor for each of the interferometers for which observed strain is being calculated, stacked along the 0th axisdetector_vertices (
Float[Tensor, 'num_ifos 3']
) -- Vertices for each interferometer's spatial location relative to the geocenter. Used to compute delay between the waveform observed at the geocenter and the one observed at the detector site. To avoid adding any delay between the two, reset your coordinates such that the desired interferometer is at(0., 0., 0.)
.sample_rate (
float
) -- Rate at which the polarization timeseries have been sampledpolarziations -- Timeseries for each waveform polarization which contributes to the interferometer response. Allowed polarizations are
cross
,plus
, andbreathing
.polarizations (Float[Tensor, 'batch time'])
- Return type:
Float[Tensor, 'batch num_ifos time']
- Returns:
Tensor representing the observed strain at each interferometer for each waveform.
- ml4gw.gw.cross(m, n)
- Return type:
Float[Tensor, 'batch space space']
- Parameters:
m (Float[Tensor, 'batch space'])
n (Float[Tensor, 'batch space'])
- ml4gw.gw.get_ifo_geometry(*ifos)
For a given list of interferometer names, retrieve and concatenate the associated detector tensors and vertices of those interferometers.
- Parameters:
ifos (
str
) -- Names of the interferometers whose geometry to retrieve- Return type:
Tuple
[Float[Tensor, 'num_ifos 3 3']
,Float[Tensor, 'num_ifos 3']
]- Returns:
A concatenation of the detector tensors of each interferometer A concatenation of the vertices of each interferometer
- ml4gw.gw.outer(x, y)
Compute the outer product of two batches of vectors
- Return type:
Float[Tensor, 'batch space space']
- Parameters:
x (Float[Tensor, 'batch space'])
y (Float[Tensor, 'batch space'])
- ml4gw.gw.plus(m, n)
- Return type:
Float[Tensor, 'batch space space']
- Parameters:
m (Float[Tensor, 'batch space'])
n (Float[Tensor, 'batch space'])
- ml4gw.gw.reweight_snrs(responses, target_snrs, psd, sample_rate, highpass=None, lowpass=None)
Scale interferometer responses such that they have a desired SNR
- Parameters:
responses (
Float[Tensor, 'batch num_ifos time']
) -- A batch of interferometer responses to a batch of raw gravitational waveformstarget_snrs (
Union
[float
,Float[Tensor, 'batch']
]) -- Either a tensor of desired SNRs for each waveform, or a single SNR to which all waveforms should be scaled.psd (
Float[Tensor, 'num_ifos frequency']
) -- The one-sided power spectral density of the background noise at each interferometer to which a response inresponses
has been calculated. If 2D, each row ofpsd
will be assumed to be the background PSD for each channel of every batch element inresponses
. If 3D, this should contain a background PSD for each channel of each element inresponses
, and therefore the first two dimensions ofpsd
andresponses
should match.sample_rate (
float
) -- The frequency at which the waveform responses timeseries have been sampled. Upon fourier transforming, should match the frequency resolution of the provided PSDs.highpass (
Union
[float
,Float[Tensor, 'frequency']
,None
]) -- The minimum frequency above which to compute the SNR. If a tensor is provided, it will be assumed to be a pre-computed mask used to 0-out low frequency components. If a float, it will be used to compute such a mask. If left asNone
, all frequencies up tosample_rate / 2
will contribute to the SNR calculation.lowpass (
Union
[float
,Float[Tensor, 'frequency']
,None
]) -- The maximum frequency below which to compute the SNR. If a tensor is provided, it will be assumed to be a pre-computed mask used to 0-out high frequency components. If a float, it will be used to compute such a mask. If left asNone
, all frequencies fromhighpass
up to the Nyquist freqyency will contribute to the SNR calculation.
- Return type:
Float[Tensor, 'batch num_ifos time']
- Returns:
Rescaled interferometer responses
- ml4gw.gw.shift_responses(responses, theta, phi, vertices, sample_rate)
- Return type:
Float[Tensor, 'batch num_ifos time']
- Parameters:
responses (Float[Tensor, 'batch num_ifos time'])
theta (Float[Tensor, 'batch'])
phi (Float[Tensor, 'batch'])
vertices (Float[Tensor, 'num_ifos 3'])
sample_rate (float)