gwsnr.numba.njit_functions

Numba-compiled helper functions for gravitational wave signal-to-noise ratio calculations.

This module provides optimized numerical functions for gravitational wave data analysis, including chirp time calculations, antenna response computations, polarization tensors, coordinate transformations, and noise-weighted inner products. All functions are compiled with Numba’s @njit decorator for high-performance computation, with parallel processing support using prange for multi-threaded execution where applicable.

Module Contents

Functions

findchirp_chirptime(m1, m2, fmin)

Time taken from f_min to f_lso (last stable orbit). 3.5PN in fourier phase considered.

einsum1(m, n)

Function to calculate einsum of two 3x1 vectors

einsum2(m, n)

Function to calculate einsum of two 3x3 matrices

gps_to_gmst(gps_time)

Function to convert gps time to greenwich mean sidereal time

ra_dec_to_theta_phi(ra, dec, gmst)

Function to convert ra and dec to theta and phi

get_polarization_tensor_plus(ra, dec, time, psi)

Function to calculate the polarization tensor

get_polarization_tensor_cross(ra, dec, time, psi)

Function to calculate the polarization tensor

antenna_response_plus(ra, dec, time, psi, detector_tensor)

Function to calculate the antenna response

antenna_response_cross(ra, dec, time, psi, detector_tensor)

Function to calculate the antenna response

antenna_response_array(ra, dec, time, psi, detector_tensor)

Function to calculate the antenna response in array form.

effective_distance(luminosity_distance, theta_jn, ra, ...)

Function to calculate the effective distance of the source.

effective_distance_array(luminosity_distance, ...)

Function to calculate the effective distance of the source in array form.

noise_weighted_inner_product(signal1, signal2, psd, ...)

Noise weighted inner product of two time series data sets.

linear_interpolator(xnew_array, y_array, x_array[, ...])

Linear interpolator for 1D data.

Attributes

Gamma

Pi

MTSUN_SI

gwsnr.numba.njit_functions.Gamma = '0.5772156649015329'[source]
gwsnr.numba.njit_functions.Pi[source]
gwsnr.numba.njit_functions.MTSUN_SI = '4.925491025543576e-06'[source]
gwsnr.numba.njit_functions.findchirp_chirptime(m1, m2, fmin)[source]

Time taken from f_min to f_lso (last stable orbit). 3.5PN in fourier phase considered.

Parameters:
m1float

Mass of the first body in solar masses.

m2float

Mass of the second body in solar masses.

fminfloat

Lower frequency cutoff.

Returns:
chirp_timefloat

Time taken from f_min to f_lso (last stable orbit frequency).

gwsnr.numba.njit_functions.einsum1(m, n)[source]

Function to calculate einsum of two 3x1 vectors

Parameters:
mnumpy.ndarray

3x1 vector.

nnumpy.ndarray

3x1 vector.

Returns:
ansnumpy.ndarray

3x3 matrix.

gwsnr.numba.njit_functions.einsum2(m, n)[source]

Function to calculate einsum of two 3x3 matrices

Parameters:
mnumpy.ndarray

3x3 matrix.

nnumpy.ndarray

3x3 matrix.

Returns:
ansnumpy.ndarray

3x3 matrix.

gwsnr.numba.njit_functions.gps_to_gmst(gps_time)[source]

Function to convert gps time to greenwich mean sidereal time

Parameters:
gps_timefloat

GPS time in seconds.

Returns:
gmstfloat

Greenwich mean sidereal time in radians.

gwsnr.numba.njit_functions.ra_dec_to_theta_phi(ra, dec, gmst)[source]

Function to convert ra and dec to theta and phi

Parameters:
rafloat

Right ascension of the source in radians.

decfloat

Declination of the source in radians.

gmstfloat

Greenwich mean sidereal time in radians.

Returns:
thetafloat

Polar angle in radians.

phifloat

Azimuthal angle in radians.

gwsnr.numba.njit_functions.get_polarization_tensor_plus(ra, dec, time, psi)[source]

Function to calculate the polarization tensor

Parameters:
rafloat

Right ascension of the source in radians.

decfloat

Declination of the source in radians.

timefloat

GPS time of the source.

psifloat

Polarization angle of the source.

Returns:
polarization_tensor: numpy.ndarray

Polarization tensor of the detector.

gwsnr.numba.njit_functions.get_polarization_tensor_cross(ra, dec, time, psi)[source]

