diff --git a/MonteCarloMarginalizeCode/Code/RIFT/calmarg/rift_source.py b/MonteCarloMarginalizeCode/Code/RIFT/calmarg/rift_source.py index f81205c33..1fb2013bb 100755 --- a/MonteCarloMarginalizeCode/Code/RIFT/calmarg/rift_source.py +++ b/MonteCarloMarginalizeCode/Code/RIFT/calmarg/rift_source.py @@ -21,6 +21,11 @@ has_GWS=False +def _hlmoft_with_extra_waveform_kwargs(P, Lmax, extra_waveform_kwargs): + """Generate RIFT modes with the caller's waveform options expanded.""" + return lalsimutils.hlmoft(P, Lmax=Lmax, **extra_waveform_kwargs) + + def RIFT_lal_binary_black_hole_orig( frequency_array, mass_1, mass_2, luminosity_distance, spin_1x, spin_1y, spin_1z, spin_2x, spin_2y, spin_2z, lambda_1, lambda_2, iota, phase, **kwargs): @@ -71,7 +76,7 @@ def RIFT_lal_binary_black_hole_orig( # Note several underlying interfaces like ChooseTDModes will enforce these conditions already, but not all. Better safe than sorry. P.phiref = 0 P.incl = 0 # L direction frame - hlmT = lalsimutils.hlmoft(P,Lmax=Lmax,extra_waveform_kwargs=extra_waveform_kwargs) # extra needed to control ChooseFDWaveform + hlmT = _hlmoft_with_extra_waveform_kwargs(P, Lmax, extra_waveform_kwargs) P.phiref = phase P.incl = iota # restore h22T = hlmT[(2,2)] @@ -179,7 +184,7 @@ def RIFT_lal_binary_black_hole( # Note several underlying interfaces like ChooseTDModes will enforce these conditions already, but not all. Better safe than sorry. P.phiref = 0 P.incl = 0 # L direction frame - hlmT = lalsimutils.hlmoft(P,Lmax=Lmax,extra_waveform_kwargs=extra_waveform_kwargs) # extra needed to control ChooseFDWaveform + hlmT = _hlmoft_with_extra_waveform_kwargs(P, Lmax, extra_waveform_kwargs) P.phiref = phase P.incl = iota # restore @@ -306,7 +311,7 @@ def RIFT_lal_eccentric_binary_black_hole( # Note several underlying interfaces like ChooseTDModes will enforce these conditions already, but not all. Better safe than sorry. P.phiref = 0 P.incl = 0 # L direction frame - hlmT = lalsimutils.hlmoft(P,Lmax=Lmax,extra_waveform_kwargs=extra_waveform_kwargs) # extra needed to control ChooseFDWaveform + hlmT = _hlmoft_with_extra_waveform_kwargs(P, Lmax, extra_waveform_kwargs) P.phiref = phase P.incl = iota # restore diff --git a/MonteCarloMarginalizeCode/Code/test/test_calmarg_rift_source.py b/MonteCarloMarginalizeCode/Code/test/test_calmarg_rift_source.py new file mode 100644 index 000000000..aa973b90d --- /dev/null +++ b/MonteCarloMarginalizeCode/Code/test/test_calmarg_rift_source.py @@ -0,0 +1,23 @@ +from RIFT.calmarg import rift_source + + +def test_hlmoft_expands_extra_waveform_kwargs(monkeypatch): + captured = {} + + def fake_hlmoft(P, **kwargs): + captured["P"] = P + captured["kwargs"] = kwargs + return "modes" + + monkeypatch.setattr(rift_source.lalsimutils, "hlmoft", fake_hlmoft) + P = object() + options = {"fd_L_frame": True, "no_condition": True} + + result = rift_source._hlmoft_with_extra_waveform_kwargs(P, 4, options) + + assert result == "modes" + assert captured == { + "P": P, + "kwargs": {"Lmax": 4, "fd_L_frame": True, "no_condition": True}, + } + assert options == {"fd_L_frame": True, "no_condition": True}