Utilities
Alignment
- gwModels.utils.alignment.get_peak(t, func)[source]
Find the peak of a function via quadratic fit over 5 points closest to argmax.
- Parameters:
t (np.ndarray) – An array of times.
func (np.ndarray) – An array of function values.
- Returns:
(tpeak, fpeak)
- Return type:
- gwModels.utils.alignment.check_pi_rotation(h_dict)[source]
Checks whether a pi rotation is required in waveform mode data.
This function determines the phase factor required for each mode based on the phase of the h_l2m1 mode, applying a pi rotation for odd m modes if necessary.
Parameters: h_dict (dict): Dictionary of gravitational wave modes. Keys should be “h_l2m2”, “h_l2m1”, etc.
Returns: dict: Updated dictionary of gravitational wave modes after potential rotation.
- gwModels.utils.alignment.phase_align_dict(hdict)[source]
Aligns a waveform dictionary to ensure proper phases.
This function modifies the phases of the waveform modes to ensure that the initial phase of the (2,2) mode is zero and that the relative phases of higher modes are consistent.
- class gwModels.utils.alignment.AlignWFData(t_input, h_input, t_common=None)[source]
Bases:
objectClass to align a waveform such that the peak is at t=0 and the initial phase is zero.
This class also casts the waveform onto a different time grid if specified.
- t_input
Input time array.
- Type:
np.ndarray
- t_common
Target time grid on which waveform data should be cast.
- Type:
np.ndarray or None
Peak finding
- class gwModels.utils.compute_local_peaks.PeakFinderCrude(time, signal, dmin=1, dmax=1)[source]
Bases:
objectClass to find the peaks of a signal using a crude way
- class gwModels.utils.compute_local_peaks.PeakFinderScipy(time, signal, distance_btw_peaks=100)[source]
Bases:
objectClass to find the peaks of a signal using scipy
Waveform features
- gwModels.utils.features.get_amplitude(h)[source]
Computes amplitude of a given gravitational wave time-series.
- Parameters:
h (np.ndarray) – Waveform mode array.
- Returns:
Amplitude A = abs(h).
- Return type:
np.ndarray
- gwModels.utils.features.get_phase(h)[source]
Computes phase of a given gravitational wave time-series.
- Parameters:
h (np.ndarray) – Waveform mode array.
- Returns:
Phase phi = arg(h).
- Return type:
np.ndarray
Metrics
- gwModels.utils.metrics.mathcalE_error(h1, h2)[source]
Computes the time-domain error between two waveforms.
Calculates the error according to Equation 21 of https://arxiv.org/pdf/1701.00550.pdf by normalizing the difference between the two waveforms.
- Parameters:
h1 (np.ndarray) – Reference waveform in the time domain.
h2 (np.ndarray) – Comparison waveform in the time domain.
- Returns:
Normalized error for each time sample.
- Return type:
np.ndarray
- gwModels.utils.metrics.simple_mismatch(h1, h2)[source]
Computes a simple mismatch between two waveforms.
- The mismatch is defined as 1 minus the normalized inner product:
MM = 1 - Re(<h1, h2>) / (||h1|| * ||h2||)
- Parameters:
h1 (np.ndarray) – First waveform in the time domain.
h2 (np.ndarray) – Second waveform in the time domain.
- Returns:
Mismatch value. Returns NaN if either waveform has zero norm.
- Return type: