def _get_dur(self): dur = lalsim.SimIMRSEOBNRv4ROMTimeOfFrequency(self.flow, self.m1 * MSUN_SI, self.m2 * MSUN_SI, self.spin1z, self.spin2z) # Allow a 10% margin of error return dur * 1.1
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
def get_inspiral_tf(tc, mass1, mass2, spin1, spin2, f_low, n_points=100, pn_2order=7, approximant='TaylorF2'): """Compute the time-frequency evolution of an inspiral signal. Return a tuple of time and frequency vectors tracking the evolution of an inspiral signal in the time-frequency plane. """ # handle param-dependent approximant specification class Params: pass params = Params() params.mass1 = mass1 params.mass2 = mass2 params.spin1z = spin1 params.spin2z = spin2 try: approximant = eval(approximant, {'__builtins__': None}, dict(params=params)) except NameError: pass if approximant in ['TaylorF2', 'SPAtmplt']: from pycbc.waveform.spa_tmplt import findchirp_chirptime # FIXME spins are not taken into account f_high = f_SchwarzISCO(mass1 + mass2) track_f = numpy.logspace(numpy.log10(f_low), numpy.log10(f_high), n_points) track_t = numpy.array([findchirp_chirptime(float(mass1), float(mass2), float(f), pn_2order) for f in track_f]) elif approximant in ['SEOBNRv2', 'SEOBNRv2_ROM_DoubleSpin', 'SEOBNRv2_ROM_DoubleSpin_HI']: f_high = get_final_freq('SEOBNRv2', mass1, mass2, spin1, spin2) track_f = numpy.logspace(numpy.log10(f_low), numpy.log10(f_high), n_points) # use HI function as it has wider freq range validity track_t = numpy.array([ lalsimulation.SimIMRSEOBNRv2ROMDoubleSpinHITimeOfFrequency(f, solar_mass_to_kg(mass1), solar_mass_to_kg(mass2), float(spin1), float(spin2)) for f in track_f]) elif approximant in ['SEOBNRv4', 'SEOBNRv4_ROM']: f_high = get_final_freq('SEOBNRv4', mass1, mass2, spin1, spin2) # use frequency below final freq in case of rounding error track_f = numpy.logspace(numpy.log10(f_low), numpy.log10(0.999*f_high), n_points) track_t = numpy.array([ lalsimulation.SimIMRSEOBNRv4ROMTimeOfFrequency( f, solar_mass_to_kg(mass1), solar_mass_to_kg(mass2), float(spin1), float(spin2)) for f in track_f]) else: raise ValueError('Approximant ' + approximant + ' not supported') return (tc - track_t, track_f)
def seobnrv4_length_in_time(**kwds): """Stub for holding the calculation of SEOBNRv4* waveform duration. """ m1 = float(kwds['mass1']) m2 = float(kwds['mass2']) s1 = float(kwds['spin1z']) s2 = float(kwds['spin2z']) fmin = float(kwds['f_lower']) t = lalsimulation.SimIMRSEOBNRv4ROMTimeOfFrequency(fmin, m1 * lal.MSUN_SI, m2 * lal.MSUN_SI, s1, s2) # Allow a 10% margin of error return t * 1.1
# newtbl = lsctables.SimInspiralTable() noinjs = 0 for s in sims: # short-circuit this potentially slow code path if possible if len(newtbl) == opts.injection_max - opts.injection_min: break # start adding to table once we reach min injection requested # by user if opts.injection_min <= noinjs: if 1. / opts.mratio_max <= s.mass1 / s.mass2 <= opts.mratio_max and opts.mtotal_min <= s.mass1 + s.mass2 <= opts.mtotal_max and ( opts.duration_min == 0 or lalsim.SimIMRSEOBNRv4ROMTimeOfFrequency( opts.flow, s.mass1 * MSUN_SI, s.mass2 * MSUN_SI, s.spin1z, s.spin2z) > opts.duration_min): newtbl.append(s) noinjs += 1 sims = newtbl if verbose: print("Loaded %d injections" % len(sims)) inj_format = "".join("%s: %s " % name_format for name_format in zip( inj_approx.param_names, inj_approx.param_formats)) # main worker loop # FIXME: this (potentially) breaks using mixed template bank approximants match_map = np.empty(len(sims), dtype=[("match", np.float32),
sims = sorted(lsctables.SimInspiralTable.get_table(xmldoc2), key=lambda s: s.mchirp) # # Sometimes inspinj doesn't give us everything we want, so we give the # user a little extra control here over the injections acutally used. # FIXME: preprocess inj file in future to avoid this step # newtbl = lsctables.SimInspiralTable() noinjs = 0 for s in sims: # short-circuit this potentially slow code path if possible if len(newtbl) == opts.injection_max - opts.injection_min: break if 1./opts.mratio_max <= s.mass1/s.mass2 <= opts.mratio_max and opts.mtotal_min <= s.mass1 + s.mass2 <= opts.mtotal_max and (opts.duration_min == 0 or lalsim.SimIMRSEOBNRv4ROMTimeOfFrequency(opts.flow, s.mass1 * MSUN_SI, s.mass2* MSUN_SI, s.spin1z, s.spin2z) > opts.duration_min): s.polarization = np.random.uniform(0, 2*np.pi) # start adding to table once we reach min injection requested # by user if opts.injection_min <= noinjs: newtbl.append(s) noinjs += 1 sims = newtbl if verbose: print("Loaded %d injections" % len(sims)) inj_format = "".join("%s: %s " % name_format for name_format in zip(inj_approx.param_names, inj_approx.param_formats)) # main worker loop