utils.create_time_series wrong number_of_samples
The create_time_series()
function is here:
https://git.ligo.org/lscsoft/bilby/-/blob/master/bilby/core/utils.py#L215
The number of samples derived from the duration
and sampling_frequency
is, from what I believe, missing 1 sample.
The function has:
number_of_samples = int(duration * sampling_frequency)
when I think it should be:
number_of_samples = int(duration * sampling_frequency) + 1
Since for a time series of N samples there are N-1 intervals of duration 1/sampling_frequency. For instance a 3 seconds array sampled at 2Hz would be: [0, 0.5, 1, 1.5, 2, 2.5, 3]
, hence of length 3 * 2 + 1
.
As a consequence, the returned time series array should also be modified. It is now:
return np.linspace(start=starting_time,
stop=duration + starting_time - 1 / sampling_frequency,
num=number_of_samples)
And I would replace it with:
return np.linspace(start=starting_time,
stop=duration + starting_time,
num=number_of_samples)
So that the end time of the series is correct.