Esempio n. 1
0
def _get_phenomb_chi(m1, m2, s1z, s2z):
    """
    Wrapper of standard Phenom effective spin calculation
    """
    return lalsimulation.SimIMRPhenomBComputeChi(
        float(m1) * lal.MSUN_SI,
        float(m2) * lal.MSUN_SI, float(s1z), float(s2z))
Esempio n. 2
0
    def __init__(self, m1, m2, spin1z, spin2z, bank, flow=None, duration=None):

        self.m1 = float(m1)
        self.m2 = float(m2)
        self.spin1z = float(spin1z)
        self.spin2z = float(spin2z)
        self.chieff = lalsim.SimIMRPhenomBComputeChi(self.m1, self.m2,
                                                     self.spin1z, self.spin2z)
        self.bank = bank

        if flow is None:
            self.flow = bank.flow
            if bank.optimize_flow is not None:
                self.optimize_flow(bank.flow,
                                   bank.fhigh_max,
                                   bank.noise_model,
                                   sigma_frac=bank.optimize_flow)
        else:
            self.flow = flow

        self._wf = {}
        self._metric = None
        self.sigmasq = 0.
        self._mchirp = compute_mchirp(m1, m2)
        self.tau0 = compute_tau0(self._mchirp, bank.flow)
        self._dur = duration
        self._f_final = None
        self._fhigh_max = bank.fhigh_max
Esempio n. 3
0
def _get_imr_duration(m1, m2, s1z, s2z, f_low, approximant="SEOBNRv4"):
    """Wrapper of lalsimulation template duration approximate formula"""
    m1, m2, s1z, s2z, f_low = float(m1), float(m2), float(s1z), float(s2z),\
                              float(f_low)
    if approximant == "SEOBNRv2":
        chi = lalsimulation.SimIMRPhenomBComputeChi(m1, m2, s1z, s2z)
        time_length = lalsimulation.SimIMRSEOBNRv2ChirpTimeSingleSpin(
                                m1 * lal.MSUN_SI, m2 * lal.MSUN_SI, chi, f_low)
    elif approximant == "IMRPhenomD":
        time_length = lalsimulation.SimIMRPhenomDChirpTime(
                           m1 * lal.MSUN_SI, m2 * lal.MSUN_SI, s1z, s2z, f_low)
    elif approximant == "SEOBNRv4":
        # NB for no clear reason this function has f_low as first argument
        time_length = lalsimulation.SimIMRSEOBNRv4ROMTimeOfFrequency(
                           f_low, m1 * lal.MSUN_SI, m2 * lal.MSUN_SI, s1z, s2z)
    elif approximant == 'SPAtmplt' or approximant == 'TaylorF2':
        chi = lalsimulation.SimInspiralTaylorF2ReducedSpinComputeChi(
            m1, m2, s1z, s2z
        )
        time_length = lalsimulation.SimInspiralTaylorF2ReducedSpinChirpTime(
            f_low, m1 * lal.MSUN_SI, m2 * lal.MSUN_SI, chi, -1
        )
    else:
        raise RuntimeError("I can't calculate a duration for %s" % approximant)
    # FIXME Add an extra factor of 1.1 for 'safety' since the duration
    # functions are approximate
    return time_length * 1.1
Esempio n. 4
0
def get_waveform(approximant, phase_order, amplitude_order, template_params,
                 start_frequency, sample_rate, length, filter_rate):

    if approximant in td_approximants():
        hplus, hcross = get_td_waveform(template_params,
                                        approximant=approximant,
                                        phase_order=phase_order,
                                        delta_t=1.0 / sample_rate,
                                        f_lower=start_frequency,
                                        amplitude_order=amplitude_order)
        hvec = generate_detector_strain(template_params, hplus, hcross)

        if filter_rate != sample_rate:
            delta_t = 1.0 / filter_rate
            hvec = resample_to_delta_t(hvec, delta_t)

    elif approximant in fd_approximants():
        delta_f = filter_rate / length
        if hasattr(template_params, "spin1z") and hasattr(
                template_params, "spin2z"):
            if template_params.spin1z <= -0.9 or template_params.spin1z >= 0.9:
                template_params.spin1z *= 0.99999999
            if template_params.spin2z <= -0.9 or template_params.spin2z >= 0.9:
                template_params.spin2z *= 0.99999999
        if True:
            print("\n spin1z = %f, spin2z = %f, chi = %f" %
                  (template_params.spin1z, template_params.spin2z,
                   lalsimulation.SimIMRPhenomBComputeChi(
                       template_params.mass1 * lal.LAL_MSUN_SI,
                       template_params.mass2 * lal.LAL_MSUN_SI,
                       template_params.spin1z, template_params.spin2z)),
                  file=sys.stderr)
            print("spin1x = %f, spin1y = %f" %
                  (template_params.spin1x, template_params.spin1y),
                  file=sys.stderr)
            print("spin2x = %f, spin2y = %f" %
                  (template_params.spin2x, template_params.spin2y),
                  file=sys.stderr)
            print("m1 = %f, m2 = %f" %
                  (template_params.mass1, template_params.mass2),
                  file=sys.stderr)
        hvec = get_fd_waveform(template_params,
                               approximant=approximant,
                               phase_order=phase_order,
                               delta_f=delta_f,
                               f_lower=start_frequency,
                               amplitude_order=amplitude_order)[0]
        if True:
            print("filter_N = %d in get waveform" % filter_N,
                  "\n type(hvec) in get_waveform:",
                  type(hvec),
                  file=sys.stderr)
            print(hvec, file=sys.stderr)
            print(hvec[0], file=sys.stderr)
            print(hvec[1], file=sys.stderr)
            print(isinstance(hvec, FrequencySeries), file=sys.stderr)
    htilde = make_padded_frequency_series(hvec, filter_N)

    return htilde
 def _get_dur(self):
     seff = lalsim.SimIMRPhenomBComputeChi(self.m1, self.m2,
                                           self.spin1z, self.spin2z)
     dur = lalsim.SimIMRSEOBNRv2ChirpTimeSingleSpin(
             self.m1 * MSUN_SI, self.m2 * MSUN_SI, seff, self.flow)
     # add a 10% to be consistent with PyCBC's duration estimate,
     # may want to FIXME if that changes
     return dur * 1.1
