cogwheel.waveform.WaveformGenerator

class cogwheel.waveform.WaveformGenerator(detector_names, tgps, tcoarse, approximant, harmonic_modes=None, disable_precession=False, n_cached_waveforms=1, lalsimulation_commands=())

Bases: JSONMixin

Class that provides methods for generating frequency domain waveforms, in terms of (hplus, hcross) or projected onto detectors.

“Fast” and “slow” parameters are distinguished: the last waveform calls are cached and can be computed fast when only fast parameters are changed. The attribute .n_cached_waveforms can be used to control how many waveform calls to save in the cache. The boolean attribute .disable_precession can be set to ignore inplane spins.

Methods

create_lal_dict

Return a LAL dict object per self.lalsimulation_commands.

from_event_data

Constructor that takes detector_names, tgps and tcoarse from an instance of data.EventData.

get_hplus_hcross

Return hplus, hcross waveform strain.

get_hplus_hcross_at_detectors

Return plus and cross polarizations with time shifts applied (but no fplus, fcross).

get_init_dict

Return dictionary with keyword arguments to __init__.

get_m_mprime_inds

Return two lists of integers, these zipped are pairs (i, j) of indices with j >= i that run through the number of m modes.

get_module_name

Name of the module that defines the instance's class.

get_strain_at_detectors

Get strain measurable at detectors.

reinstantiate

Return a new instance of the class, possibly updating init_kwargs.

to_json

Write class instance to json file.

Attributes

approximant

String with waveform approximant name.

fast_params

harmonic_modes

List of (l, m) pairs.

lalsimulation_commands

Tuple of (key, value) where key is the name of a lalsimulation function and value is its second argument, after lal_dic.

m_arr

Int array of m harmonic mode numbers.

n_cached_waveforms

Nonnegative integer, number of cached waveforms.

params

polarization_params

slow_params

subclass_registry

property approximant

String with waveform approximant name.

create_lal_dict()

Return a LAL dict object per self.lalsimulation_commands.

classmethod from_event_data(event_data, approximant, harmonic_modes=None, disable_precession=False, n_cached_waveforms=1, lalsimulation_commands=())

Constructor that takes detector_names, tgps and tcoarse from an instance of data.EventData.

get_hplus_hcross(f, waveform_par_dic, by_m=False)

Return hplus, hcross waveform strain.

Note: inplane spins will be zeroized if self.disable_precession

is True.

Parameters:
f1d array of frequencies [Hz]
waveform_par_dicdictionary per

WaveformGenerator._waveform_params.

by_mbool, whether to return harmonic modes separately by m (l

summed over) or all modes already summed over.

Returns:
numpy.ndarray

(hplus, hcross), of shape (2, len(f)) if by_m is False, or (n_m, 2, len(f)) if by_m is True, where n_m is the number of harmonic modes with different |m|.

get_hplus_hcross_at_detectors(f, par_dic, by_m=False)

Return plus and cross polarizations with time shifts applied (but no fplus, fcross).

Parameters:
f: 1d array of frequencies [Hz]
par_dic: parameter dictionary per `WaveformGenerator.params`.
by_m: bool, whether to return waveform separated by `m`

harmonic mode (summed over l), or already summed.

Returns:
Array of shape (n_m?, 2, n_detectors, n_frequencies) with hplus,
hcross at detector, n_m is there only if by_m=True.
get_init_dict(**kwargs)

Return dictionary with keyword arguments to __init__.

Only works if the class stores its init parameters as attributes with the same names. Otherwise, the subclass should override this method.

Parameters:
**kwargs

Allows to manually override some keys. The remaining ones will be read from the instance’s attributes. All keywords must be in the __init__ signature. It’s mostly here to facilitate overriding by subclasses.

get_m_mprime_inds()

Return two lists of integers, these zipped are pairs (i, j) of indices with j >= i that run through the number of m modes.

get_module_name()

Name of the module that defines the instance’s class.

get_strain_at_detectors(f, par_dic, by_m=False)

Get strain measurable at detectors.

Parameters:
f: 1d array of frequencies [Hz]
par_dic: parameter dictionary per `WaveformGenerator.params`.
by_m: bool, whether to return waveform separated by `m`

harmonic mode (summed over l), or already summed.

Returns:
Array of shape (n_m?, n_detectors, n_frequencies) with strain at
detector, n_m is there only if by_m=True.
property harmonic_modes

List of (l, m) pairs.

property lalsimulation_commands

Tuple of (key, value) where key is the name of a lalsimulation function and value is its second argument, after lal_dic.

property m_arr

Int array of m harmonic mode numbers.

property n_cached_waveforms

Nonnegative integer, number of cached waveforms.

reinstantiate(**new_init_kwargs)

Return a new instance of the class, possibly updating init_kwargs.

Values not passed will be taken from the current instance.

to_json(dirname, basename=None, *, dir_permissions=493, file_permissions=420, overwrite=False)

Write class instance to json file.

It can then be loaded with read_json.