Function to calculate the polarization tensor

Parameters:
rafloat

Right ascension of the source in radians.

decfloat

Declination of the source in radians.

timefloat

GPS time of the source.

psifloat

Polarization angle of the source.

Returns:
polarization_tensor: numpy.ndarray

Polarization tensor of the detector.

gwsnr.numba.njit_functions.antenna_response_plus(ra, dec, time, psi, detector_tensor)[source]

Function to calculate the antenna response

Parameters:
rafloat

Right ascension of the source in radians.

decfloat

Declination of the source in radians.

timefloat

GPS time of the source.

psifloat

Polarization angle of the source.

detector_tensorarray-like

Detector tensor for the detector (3x3 matrix)

modestr

Mode of the polarization. Default is ‘plus’.

Returns:
antenna_response: float

Antenna response of the detector.

gwsnr.numba.njit_functions.antenna_response_cross(ra, dec, time, psi, detector_tensor)[source]

Function to calculate the antenna response

Parameters:
rafloat

Right ascension of the source in radians.

decfloat

Declination of the source in radians.

timefloat

GPS time of the source.

psifloat

Polarization angle of the source.

detector_tensorarray-like

Detector tensor for the detector (3x3 matrix)

modestr

Mode of the polarization. Default is ‘plus’.

Returns:
antenna_response: float

Antenna response of the detector.

gwsnr.numba.njit_functions.antenna_response_array(ra, dec, time, psi, detector_tensor)[source]

Function to calculate the antenna response in array form.

Parameters:
ranumpy.ndarray

Right ascension of the source in radians.

decnumpy.ndarray

Declination of the source in radians.

timenumpy.ndarray

GPS time of the source.

psinumpy.ndarray

Polarization angle of the source.

detector_tensorarray-like

Detector tensor for the multiple detectors (nx3x3 matrix), where n is the number of detectors.

Returns:
antenna_response: numpy.ndarray

Antenna response of the detector. Shape is (n, len(ra)).

gwsnr.numba.njit_functions.effective_distance(luminosity_distance, theta_jn, ra, dec, geocent_time, psi, detector_tensor)[source]

Function to calculate the effective distance of the source.

Parameters:
luminosity_distancefloat

Luminosity distance of the source in Mpc.

theta_jnfloat

Angle between the line of sight and the orbital angular momentum vector.

rafloat

Right ascension of the source in radians.

decfloat

Declination of the source in radians.

timefloat

GPS time of the source.

psifloat

Polarization angle of the source.

detector_tensorarray-like

Detector tensor for the detector (3x3 matrix).

Returns:
effective_distance: float

Effective distance of the source in Mpc.

gwsnr.numba.njit_functions.effective_distance_array(luminosity_distance, theta_jn, ra, dec, geocent_time, psi, detector_tensor)[source]

Function to calculate the effective distance of the source in array form.

Parameters:
luminosity_distancenumpy.ndarray

Luminosity distance of the source in Mpc.

theta_jnnumpy.ndarray

Angle between the line of sight and the orbital angular momentum vector.

ranumpy.ndarray

Right ascension of the source in radians.

decnumpy.ndarray

Declination of the source in radians.

timenumpy.ndarray

GPS time of the source.

psinumpy.ndarray

Polarization angle of the source.

detector_tensorarray-like

Detector tensor for the multiple detectors (nx3x3 matrix), where n is the number of detectors.

Returns:
effective_distance: numpy.ndarray

Effective distance of the source in Mpc. Shape is (n, len(ra)).

gwsnr.numba.njit_functions.noise_weighted_inner_product(signal1, signal2, psd, duration)[source]

Noise weighted inner product of two time series data sets.

Parameters:
signal1: `numpy.ndarray` or `float`

First series data set.

signal2: `numpy.ndarray` or `float`

Second series data set.

psd: `numpy.ndarray` or `float`

Power spectral density of the detector.

duration: `float`

Duration of the data.

gwsnr.numba.njit_functions.linear_interpolator(xnew_array, y_array, x_array, fill_value=np.inf)[source]

Linear interpolator for 1D data.

Parameters:
xnew_arraynumpy.ndarray

New x values to interpolate.

y_arraynumpy.ndarray

y values corresponding to the x_array.

x_arraynumpy.ndarray

Original x values.

Returns:
resultnumpy.ndarray

Interpolated y values at xnew_array.