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:
JSONMixinClass 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
Return a LAL dict object per
self.lalsimulation_commands.Constructor that takes
detector_names,tgpsandtcoarsefrom an instance of data.EventData.Return hplus, hcross waveform strain.
Return plus and cross polarizations with time shifts applied (but no fplus, fcross).
Return dictionary with keyword arguments to __init__.
Return two lists of integers, these zipped are pairs (i, j) of indices with j >= i that run through the number of m modes.
Name of the module that defines the instance's class.
Get strain measurable at detectors.
Return a new instance of the class, possibly updating init_kwargs.
Write class instance to json file.
Attributes
String with waveform approximant name.
fast_paramsList of (l, m) pairs.
Tuple of (key, value) where key is the name of a lalsimulation function and value is its second argument, after lal_dic.
Int array of m harmonic mode numbers.
Nonnegative integer, number of cached waveforms.
paramspolarization_paramsslow_paramssubclass_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,tgpsandtcoarsefrom 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 isFalse, or(n_m, 2, len(f))if by_m isTrue, wheren_mis 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.