Skip to content

Add waveform error handling

I've taken at stab at implementing the error catching specified in #352 (closed). I'd like some feedback, because I've pretty much just hard-coded in some of the different errors here: https://lscsoft.docs.ligo.org/lalsuite/lal/group___x_l_a_l_error__h.html#ggacd0e128cb3ee1cc61f98d9e1add4d267a785106db6dbfb84fcfc4c99ae74b306d I've tested it with three different situations. Test case 1: Mass ratio outside range of validity of NRSUr7dq4

injection_parameters = dict(mass_ratio=.001, total_mass=70., a_1=0.1, a_2=0.1, tilt_1=0.,
        tilt_2=0., phi_12=0, phi_jl=0, luminosity_distance=400, theta_jn=2./3*np.pi,
        phase=0, psi=2.659, geocent_time=1126259642.413, ra=1.375, dec=-1.2108)
waveform_arguments = dict(waveform_approximant='NRSur7dq4', reference_frequency=30., minimum_frequency=30.)
waveform_generator = bilby.gw.waveform_generator.WaveformGenerator(
        sampling_frequency=1024, duration=4,
        frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole,
        parameter_conversion=bilby.gw.conversion.convert_to_lal_binary_black_hole_parameters,
        waveform_arguments=waveform_arguments)
test = waveform_generator.frequency_domain_strain(parameters=injection_parameters)
if not test:
    print("Success!")

Output:

XLAL Error - PrecessingNRSur_IntegrateDynamics (LALSimIMRPrecessingNRSur.c:1705): Too much extrapolation. Mass ratio q = 1000.0000 > 6.0100, the maximum allowed value.

XLAL Error - PrecessingNRSur_IntegrateDynamics (LALSimIMRPrecessingNRSur.c:1705): Input domain error
XLAL Error - PrecessingNRSur_core (LALSimIMRPrecessingNRSur.c:1858): Failed to integrate dynamics
XLAL Error - PrecessingNRSur_core (LALSimIMRPrecessingNRSur.c:1858): Internal function call failed: Input domain error
XLAL Error - XLALSimInspiralChooseTDWaveform (LALSimInspiral.c:1002): Internal function call failed: Input domain error
XLAL Error - XLALSimInspiralTDFromTD (LALSimInspiral.c:1942): Internal function call failed: Input domain error
XLAL Error - XLALSimInspiralTD (LALSimInspiral.c:2181): Internal function call failed: Input domain error
XLAL Error - XLALSimInspiralFD (LALSimInspiral.c:2394): Internal function call failed: Input domain error
08:59 bilby WARNING : Evaluating the waveform failed with error: Internal function call failed: Input domain error
The parameters were {'mass_1': 1.3905922761968263e+32, 'mass_2': 1.3905922761968264e+29, 'spin_1': (0, 0, 0.1), 'spin_2': (0, 0, 0.1), 'luminosity_distance': 1.2342710325965468e+25, 'iota': 2.0943951023931953, 'phase': 0, 'ecce
ntricity': 0.0, 'start_frequency': 30.0}
Likelihood will be set to -inf.
Success!

Test case 2: mass ratio outside range of validity for SEOBNRv4

XLAL Error - XLALSimIMRSpinAlignedEOBModes: Mass ratio larger than 100!
SEOBNRv2, SEOBNRv2_opt, SEOBNRv4, and SEOBNRv4_opt are only available for mass ratios up to 100.
XLAL Error - XLALSimIMRSpinAlignedEOBModes (LALSimIMRSpinAlignedEOB.c:993): Invalid argument
XLAL Error - XLALSimIMRSpinAlignedEOBWaveformAll (LALSimIMRSpinAlignedEOB.c:3217): Internal function call failed: Invalid argument
XLAL Error - XLALSimIMRSpinAlignedEOBWaveform (LALSimIMRSpinAlignedEOB.c:635): Internal function call failed: Invalid argument
XLAL Error - XLALSimInspiralChooseTDWaveform (LALSimInspiral.c:1002): Internal function call failed: Invalid argument
XLAL Error - XLALSimInspiralTDFromTD (LALSimInspiral.c:1942): Internal function call failed: Invalid argument
XLAL Error - XLALSimInspiralTD (LALSimInspiral.c:2181): Internal function call failed: Invalid argument
XLAL Error - XLALSimInspiralFD (LALSimInspiral.c:2394): Internal function call failed: Invalid argument
08:59 bilby WARNING : Evaluating the waveform failed with error: Internal function call failed: Invalid argument
The parameters were {'mass_1': 1.3905922761968263e+32, 'mass_2': 1.3905922761968264e+29, 'spin_1': (0, 0, 0.1), 'spin_2': (0, 0, 0.1), 'luminosity_distance': 1.2342710325965468e+25, 'iota': 2.0943951023931953, 'phase': 0, 'ecce
ntricity': 0.0, 'start_frequency': 30.0}
Likelihood will be set to -inf.
Success!

Output:

injection_parameters = dict(mass_ratio=.001, total_mass=70., chi_1=0.1, chi_2=0.1,
        luminosity_distance=400, theta_jn=2./3*np.pi,
        phase=0, psi=2.659, geocent_time=1126259642.413, ra=1.375, dec=-1.2108)
waveform_arguments = dict(waveform_approximant='SEOBNRv4', reference_frequency=30., minimum_frequency=30.)
waveform_generator = bilby.gw.waveform_generator.WaveformGenerator(
        sampling_frequency=1024, duration=4,
        frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole,
        parameter_conversion=bilby.gw.conversion.convert_to_lal_binary_black_hole_parameters,
        waveform_arguments=waveform_arguments)
test = waveform_generator.frequency_domain_strain(parameters=injection_parameters)
if not test:
    print("Success!")

The third test case was injecting a precessing system into a non-precessing waveform, but I wasn't able to catch the error in this case because of the LALSim bug that triggers a segfault in this case. One question I have is which cases we actually want to catch. It seems like there would be a wide variety of errors that could trigger "Invalid argument", but even the XLALErrorHandler doesn't differentiate. Is it safe to do this generically? How can we prevent getting stuck in an endless loop because of e.g. a bad prior setting?

Edited by Sylvia Biscoveanu

Merge request reports