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
28 logger = pyfstat.set_up_logger(
29 label="short_transient_grid_search", outdir=data.outdir
30 )
31 if not os.path.isdir(data.outdir) or not np.any(
32 [f.endswith(".sft") for f in os.listdir(data.outdir)]
33 ):
34 raise RuntimeError(
35 "Please first run PyFstat_example_make_data_for_short_transient_search.py !"
36 )
37
38 maxStartTime = data.tstart + data.duration
39
40 m = 0.001
41 dF0 = np.sqrt(12 * m) / (np.pi * data.duration)
42 DeltaF0 = 100 * dF0
43 F0s = [data.F0 - DeltaF0 / 2.0, data.F0 + DeltaF0 / 2.0, dF0]
44 F1s = [data.F1]
45 F2s = [data.F2]
46 Alphas = [data.Alpha]
47 Deltas = [data.Delta]
48
49 BSGL = False
50 BtSG = False
51
52 logger.info("Standard CW search:")
53 search1 = pyfstat.GridSearch(
54 label=f"CW{'_BSGL' if BSGL else ''}",
55 outdir=data.outdir,
56 sftfilepattern=os.path.join(data.outdir, "*simulated_transient_signal*sft"),
57 F0s=F0s,
58 F1s=F1s,
59 F2s=F2s,
60 Alphas=Alphas,
61 Deltas=Deltas,
62 tref=data.tref,
63 BSGL=BSGL,
64 )
65 search1.run()
66 search1.print_max_twoF()
67 search1.plot_1D(
68 xkey="F0", xlabel="freq [Hz]", ylabel=search1.tex_labels[search1.detstat]
69 )
70
71 logger.info("with t0,tau bands:")
72 label = f"tCW{'_BSGL' if BSGL else ''}{'_BtSG' if BtSG else ''}_FstatMap_{tCWFstatMapVersion}"
73 search2 = pyfstat.TransientGridSearch(
74 label=label,
75 outdir=data.outdir,
76 sftfilepattern=os.path.join(data.outdir, "*simulated_transient_signal*sft"),
77 F0s=F0s,
78 F1s=F1s,
79 F2s=F2s,
80 Alphas=Alphas,
81 Deltas=Deltas,
82 tref=data.tref,
83 transientWindowType="rect",
84 t0Band=data.duration - 2 * data.Tsft,
85 tauBand=data.duration,
86 outputTransientFstatMap=True,
87 tCWFstatMapVersion=tCWFstatMapVersion,
88 BSGL=BSGL,
89 BtSG=BtSG,
90 )
91 search2.run()
92 search2.print_max_twoF()
93 search2.plot_1D(
94 xkey="F0", xlabel="freq [Hz]", ylabel=search2.tex_labels[search2.detstat]
95 )
Total running time of the script: ( 0 minutes 0.000 seconds)