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