Skip to content

Error: Waveform longer than frequency array

I am linking here the issue #5 which was raised by @nicola.delillo in the parallel_bilby project.

Bilby sometimes raises the following error:

  File "/.auto/home/sossokine/envs/p3/lib/python3.6/site-packages/bilby-0.6.3-py3.6.egg/bilby/gw/source.py", line 383, in _base_lal_cbc_fd_waveform
    raise ValueError("Waveform longer than frequency array")
ValueError: Waveform longer than frequency array

Which comes from the following chunk of code in /gw/source.py:

    if len(hplus.data.data) > len(frequency_array):
        raise ValueError("Waveform longer than frequency array")

    h_plus[:len(hplus.data.data)] = hplus.data.data
    h_cross[:len(hcross.data.data)] = hcross.data.data

Here hplus.data.data is the waveform polarization returned by lalsimulation. For me that case shouldn't be raised as an error since IMRPhenomPv2 for instance in lalsim outputs waveforms which array_length is a power of two and are padded with zeros from maximum_frequency up to the end of the array. Since this "next power of two" array-length rule is not used in bilby, it happens that the lalsim waveform is longer than our bilby frequency_array; hence the error raised by the code.

I propose the following change to the code which I will submit in a MR:

    if len(hplus.data.data) > len(frequency_array):
        h_plus = hplus.data.data[:len(h_plus)]
        h_cross = hcross.data.data[:len(h_cross)]
    else:
        h_plus[:len(hplus.data.data)] = hplus.data.data
        h_cross[:len(hcross.data.data)] = hcross.data.data