Waveform
gwmock_signal.waveform
¶
Waveform generation (PyCBC-backed and extensible).
WaveformFactory
¶
Registry and dispatcher for time-domain waveform generators.
On construction, every name returned by PyCBC
td_approximants is
registered and mapped to pycbc_waveform_wrapper.
You may register additional names pointing at custom callables. See package docs for examples.
Source code in src/gwmock_signal/waveform/factory.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
__init__()
¶
Build the registry of built-in PyCBC TD approximants.
Note
Importing PyCBC and enumerating approximants can be slow; reuse one factory instance in tight loops instead of creating many factories.
Source code in src/gwmock_signal/waveform/factory.py
30 31 32 33 34 35 36 37 38 39 40 | |
generate(waveform_model, parameters, **extra_params)
¶
Generate polarizations by calling the registered model with merged parameters.
The callable is invoked with waveform_model, then entries from parameters,
then extra_params (later keys override earlier ones).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waveform_model
|
str
|
Name of the registered model to run. |
required |
parameters
|
dict[str, Any]
|
Injection parameters (e.g. |
required |
**extra_params
|
Any
|
Additional fixed settings (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, TimeSeries]
|
Dict whose keys are the strings |
dict[str, TimeSeries]
|
GWpy |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If the underlying generator is called with invalid arguments. |
Source code in src/gwmock_signal/waveform/factory.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
get_model(name)
¶
Look up the generator function registered for name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Registered model name (built-in approximant or custom). |
required |
Returns:
| Type | Description |
|---|---|
Callable[..., dict[str, TimeSeries]]
|
The callable registered for this name. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/gwmock_signal/waveform/factory.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
list_models()
¶
Return every registered waveform model name, in dict iteration order.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of keys (PyCBC TD approximants plus any custom registrations). |
Source code in src/gwmock_signal/waveform/factory.py
91 92 93 94 95 96 97 | |
register_model(name, factory_func)
¶
Register or overwrite a waveform model under name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Key used with |
required |
factory_func
|
Callable[..., Any] | str
|
Callable that accepts merged waveform kwargs (including
|
required |
Raises:
| Type | Description |
|---|---|
ImportError
|
If a string path does not refer to an importable module. |
AttributeError
|
If the imported module has no such callable attribute. |
ValueError
|
If factory_func string is neither 'module.path:callable' nor 'package.module.callable'. |
TypeError
|
Registered model is not callable. |
Source code in src/gwmock_signal/waveform/factory.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
pycbc_waveform_wrapper(tc, sampling_frequency, minimum_frequency, waveform_model, **kwargs)
¶
Generate plus and cross polarizations with PyCBC and return GWpy time series.
Calls pycbc.waveform.get_td_waveform
with delta_t = 1/sampling_frequency,
f_lower = minimum_frequency, and approximant=waveform_model, then shifts both
polarizations by tc in GPS seconds and converts them to GWpy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tc
|
float
|
GPS time of coalescence (seconds); added to each series' |
required |
sampling_frequency
|
float
|
Sample rate in Hz for |
required |
minimum_frequency
|
float
|
Low-frequency cutoff in Hz, passed to PyCBC as |
required |
waveform_model
|
str
|
PyCBC time-domain approximant name (e.g. |
required |
**kwargs
|
Any
|
Additional arguments for |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, TimeSeries]
|
Mapping whose keys are the strings |
dict[str, TimeSeries]
|
GWpy |
Raises:
| Type | Description |
|---|---|
ValueError
|
sampling_frequency must be > 0. |
Note
Invalid parameters may raise exceptions from PyCBC/LAL; see PyCBC waveform docs.
Source code in src/gwmock_signal/waveform/pycbc_wrapper.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
For usage examples, see the User guide — Waveform examples.