diff --git a/pycbc/waveform/waveform.py b/pycbc/waveform/waveform.py index 235b4f54aec..c5e97c8e9fc 100644 --- a/pycbc/waveform/waveform.py +++ b/pycbc/waveform/waveform.py @@ -342,11 +342,7 @@ def td_approximants(scheme=_scheme.mgr.state): """Return a list containing the available time domain approximants for the given processing scheme. """ - return list(td_wav[type(scheme)].keys()) + [ - "IMRESIGMAHM", - "IMRESIGMA", - "InspiralESIGMAHM", - ] + return list(td_wav[type(scheme)].keys()) def fd_approximants(scheme=_scheme.mgr.state): """Return a list containing the available fourier domain approximants for @@ -591,26 +587,70 @@ def get_td_waveform(template=None, **kwargs): """ input_params = props(template, **kwargs) if "ESIGMA" in input_params["approximant"]: - from gwnr.waveform import enigma_utils + from gwnr.waveform import esigma_utils hp, hc = None, None - if input_params["approximant"] == "IMRESIGMAHM": - hp, hc = enigma_utils.get_imr_enigma_waveform(**input_params) - if input_params["approximant"] == "IMRESIGMA": - hp, hc = enigma_utils.get_imr_enigma_waveform( - **input_params, modes_to_use=[(2, 2)] - ) - if input_params["approximant"] == "InspiralESIGMAHM": - _, hp, hc = enigma_utils.get_inspiral_enigma_waveform(**input_params) - if input_params["approximant"] == "InspiralESIGMA": - _, hp, hc = enigma_utils.get_inspiral_enigma_waveform( - **input_params, modes_to_use=[(2, 2)] - ) - if hp is None or hc is None: - raise IOError( - f"Approximant {input_params['approximant']} not supported" - ) - return hp, hc + + os.environ["RadiationPNOrder"] = "8" + os.environ["ModePNOrder"] = "8" + os.environ["InspiralEndRadius"] = "4.0" + + esigma_params = dict( + mass1=float(input_params["mass1"]), + mass2=float(input_params["mass2"]), + spin1z=float(input_params["spin1z"]), + spin2z=float(input_params["spin2z"]), + eccentricity=float(input_params["eccentricity"]), + mean_anomaly=float(input_params["mean_per_ano"]), + coa_phase=float(input_params["coa_phase"]), + distance=float(input_params["distance"]), + inclination=float(input_params["inclination"]), + f_lower=float(input_params["f_lower"]), + delta_t=float(input_params["delta_t"]), + # even thought we specify them, the inspiral ESIGMA methods + # will ignore the following arguments + mode_to_align_by=(2, 2), + include_conjugate_modes=True, + f_mr_transition=None, + f_window_mr_transition=None, + num_hyb_orbits=0.25, + hybridize_using_avg_orbital_frequency=False, + hybridize_aligning_merger_to_inspiral=False, + keep_f_mr_transition_at_center=False, + merger_ringdown_approximant="NRSur7dq4", + return_hybridization_info=False, + return_orbital_params=False, + failsafe=True, + verbose=False, + ) + + try: + if input_params["approximant"] == "IMRESIGMAHM": + hp, hc = esigma_utils.get_imr_esigma_waveform( + **esigma_params, modes_to_use=[(2, 2), (3, 3), (4, 4)] + ) + elif input_params["approximant"] == "IMRESIGMA": + hp, hc = esigma_utils.get_imr_esigma_waveform( + **esigma_params, modes_to_use=[(2, 2)] + ) + elif input_params["approximant"] == "InspiralESIGMAHM": + hp, hc = esigma_utils.get_inspiral_esigma_waveform( + **esigma_params, modes_to_use=[(2, 2), (3, 3), (4, 4)] + ) + elif input_params["approximant"] == "InspiralESIGMA": + hp, hc = esigma_utils.get_inspiral_esigma_waveform( + **esigma_params, modes_to_use=[(2, 2)] + ) + if hp is None or hc is None: + raise IOError( + f"Approximant {input_params['approximant']} not supported" + ) + return hp, hc + except Exception as exc: + print(f"""Failed to generate waveform with input_params={input_params}, + with error: {exc} + """) + return None, None else: wav_gen = td_wav[type(_scheme.mgr.state)] if input_params['approximant'] not in wav_gen: @@ -628,6 +668,15 @@ def get_td_waveform(template=None, **kwargs): params=parameters.td_waveform_params.docstr(prefix=" ", include_label=False).lstrip(' ')) +cpu_td.update( + { + "InspiralESIGMA": get_td_waveform, + "InspiralESIGMAHM": get_td_waveform, + "IMRESIGMA": get_td_waveform, + "IMRESIGMAHM": get_td_waveform, + } +) + def get_fd_waveform(template=None, **kwargs): """Return a frequency domain gravitational waveform. @@ -1331,30 +1380,8 @@ def get_two_pol_waveform_filter(outplus, outcross, template, **kwargs): N = (n-1)*2 delta_f = 1.0 / (N * input_params['delta_t']) - if "ESIGMA" in input_params["approximant"]: - from gwnr.waveform import enigma_utils - - hp, hc = None, None - if input_params["approximant"] == "IMRESIGMAHM": - hp, hc = enigma_utils.get_imr_enigma_waveform(**input_params) - if input_params["approximant"] == "IMRESIGMA": - hp, hc = enigma_utils.get_imr_enigma_waveform( - **input_params, modes_to_use=[(2, 2)] - ) - if input_params["approximant"] == "InspiralESIGMAHM": - _, hp, hc = enigma_utils.get_inspiral_enigma_waveform(**input_params) - if input_params["approximant"] == "InspiralESIGMA": - _, hp, hc = enigma_utils.get_inspiral_enigma_waveform( - **input_params, modes_to_use=[(2, 2)] - ) - if hp is None or hc is None: - raise IOError( - f"Approximant {input_params['approximant']} not supported" - ) - print(f"ESIGMA length; {len(hp)}") - else: - wav_gen = td_wav[type(_scheme.mgr.state)] - hp, hc = wav_gen[input_params['approximant']](**input_params) + wav_gen = td_wav[type(_scheme.mgr.state)] + hp, hc = wav_gen[input_params['approximant']](**input_params) # taper the time series hp if required if 'taper' in input_params.keys() and \ input_params['taper'] is not None: