An inject_glitch method for the interferometer object#1055
An inject_glitch method for the interferometer object#1055narolaharsh wants to merge 25 commits intobilby-dev:mainfrom
Conversation
|
Thanks for opening this PR. Personally, I don't think that making this change directly is appropriate for adding to Bilby. However, I think there are some opportunities here.
The rough pattern is below. def glitch_model(time_array, amplitude, ..., **kwargs):
# e.g., kwargs = dict(detector="H1", ...)
glitch_timeseries = ...
return {kwargs["detector"]: glitch_timeseries}
wfg = bilby.gw.waveform_generator.WaveformGenerator(...)
ifos = bilby.gw.detector.InterferometerList(...)
ifos.inject_signal(
parameters=dict(...glitch parameters..., geocent_time=..., ...unfortunately, we need to specify sky position...),
waveform_generator=wfg,
) |
|
Thanks, Colm! I re-structured def inject_glitch(self, glitch_parameters=None, glitch_time_domain_strain=None,
glitch_sample_times=None, glitch_waveform_generator=None):
""" Inject a glitch into the interferometer data.
Parameters
==========
glitch_parameters: dict
Dictionary of glitch parameters.
Must contain ``onset_time`` (the GPS time at which the glitch peak should occur).
Must contain ``snr``. The glitch will be rescaled in such a
way that it's optimal SNR matches to this value.
Other parameters passed to glitch_waveform_generator.
...
"""Directly using inject_signal function was making it difficult to make glitch maxima appear at a specific time. I have to do something like # Roll the glitch since the glitch maxima of the glitch may not align in the same way as the signal maxima.
glitch_parameters['geocent_time'] = glitch_parameters["onset_time”] - glitch_sample_times[np.argmax(glitch_time_domain_strain)]since glitch peak at random times. Besides this and adjusting snr, another minor improvement is in book keeping, i.e., using inject_signal was not updating the log properly (it still doesn’t but now there’s an option). In case the feature is not relevant at this stage, I am happy to close the PR. |
Time shift work in progress Time shifts fixed
Minor edits Minor edits Minor edits Minor edits Update interferometer
472299f to
198a60b
Compare
Updated README to include details about the new inject_glitch method and earth_rotation argument.
|
Hi @narolaharsh I've noticed that this branch seems to have diverged from the initial change. |
|
Hi Colm, let me close this pull request. I would like to merge the initial change or parts of it (snr adjustment and example script to inject glitch) if possible. For that, let me create a new PR with a separate source branch instead of main. Sorry about that. |
The method injects a glitch in a user specified interferometer at a desired SNR and onset time.
Also, I added an example to demonstrate the method. The time domain strain of the glitch needs to be provided by the user. For the sake of the example, I use the gengli codebase to inject a blip glitch.
The feautre could be of use for various glitch-mitigation or effect of glithces on PE related simulations. Any feedback on furhter developement, relevance of the feature for Bilby welcome.