def get_interpolated_fd_waveform(dtype=numpy.complex64, return_hc=True, **params): """ Return a fourier domain waveform approximant, using interpolation """ def rulog2(val): return 2.0 ** numpy.ceil(numpy.log2(float(val))) orig_approx = params["approximant"] params["approximant"] = params["approximant"].replace("_INTERP", "") df = params["delta_f"] if "duration" not in params: duration = get_waveform_filter_length_in_time(**params) elif params["duration"] > 0: duration = params["duration"] else: err_msg = "Waveform duration must be greater than 0." raise ValueError(err_msg) # FIXME We should try to get this length directly somehow # I think this number should be conservative ringdown_padding = 0.5 df_min = 1.0 / rulog2(duration + ringdown_padding) # FIXME: I don't understand this, but waveforms with df_min < 0.5 will chop # off the inspiral when using ringdown_padding - 0.5. # Also, if ringdown_padding is set to a very small # value we can see cases where the ringdown is chopped. if df_min > 0.5: df_min = 0.5 params["delta_f"] = df_min hp, hc = get_fd_waveform(**params) hp = hp.astype(dtype) if return_hc: hc = hc.astype(dtype) else: hc = None f_end = get_waveform_end_frequency(**params) if f_end is None: f_end = (len(hp) - 1) * hp.delta_f if "f_final" in params and params["f_final"] > 0: f_end_params = params["f_final"] if f_end is not None: f_end = min(f_end_params, f_end) n_min = int(rulog2(f_end / df_min)) + 1 if n_min < len(hp): hp = hp[:n_min] if hc is not None: hc = hc[:n_min] offset = int(ringdown_padding * (len(hp) - 1) * 2 * hp.delta_f) hp = interpolate_complex_frequency(hp, df, zeros_offset=offset, side="left") if hc is not None: hc = interpolate_complex_frequency(hc, df, zeros_offset=offset, side="left") params["approximant"] = orig_approx return hp, hc
def get_interpolated_fd_waveform(dtype=numpy.complex64, return_hc=True, **params): """ Return a fourier domain waveform approximant, using interpolation """ def rulog2(val): return 2.0 ** numpy.ceil(numpy.log2(float(val))) orig_approx = params['approximant'] params['approximant'] = params['approximant'].replace('_INTERP', '') df = params['delta_f'] if 'duration' not in params: duration = get_waveform_filter_length_in_time(**params) elif params['duration'] > 0: duration = params['duration'] else: err_msg = "Waveform duration must be greater than 0." raise ValueError(err_msg) #FIXME We should try to get this length directly somehow # I think this number should be conservative ringdown_padding = 0.5 df_min = 1.0 / rulog2(duration + ringdown_padding) # FIXME: I don't understand this, but waveforms with df_min < 0.5 will chop # off the inspiral when using ringdown_padding - 0.5. # Also, if ringdown_padding is set to a very small # value we can see cases where the ringdown is chopped. if df_min > 0.5: df_min = 0.5 params['delta_f'] = df_min hp, hc = get_fd_waveform(**params) hp = hp.astype(dtype) if return_hc: hc = hc.astype(dtype) else: hc = None f_end = get_waveform_end_frequency(**params) if f_end is None: f_end = (len(hp) - 1) * hp.delta_f if 'f_final' in params and params['f_final'] > 0: f_end_params = params['f_final'] if f_end is not None: f_end = min(f_end_params, f_end) n_min = int(rulog2(f_end / df_min)) + 1 if n_min < len(hp): hp = hp[:n_min] if hc is not None: hc = hc[:n_min] offset = int(ringdown_padding * (len(hp)-1)*2 * hp.delta_f) hp = interpolate_complex_frequency(hp, df, zeros_offset=offset, side='left') if hc is not None: hc = interpolate_complex_frequency(hc, df, zeros_offset=offset, side='left') params['approximant'] = orig_approx return hp, hc