The "create your own time domain source model" example doesn't "work"
The example to create your own time domain model (create_your_own_time_domain_source_model.py
) runs, but doesn't really work. The amplitude posterior just seems to return the prior. I've been playing around trying to fix things, but can't figure it out (I have thought that in the current example the model was maybe getting cut off by the windowing before FFTing, but even if I move the signal to the centre of the data it still doesn't seem to work). The example below:
import numpy as np
import bilby
from matplotlib import pyplot as pl
# define the time-domain model
def time_domain_damped_sinusoid(
time, amplitude, damping_time, frequency, phase, t0):
"""
This example only creates a linearly polarised signal with only plus
polarisation.
"""
plus = np.zeros(len(time))
tidx = time >= t0 # start at time t0
plus[tidx] = amplitude * np.exp(-time[tidx] / damping_time) *\
np.sin(2 * np.pi * frequency * time[tidx] + phase)
cross = np.zeros(len(time))
return {'plus': plus, 'cross': cross}
# define parameters to inject.
injection_parameters = dict(amplitude=5e-21, damping_time=0.1, frequency=50,
phase=0, ra=0, dec=0, psi=0, t0=0., geocent_time=0.)
duration = 3.0
sampling_frequency = 2048
outdir = 'outdir'
label = 'time_domain_source_model'
# call the waveform_generator to create our waveform model.
waveform = bilby.gw.waveform_generator.WaveformGenerator(
duration=duration, sampling_frequency=sampling_frequency,
time_domain_source_model=time_domain_damped_sinusoid)
# inject the signal into three interferometers
ifos = bilby.gw.detector.InterferometerList(['H1', 'L1'])
ifos.set_strain_data_from_power_spectral_densities(
sampling_frequency=sampling_frequency, duration=duration,
start_time=injection_parameters['geocent_time'] - 1.5)
ifos.inject_signal(waveform_generator=waveform,
parameters=injection_parameters)
#fig, ax = pl.subplots()
#ax.plot(ifos[0].time_array, ifos[0].time_domain_strain)
#print(ifos[0].time_array)
#exit(0)
#pl.show()
#exit(0)
# create the priors
prior = injection_parameters.copy()
prior['amplitude'] = bilby.core.prior.LogUniform(1e-23, 1e-19, r'$h_0$')
prior['damping_time'] = bilby.core.prior.Uniform(
0.01, 1, r'damping time', unit='$s$')
# define likelihood
likelihood = bilby.gw.likelihood.GravitationalWaveTransient(ifos, waveform)
# launch sampler
result = bilby.core.sampler.run_sampler(
likelihood, prior, sampler='dynesty', npoints=1000,
injection_parameters=injection_parameters, outdir=outdir, label=label)
result.plot_corner()
gives:
I'll pay around a bit more, but would be interested in other people's experience in using time domain models.
Edited by Matthew Pitkin