20"""Search for long-transient gravitational waves using a piecewise frequency model"""
28import matplotlib.pyplot
as plt
38pr = cProfile.Profile()
41parser = ap.ArgumentParser()
46 help=
"Specifies the tbank object to use for a search",
50 "--j", type=int, help=
"The job array number on OzSTAR", required=
True
55 help=
"Use a capital S or T to specify whether you want to calculate the size of the template bank, or the templates themselves",
60parser.add_argument(
"--tstart", type=int, help=
"Start time of SFTs", default=900000000)
63 help=
"Whether to write the statistics of the tiling to a file or not",
69 "--s", type=int, help=
"Set the s parameter", nargs=
"?", const=1, default=-1
72 "--fmin", type=float, help=
"Set the fmin parameter", nargs=
"?", const=1, default=-1
75 "--fmax", type=float, help=
"Set the fmax parameter", nargs=
"?", const=1, default=-1
78 "--nmin", type=float, help=
"Set the nmin parameter", nargs=
"?", const=1, default=-1
81 "--nmax", type=float, help=
"Set the nmax parameter", nargs=
"?", const=1, default=-1
84 "--kmin", type=float, help=
"Set the kmin parameter", nargs=
"?", const=1, default=-1
87 "--kmax", type=float, help=
"Set the kmax parameter", nargs=
"?", const=1, default=-1
92 help=
"The maximum duration we want the knot algorithm to calculate up to",
98 "--knots", type=float, help=
"Use user defined knots", nargs=
"+", default=[0]
103 help=
"Set the mismatch parameter",
109args = parser.parse_args()
112tbankcode = args.tbankcode
114SizeOrTemps = args.SizeOrTemps
122 filename=
"TBankCommandLineLog_" +
str(j) +
".log",
125 format=
"%(asctime)s %(message)s",
127log = logging.getLogger()
128log.setLevel(logging.DEBUG)
133if tbankcode ==
"GW170817":
134 tbank.SetDefaultBNSR()
136if tbankcode ==
"1987A":
137 tbank.SetDefault1987A()
139if tbankcode ==
"Small":
140 tbank.SetSmallTestCase()
151mismatch = args.mismatch
171 tbank.maxmismatch = mismatch
176 tbank.dur = knots[-1] - knots[0]
178 ek.allidealisedknots(
179 tbank.s, tbank.dur, 40, tbank.fmax, tbank.nmax, tbank.kmin, tbank.maxmismatch
183if bf.knotslist[0] != tstart:
184 for i, knot
in enumerate(bf.knotslist):
185 bf.knotslist[i] = knot + tstart
187logging.info(tbank.toString())
189logging.info(
"Knots are: " +
str(bf.knotslist))
190logging.info(
"Knots: %s",
str(bf.knotslist))
192tbank.knots = bf.knotslist
194logging.info(bf.knotslist)
196if SizeOrTemps ==
"S":
197 temps = tbe.PWTBankSizeWithObject(tbank, stats=stats)
198 logging.info(
"Number of temps found: " +
str(temps))
199elif SizeOrTemps ==
"T":
200 temps = tbe.PWTBankWithObject(tbank)
201 logging.info(
"Number of temps found: " +
str(len(temps)))
203 midway =
int(np.ceil(len(temps) / 2))
206 midway = temps[midway]
211 +
str(first[0 : (2 * tbank.s)])
213 +
str(first[-(2 * tbank.s + 1) : -1])
217 +
str(midway[0 : (2 * tbank.s)])
219 +
str(midway[-(2 * tbank.s + 1) : -1])
223 +
str(last[0 : (2 * tbank.s)])
225 +
str(last[-(2 * tbank.s + 1) : -1])
228 gom.PlotPWModel(first, show=
False, label=
"First", linewidth=4)
229 gom.PlotPWModel(midway, show=
False, label=
"Midway", linewidth=3)
230 gom.PlotPWModel(last, show=
False, label=
"Last", linewidth=2)
237sortby = pstats.SortKey.CUMULATIVE
238ps = pstats.Stats(pr, stream=s).sort_stats(
"cumtime")
241with open(
"TBankCommandLineProfile_" +
str(j) +
".txt",
"w+")
as f:
242 f.write(s.getvalue())