pygwb.simulator.Simulator

class pygwb.simulator.Simulator(interferometers, N_segments, duration, sampling_frequency, intensity_GW=None, injection_dict=None, start_time=0.0, no_noise=False, orf_polarization='tensor', seed=None, continuous=False)[source]

Bases: object

__init__(interferometers, N_segments, duration, sampling_frequency, intensity_GW=None, injection_dict=None, start_time=0.0, no_noise=False, orf_polarization='tensor', seed=None, continuous=False)[source]

Create an instance of the the simulator class.

Parameters:
  • interferometers (list) – List of bilby interferometer objects.

  • intensity_GW (gwpy.frequencyseries.FrequencySeries, optional) – A gwpy.frequencyseries.FrequencySeries containing the desired strain power spectrum which needs to be simulated. Defaults to None (then injection_dict should be passed).

  • injection_dict (dict, optional) – Dictionary containing the parameters of CBC injections. Defaults to None (then intensity_GW should be passed).

  • N_segments (int) – Number of segments that needs to be generated for the simulation.

  • duration (float) – Duration of a simulated data segment in seconds.

  • sampling_frequency (float) – Sampling frequency in Hz.

  • start_time (float, optional) – Start time (in seconds) of the simulation. Defaults to 0.

  • no_noise (boolean, optional) – Flag that sets the noise_PSDs to 0. Defaults to False.

  • seed (int, optional) – Seed to use for random data generation. Defaults to None.

  • continuous (boolean, optional) – Flag to generate continuous segments. If True, a seed must also be provided. Defaults to False.

Notes

A range of spectral indices (from -3 to 3) was tested. However, one should be careful for spectral indices outside of this range, as the splicing procedure implemented in this module is known to introduce a bias for some values of the spectral index (usually large negative numbers).

__call__(*args, **kwargs)

Call self as a function.

Methods

__init__(interferometers, N_segments, ...[, ...])

Create an instance of the the simulator class.

compute_eigval_eigvec(C)

Function to compute the eigenvalues and eigenvectors of the covariance matrix corresponding to a stochastic background in the various detectors.

covariance_matrix(flag)

Function to compute the covariance matrix corresponding to a stochastic background in the various detectors.

generate_data([data_start])

Function that simulates an isotropic stochastic background given the input parameters.

generate_freq_domain_data()

Function that generates the uncorrelated frequency domain data with random phases for the stochastic background.

get_data_for_interferometers()

Get a data dictionary for interferometers.

get_frequencies()

Computes an array of frequencies given sampling frequency and duration of the simulator object.

get_noise_PSD_array()

Function that gets the noise PSD array of all the interferometers.

get_orf([polarization])

Function that returns a list containing the overlap reduction functions for all the baselines in self.baselines.

inject_CBC()

This function uses the provided dictionary of injection parameters to simulate a background of CBC sources.

orf_to_array()

Function that converts the list of overlap reduction functions (ORFs) into an array to facilitate the correct implementation when computing the covariance matrix.

simulate(flag)

Function that simulates the data corresponding to an isotropic stochastic background.

splice_segments(segments)

This function splices together the various segments to prevent artifacts related to the periodicity that can arise from inverse Fourier transforms.

transform_to_correlated_data(z, C)

Function that transforms the uncorrelated stochastic background simulated data, to correlated data.

compute_eigval_eigvec(C)[source]

Function to compute the eigenvalues and eigenvectors of the covariance matrix corresponding to a stochastic background in the various detectors.

Parameters:

C (array_like) – Covariance matrix corresponding to a stochastic background in the various detectors. Dimensions are Nd x Nd x Nf, where Nd is the number of detectors and Nf is the number of frequencies.

Returns:
eigval: array_like

Array of diagonal matrices containing the eigenvalues of the covariance matrix C.

eigvec: array_like

Array of matrices containing the eigenvectors of the covariance matrix C.

See also

numpy.linalg.eig

More information here.

covariance_matrix(flag)[source]

Function to compute the covariance matrix corresponding to a stochastic background in the various detectors.

Parameters:

flag (str) – Either flagged as “noise” or “signal”, to allow for different generation of covariance matrix in both cases.

Returns:
C: array_like

Covariance matrix corresponding to a stochastic background in the various detectors. Dimensions are Nd x Nd x Nf, where Nd is the number of detectors and Nf is the number of frequencies.

generate_data(data_start=None)[source]

Function that simulates an isotropic stochastic background given the input parameters. The data is simulated and spliced together to prevent periodicity artifacts related to IFFTs.