Esempio n. 6
0
def _get_seobnrrom_duration(m1, m2, s1z, s2z, f_low):
    """Wrapper of lalsimulation template duration approximate formula"""
    m1, m2, s1z, s2z, f_low = float(m1), float(m2), float(s1z), float(s2z),\
                              float(f_low)
    chi = lalsimulation.SimIMRPhenomBComputeChi(m1, m2, s1z, s2z)
    time_length = lalsimulation.SimIMRSEOBNRv2ChirpTimeSingleSpin(
        m1 * lal.MSUN_SI, m2 * lal.MSUN_SI, chi, f_low)
    # FIXME The function seobnrrom_length_in_time() in waveform.py adds an
    # extra factor of 1.1 for 'safety'.  For consistency with that code we do
    # that here.  THIS IS FRAGILE AND HACKY
    return time_length * 1.1
Esempio n. 7
0
def seobnrv2_length_in_time(**kwds):
    """Stub for holding the calculation of ROM waveform duration.
    """
    mass1 = float(kwds['mass1'])
    mass2 = float(kwds['mass2'])
    spin1z = float(kwds['spin1z'])
    spin2z = float(kwds['spin2z'])
    fmin = float(kwds['f_lower'])
    chi = lalsimulation.SimIMRPhenomBComputeChi(mass1, mass2, spin1z, spin2z)
    time_length = lalsimulation.SimIMRSEOBNRv2ChirpTimeSingleSpin(
        mass1 * lal.MSUN_SI, mass2 * lal.MSUN_SI, chi, fmin)
    # FIXME: This is still approximate so add a 10% error margin
    time_length = time_length * 1.1
    return time_length
Esempio n. 8
0
def seobnrrom_length_in_time(**kwds):
    """
    This is a stub for holding the calculation for getting length of the ROM
    waveforms.
    """
    mass1 = kwds['mass1']
    mass2 = kwds['mass2']
    spin1z = kwds['spin1z']
    spin2z = kwds['spin2z']
    fmin = kwds['f_lower']
    chi = lalsimulation.SimIMRPhenomBComputeChi(mass1, mass2, spin1z, spin2z)
    time_length = lalsimulation.SimIMRSEOBNRv2ChirpTimeSingleSpin(
        mass1 * lal.MSUN_SI, mass2 * lal.MSUN_SI, chi, fmin)
    # FIXME: This is still approximate so add a 10% error margin
    time_length = time_length * 1.1
    return time_length
Esempio n. 9
0
    def __init__(self, m1, m2, spin1z, spin2z, bank):

        self.m1 = float(m1)
        self.m2 = float(m2)
        self.spin1z = float(spin1z)
        self.spin2z = float(spin2z)
        self.chieff = lalsim.SimIMRPhenomBComputeChi(m1, m2, spin1z, spin2z)
        self.bank = bank

        self._wf = {}
        self._metric = None
        self.sigmasq = 0.
        self._mchirp = compute_mchirp(m1, m2)
        self._tau0 = compute_tau0(self._mchirp, bank.flow)
        self._dur = self._get_dur()
        self._f_final = None
        self._fhigh_max = bank.fhigh_max
Esempio n. 10
0
    def __init__(self, m1, m2, spin1z, spin2z, bank):

        Template.__init__(self, m1, m2, bank)
        self.spin1z = float(spin1z)
        self.spin2z = float(spin2z)
        self.chieff = lalsim.SimIMRPhenomBComputeChi(m1, m2, spin1z, spin2z)