gwadama.tat#

tat.py

Time analysis toolkit.

gwadama.tat.find_merger(h: ndarray) int[source]#

Estimate the index position of the merger in the given strain.

This function provides a rough estimate of the merger index position by locating the maximum of the absolute amplitude of the gravitational wave signal in the time domain. It assumes that the merger roughly corresponds to this peak, which holds for certain clean or high-SNR simulated CBC gravitational waves.

Warning:

This function may be replaced in the near future by a more formal estimator with a better model, such as a Gaussian fit for binary mergers.

Caution:

This is a very ad-hoc method and may not be accurate for all datasets, especially depending on the sensitivity of the detector. This method assumes that the peak amplitude in the time domain corresponds closely to the merger, which may not hold for lower-SNR signals or noisy data.

Parameters:
hnp.ndarray

The gravitational wave strain data.

Returns:
int

The index of the estimated merger position in the strain data.

gwadama.tat.find_time_origin(times: ndarray) int[source]#

Find the index position of the origin of a time array.

It is just a shortcut for np.argmin(np.abs(times)).

Parameters:
timesNDArray

Time array.

Returns:
_int

Index position of the time origin (0).

gwadama.tat.gen_time_array(t0, t1, sr)[source]#

Generate a time array with constant sampling rate.

Extension of numpy.arange which takes care of the case when an extra sample is produced due to round-off errors. When this happens, the extra sample is cut off.

Parameters:
t0, t1: float

Initial and final times of the array: [t0, t1).

sr: int

Sample rate.

length: int

Length of the final time array in samples. If due to round-off errors the length of the array is longer, it will be adjusted.

Returns:
times: NDArray

Time array.

gwadama.tat.pad_time_array(times: ndarray, pad: int | tuple) ndarray[source]#

Extend a time array by ‘pad’ number of samples.

Parameters:
times: NDArray

Time array.

pad: int | tuple

If int, number of samples to add on both sides. If tuple, number of samples to add on each side.

Returns:
NDArray

Padded time array.

Notes

  • Computes again the entire time array.

  • Due to round-off errors some intermediate time values might be slightly different.

gwadama.tat.resample(strain: ndarray, time: ndarray | int, sample_rate: int, full_output=True) tuple[ndarray, int, int][source]#

Resample a single strain in time domain.

Resample strain’s sampling rate using an interpolation in the time domain for upscalling to a constant rate, and then decimate it to the target rate.

The upscaled sample rate is chosen as the minimum common multiple between the next integer value of the maximum sampling rate found in the original strain, and the target sample rate.

Parameters:
strain: 1d-array

Only one strain.

time: 1d-array | int | float

Time points. If an Int or Float is given, it is interpreted as the former sampling rate, and assumed to be constant.

sample_rate: int

Target sample rate. NOTE: It cannot be fractional.

full_output: bool, optional

If True, also returns the new time points, the upscaled sampling rate, and the factor down.

Returns:
strain: 1d-array

Strain at the new sampling rate.

time: 1d-array, optional

New time points.

sr_up: int, optional

Upscaled sample rate.

factor_down: int, optional

Factor at which the signal is decimated after the upscalling.

gwadama.tat.shrink_time_array(times: ndarray, unpad: int) ndarray[source]#

Shrink a time array on both sides by ‘unpad’ number of samples.

Notes

  • Computes again the entire time array.

  • Due to round-off errors some intermediate time values might be slightly different.