Skip to content

Error: Waveform longer than frequency array

This error comes from a run I have tried to set up on Hawk at:

HAWK:/home/nicola.delillo/projects/pbilby_test/pbilby_test_injection/pe_v0.1.0

if you dont have access, the config.ini and all the other files used for this, are stored in the repo: injection_hands_on_v0.1.0. If you might need to reproduce it.

It seems to be hit only for certain high combinations of srate and approximant, which I have not explored. I think Roberto in the mattermost chat also reported this error.

Looking at actuall error, printed in the .err after submission, it says:

File "/home/nicola.delillo/.conda/envs/nsbhmodels-rebase/lib/python3.7/site-packages/bilby/gw/source.py", line 360, in _base_lal_cbc_fd_waveform
raise ValueError("Waveform longer than frequency array")

ValueError: Waveform longer than frequency array

Looking into the file "/home/nicola.delillo/.conda/envs/nsbhmodels-rebase/lib/python3.7/site-packages/bilby/gw/source.py" It is coming from this piece of code:

 345     if lalsim.SimInspiralImplementedFDApproximants(approximant):
    346         wf_func = lalsim_SimInspiralChooseFDWaveform
    347     else:
    348         wf_func = lalsim_SimInspiralFD
    349     hplus, hcross = wf_func(
    350         mass_1, mass_2, spin_1x, spin_1y, spin_1z, spin_2x, spin_2y,
    351         spin_2z, luminosity_distance, iota, phase,
    352         longitude_ascending_nodes, eccentricity, mean_per_ano, delta_frequency,
    353         start_frequency, maximum_frequency, reference_frequency,
    354         waveform_dictionary, approximant)
    355 
    356     h_plus = np.zeros_like(frequency_array, dtype=np.complex)
    357     h_cross = np.zeros_like(frequency_array, dtype=np.complex)
    358 
    359     if len(hplus.data.data) > len(frequency_array):
    360         raise ValueError("Waveform longer than frequency array")
    361 
    362     h_plus[:len(hplus.data.data)] = hplus.data.data
    363     h_cross[:len(hcross.data.data)] = hcross.data.data

If I understand, the waveform is first generated and saved in hplus, hcross. Then we createh_plus, h_cross which are sized to the length of frequency_array (not sure if it is the freq araay of the data). Then possibly hplus, hcross SHOULD be evaluated at the same frequency of frequency_array and stored in h_plus, h_cross. If this "SHOULD" is what actually we want, then I am quite surprised this gives error only for certain combination of srate and approximant.

Without having explored fully, have thought about two possibilities:

  1. One could check that passing to lalsim.SimInspiralImplementedFDApproximants : maximum_frequency = frequency_array[-1] and start_frequency = frequency_array[0] , d_f = frequency_array[1] - frequency_array[0] , is actually evaluating the signal at the same set of frequencies we want. This is actually implemented
 299     approximant = lalsim_GetApproximantFromString(waveform_approximant)
    300 
    301     if pn_amplitude_order != 0:
    302         start_frequency = lalsim.SimInspiralfLow2fStart(
    303             minimum_frequency, int(pn_amplitude_order), approximant)
    304     else:
    305         start_frequency = minimum_frequency
    306 
    307     delta_frequency = frequency_array[1] - frequency_array[0]

So it might be worth if I check the output of the lalsim.SimInspiralImplementedFDApproximants itself?It runs in _base_lal_cbc_fd_waveform.

  1. If we can get a frequency vector from wf_func (lets call it wf_func.frequency_array) . What about simply interpolating? :
h_plus = np.interp(frequency_array, wf_fun.frequency_array,hplus.data.data)
h_cross = np.interp(frequency_array, wf_fun.frequency_array, hcross.data.data)

I am not still 100% sure that would be the correct way since interpolation might not be the magic word here. If yes, than it would never hit error (that I would anyway leave it there).

Edited by Nicola De Lillo