Note
Click here to download the full example code
Short transient grid search¶
An example grid-based search for a short transient signal. By default, the standard persistent-CW 2F-statistic and the transient max2F statistic are compared.
You can turn on either BSGL = True or BtSG = True (not both!) to test alternative statistics.
This is also ready to use on a GPU, if you have one available and pycuda installed. Just change to tCWFstatMapVersion = “pycuda”.
17 import os
18
19 import numpy as np
20 import PyFstat_example_make_data_for_short_transient_search as data
21
22 import pyfstat
23
24 tCWFstatMapVersion = "lal"
25
26 if __name__ == "__main__":
27 label = "PyFstatExampleShortTransientGridSearch"
28 logger = pyfstat.set_up_logger(label=label, outdir=data.outdir)
29 if not os.path.isdir(data.outdir) or not np.any(
30 [f.endswith(".sft") for f in os.listdir(data.outdir)]
31 ):
32 raise RuntimeError(
33 "Please first run PyFstat_example_make_data_for_short_transient_search.py !"
34 )
35
36 maxStartTime = data.tstart + data.duration
37
38 m = 0.001
39 dF0 = np.sqrt(12 * m) / (np.pi * data.duration)
40 DeltaF0 = 100 * dF0
41 F0s = [data.F0 - DeltaF0 / 2.0, data.F0 + DeltaF0 / 2.0, dF0]
42 F1s = [data.F1]
43 F2s = [data.F2]
44 Alphas = [data.Alpha]
45 Deltas = [data.Delta]
46
47 BSGL = False
48 BtSG = False
49
50 logger.info("Standard CW search:")
51 search1 = pyfstat.GridSearch(
52 label=label + f"CW{'BSGL' if BSGL else ''}",
53 outdir=data.outdir,
54 sftfilepattern=os.path.join(data.outdir, f"*{data.label}*sft"),
55 F0s=F0s,
56 F1s=F1s,
57 F2s=F2s,
58 Alphas=Alphas,
59 Deltas=Deltas,
60 tref=data.tref,
61 BSGL=BSGL,
62 )
63 search1.run()
64 search1.print_max_twoF()
65 search1.plot_1D(
66 xkey="F0", xlabel="freq [Hz]", ylabel=search1.tex_labels[search1.detstat]
67 )
68
69 logger.info("with t0,tau bands:")
70 label = f"tCW{'_BSGL' if BSGL else ''}{'_BtSG' if BtSG else ''}_FstatMap_{tCWFstatMapVersion}"
71 search2 = pyfstat.TransientGridSearch(
72 label=label,
73 outdir=data.outdir,
74 sftfilepattern=os.path.join(data.outdir, f"*{data.label}*sft"),
75 F0s=F0s,
76 F1s=F1s,
77 F2s=F2s,
78 Alphas=Alphas,
79 Deltas=Deltas,
80 tref=data.tref,
81 transientWindowType="rect",
82 t0Band=data.duration - 2 * data.Tsft,
83 tauBand=data.duration,
84 outputTransientFstatMap=True,
85 tCWFstatMapVersion=tCWFstatMapVersion,
86 BSGL=BSGL,
87 BtSG=BtSG,
88 )
89 search2.run()
90 search2.print_max_twoF()
91 search2.plot_1D(
92 xkey="F0", xlabel="freq [Hz]", ylabel=search2.tex_labels[search2.detstat]
93 )
Total running time of the script: ( 0 minutes 0.000 seconds)