Data / Residual / Signal Container

class lisatools.datacontainer.DataResidualArray(data_res_in, dt=None, f_arr=None, df=None, **kwargs)[source]

Bases: object

Container to hold Data, residual, or template information.

This class abstracts the connection with the sensitivity matrices to make this analysis as generic as possible for the user frontend, while handling special computations in the backend.

Parameters:
  • data_res_in (Union[List[ndarray], ndarray, DataResidualArray]) – Data, residual, or template input information. Can be a list, numpy array or another DataResidualArray.

  • dt (Optional[float], default: None) – Timestep in seconds.

  • f_arr (Optional[ndarray], default: None) – Frequency array.

  • df (Optional[float], default: None) – Delta f in frequency domain.

  • **kwargs (dict) – For future compatibility.

property init_kwargs: dict

Initial dt, df, f_arr

property fmax

Maximum frequency.

property f_arr

Frequency array.

property dt

Time step in seconds.

property Tobs

Observation time in seconds

property df

Delta f in the frequency domain.

property frequency_arr: ndarray

Frequency array

property data_res_arr: ndarray

Actual data residual array

property ndim: int

Number of dimensions in the data_res_arr.

flatten()[source]

Flatten the data_res_arr.

Return type:

ndarray

property shape: tuple

Shape of data_res_arr.

loglog(ax=None, fig=None, inds=None, char_strain=False, **kwargs)[source]

Produce a log-log plot of the data.

Parameters:
  • ax (Union[List[Axes], Axes, None], default: None) – Matplotlib Axes objects to add plots. Either a list of Axes objects or a single Axes object.

  • fig (Optional[Figure], default: None) – Matplotlib figure object.

  • inds (Union[List[int], int, None], default: None) – Integer index to select out which data to add to a single access. A list can be provided if ax is a list. They must be the same length.

  • char_strain (Optional[bool], default: False) – If True return plot in characteristic strain representation.

  • **kwargs (dict) – Keyword arguments to be passed to loglog function in matplotlib.

Return type:

Tuple[Figure, Axes]

Returns:

Matplotlib figure and axes objects in a 2-tuple.

property char_strain: ndarray

Characteristic strain representation of the data.

Analysis Container

class lisatools.analysiscontainer.AnalysisContainer(data_res_arr, sens_mat, signal_gen=None)[source]

Bases: object

Combinatorial container that combines sensitivity and data information.

Parameters:
  • data_res_arr (DataResidualArray) – Data / Residual / Signal array.

  • sens_mat (SensitivityMatrix) – Sensitivity information.

  • signal_gen (Optional[callable], default: None) – Callable object that takes information through *args and **kwargs and generates a signal in the proper channel setup employed in data_res_arr and sens_mat.

property data_res_arr: DataResidualArray

Data information.

property sens_mat: SensitivityMatrix

Sensitivity information.

property signal_gen: callable

Signal generator.

loglog()[source]

Produce loglog plot of both source and sensitivity information.

Return type:

Tuple[Figure, Axes]

Returns:

Matplotlib figure and axes object in a 2-tuple.

inner_product(**kwargs)[source]

Return the inner product of the current set of information

Parameters:

**kwargs (dict) – Inner product keyword arguments.

Return type:

float | complex

Returns:

Inner product value.

snr(**kwargs)[source]

Return the SNR of the current set of information

Parameters:

**kwargs (dict) – Inner product keyword arguments.

Return type:

float

Returns:

SNR value.

template_inner_product(template, **kwargs)[source]

Calculate the inner product of a template with the data.

Parameters:
Return type:

float | complex

Returns:

Inner product value.

template_snr(template, phase_maximize=False, **kwargs)[source]

Calculate the SNR of a template, both optimal and detected.

Parameters:
Return type:

Tuple[float, float]

Returns:

(optimal snr, detected snr).

template_likelihood(template, include_psd_info=False, phase_maximize=False, **kwargs)[source]

Calculate the Likelihood of a template against the data.

Parameters:
Return type:

float

Returns:

Likelihood value.

likelihood(source_only=False, noise_only=False, **kwargs)[source]

Return the likelihood of the current arangement.

Parameters:
  • source_only (bool, default: False) – If True return the source-only Likelihood.

  • noise_only (bool, default: False) – If True, return the noise part of the Likelihood alone.

  • **kwargs (dict) – Keyword arguments to pass to lisatools.diagnostic.inner_product().

Return type:

float | complex

Returns:

Likelihood value.

calculate_signal_likelihood(*args, source_only=False, waveform_kwargs={}, data_res_arr_kwargs={}, **kwargs)[source]

Return the likelihood of a generated signal with the data.

Parameters:
  • params – Arguments to waveform generating function. Must include parameters.

  • source_only (bool, default: False) – If True return the source-only Likelihood (leave out noise part).

  • waveform_kwargs (Optional[dict], default: {}) – Keyword arguments to pass to waveform generator.

  • data_res_arr_kwargs (Optional[dict], default: {}) – Keyword arguments for instantiation of DataResidualArray. This can be used if any transforms are desired prior to the Likelihood computation.

  • **kwargs (dict) – Keyword arguments to pass to lisatools.diagnostic.inner_product()

Return type:

float | complex

Returns:

Likelihood value.

calculate_signal_inner_product(*args, source_only=False, waveform_kwargs={}, data_res_arr_kwargs={}, **kwargs)[source]

Return the inner product of a generated signal with the data.

Parameters:
  • *args (Any) – Arguments to waveform generating function. Must include parameters.

  • source_only (bool, default: False) – If True return the source-only Likelihood (leave out noise part).

  • waveform_kwargs (Optional[dict], default: {}) – Keyword arguments to pass to waveform generator.

  • data_res_arr_kwargs (Optional[dict], default: {}) – Keyword arguments for instantiation of DataResidualArray. This can be used if any transforms are desired prior to the Likelihood computation.

  • **kwargs (dict) – Keyword arguments to pass to lisatools.diagnostic.inner_product()

Return type:

float | complex

Returns:

Inner product value.

calculate_signal_snr(*args, source_only=False, waveform_kwargs={}, data_res_arr_kwargs={}, **kwargs)[source]

Return the SNR of a generated signal with the data.

Parameters:
  • *args (Any) – Arguments to waveform generating function. Must include parameters.

  • source_only (bool, default: False) – If True return the source-only Likelihood (leave out noise part).

  • waveform_kwargs (Optional[dict], default: {}) – Keyword arguments to pass to waveform generator.

  • data_res_arr_kwargs (Optional[dict], default: {}) – Keyword arguments for instantiation of DataResidualArray. This can be used if any transforms are desired prior to the Likelihood computation.

  • **kwargs (dict) – Keyword arguments to pass to lisatools.diagnostic.inner_product()

Return type:

Tuple[float, float]

Returns:

Snr values (optimal, detected).

eryn_likelihood_function(x, *args, **kwargs)[source]

Likelihood function for Eryn sampler.

This function is not vectorized.

signal_gen must be set to use this function.

Parameters:
  • x (ndarray | list | tuple) – Parameters. Can be 1D list, tuple, array or 2D array. If a 2D array is input, the computation is done serially.

  • *args (Any) – Likelihood args.

  • **kwargs (Any) – Likelihood kwargs.

Return type:

ndarray | float

Returns:

Likelihood value(s).