-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter_func.py
38 lines (33 loc) · 1.55 KB
/
filter_func.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
""" This script filters the injections by duration and keeps only those with a duration above 0.15 s.
This value can be directly changed in the script. The approximation used to compute the duration can also
be changed by importing a new one and modifying the script."""
def filter_injections(mass1, mass2, spin1z, spin2z):
"""Filter injections according to O2 requirements.
Taking mass1, mass2, spin1z, spin2z return a boolean array which is True
if point is within the O2 template region and False if it is outside the
O2 template region. Currently using the PyCBC definition, but this can
always be updated.
"""
import numpy
from scipy.interpolate import UnivariateSpline
from lalinspiral.sbank.waveforms import SEOBNRv4ROMTemplate, TaylorF2Template, IMRPhenomDTemplate
ifo_data = numpy.loadtxt('/home/marion.pillas/projects/template_bank/aligo_O4low.txt')
f_orig, asddata = ifo_data[:,0], ifo_data[:,1]
psddata = numpy.square(asddata)
interpolator = UnivariateSpline(f_orig, numpy.log(psddata), s=0)
noise_m = lambda u,g: numpy.where(g < 1024, numpy.exp(interpolator(g)), numpy.inf)
class Dummy(object):
flow = 15.
fhigh_max = 1024
noise_model = noise_m
optimize_flow = 0.995
bank = Dummy()
outs = []
for i in range(len(mass1)):
t = SEOBNRv4ROMTemplate(mass1[i], mass2[i], spin1z[i], spin2z[i],
bank=bank)
if t.dur > 0.15:
outs.append(True)
else:
outs.append(False)
return outs