Parameters:

data_start (float, optional) – Start time of the data that is being generated. Defaults to None.

Returns:
data: array_like

An array of size Nd (number of detectors) with gwpy TimeSeries with the data containing the simulated isotropic stochastic background.

See also

gwpy.timeseries.TimeSeries

More information here.

generate_freq_domain_data()[source]

Function that generates the uncorrelated frequency domain data with random phases for the stochastic background.

Returns:
z: array_like

Array of size Nf x Nd containing uncorrelated frequency domain data.

See also

numpy.random.randn

More information here.

get_data_for_interferometers()[source]

Get a data dictionary for interferometers.

Returns:
interferometer_data: dict

A dictionary with the simulated data for the interferometers.

See also

pygwb.simulator.generate_data
gwpy.timeseries.TimeSeries

More information here.

get_frequencies()[source]

Computes an array of frequencies given sampling frequency and duration of the simulator object.

Returns:
frequencies: array_like

Array containing the computed frequencies.

See also

bilby.core.utils.create_frequency_series

More information here.

get_noise_PSD_array()[source]

Function that gets the noise PSD array of all the interferometers.

Returns:
noise_PSDs_array: array_like

Array containing the noise PSD arrays for all interferometers in self.interferometers.

get_orf(polarization='tensor')[source]

Function that returns a list containing the overlap reduction functions for all the baselines in self.baselines.

Parameters:

polarization (str, optional) – Polarization for which to generate the overlap reduction function. Defaults to tensor.

Returns:
orf_list: list

List containing the overlap reduction functions for all the baselines in self.baselines.

See also

pygwb.baseline.overlap_reduction_function
inject_CBC()[source]

This function uses the provided dictionary of injection parameters to simulate a background of CBC sources.

Returns:
data: array_like

Array of size Nd x (N_segments*N_samples_per_segment) containing the simulated data corresponding to a background of CBC sources for each of the detectors, where Nd is the number of detectors.

See also

bilby.gw.WaveformGenerator

More information here.

gwpy.timeseries.TimeSeries

More information here.

orf_to_array()[source]

Function that converts the list of overlap reduction functions (ORFs) into an array to facilitate the correct implementation when computing the covariance matrix.

Returns:
orf_array: array_like

Array of shape Nd x Nd containing the orfs, where Nd is the number of detectors. The convention used for consistency with the remainder of the simulation is as follows. ORFs are only present in the off-diagonal slots in the array. Only the part below the diagonal is filled, after which this is copied to the upper part by transposing and summing. The array is filled by starting from the first free slot below the diagonal, from left to right, until the diagonal is reached, after which the line below in the array is filled analogously and so on.

See also

pygwb.baseline.overlap_reduction_function
simulate(flag)[source]

Function that simulates the data corresponding to an isotropic stochastic background.

Parameters:

flag (str) – Either flagged as “noise” or “signal”, to allow for different generation of covariance matrix in both cases.

Returns:
y: array_like

Array of size Nd x 2*(N_segments+1) x N_samples_per_segment containing the various segments with the simulated data.

See also

numpy.fft.ifft

More information here.

splice_segments(segments)[source]

This function splices together the various segments to prevent artifacts related to the periodicity that can arise from inverse Fourier transforms.

Parameters:

segments (array_like) – Array of size Nd x (2*N_segments+1) x N_samples_per_segment containing the various segments with the simulated data that need to be spliced together, where Nd is the number of detectors.

Returns:
data: array_like

Array of size Nd x (N_segments*N_samples_per_segment) containing the simulated data corresponding to an isotropic stochastic background for each of the detectors, where Nd is the number of detectors.

Notes

A range of spectral indices (from -3 to 3) was tested for the GW power spectrum to inject. However, one should be careful for spectral indices outside of this range, as the splicing procedure implemented here is known to introduce a bias for some values of the spectral index (usually large negative numbers).

transform_to_correlated_data(z, C)[source]

Function that transforms the uncorrelated stochastic background simulated data, to correlated data.

Parameters:
  • z (array_like) – Array containing the uncorrelated data with random phase.

  • C (array_like) – Array of size Nd x Nd x Nf representing the covariance matrices between detectors for a desired stochastic background, where Nd is the number of detectors and Nf is the number of frequencies.

Returns:
x: array_like

Array of size Nf x Nd, containing the correlated stochastic background data.

See also

numpy.einsum

Used for efficient summation over specific indices. More information here.