Note
Click here to download the full example code
Directed grid search: Linear spindown
Search for CW signal including one spindown parameter using a parameter space grid (i.e. no MCMC).
8 import os
9
10 import numpy as np
11
12 import pyfstat
13
14 label = "PyFstat_example_grid_search_F0F1"
15 outdir = os.path.join("PyFstat_example_data", label)
16
17 # Properties of the GW data
18 sqrtSX = 1e-23
19 tstart = 1000000000
20 duration = 10 * 86400
21 tend = tstart + duration
22 tref = 0.5 * (tstart + tend)
23 IFOs = "H1"
24
25 # parameters for injected signals
26 depth = 20
27 inj = {
28 "tref": tref,
29 "F0": 30.0,
30 "F1": -1e-10,
31 "F2": 0,
32 "Alpha": 1.0,
33 "Delta": 1.5,
34 "h0": sqrtSX / depth,
35 "cosi": 0.0,
36 }
37
38 data = pyfstat.Writer(
39 label=label,
40 outdir=outdir,
41 tstart=tstart,
42 duration=duration,
43 sqrtSX=sqrtSX,
44 detectors=IFOs,
45 **inj,
46 )
47 data.make_data()
48
49 m = 0.01
50 dF0 = np.sqrt(12 * m) / (np.pi * duration)
51 dF1 = np.sqrt(180 * m) / (np.pi * duration**2)
52 dF2 = 1e-17
53 N = 100
54 DeltaF0 = N * dF0
55 DeltaF1 = N * dF1
56 F0s = [inj["F0"] - DeltaF0 / 2.0, inj["F0"] + DeltaF0 / 2.0, dF0]
57 F1s = [inj["F1"] - DeltaF1 / 2.0, inj["F1"] + DeltaF1 / 2.0, dF1]
58 F2s = [inj["F2"]]
59 Alphas = [inj["Alpha"]]
60 Deltas = [inj["Delta"]]
61 search = pyfstat.GridSearch(
62 label=label,
63 outdir=outdir,
64 sftfilepattern=data.sftfilepath,
65 F0s=F0s,
66 F1s=F1s,
67 F2s=F2s,
68 Alphas=Alphas,
69 Deltas=Deltas,
70 tref=tref,
71 minStartTime=tstart,
72 maxStartTime=tend,
73 )
74 search.run()
75
76 # report details of the maximum point
77 max_dict = search.get_max_twoF()
78 print(
79 "max2F={:.4f} from GridSearch, offsets from injection: {:s}.".format(
80 max_dict["twoF"],
81 ", ".join(
82 [
83 "{:.4e} in {:s}".format(max_dict[key] - inj[key], key)
84 for key in max_dict.keys()
85 if not key == "twoF"
86 ]
87 ),
88 )
89 )
90 search.generate_loudest()
91
92 print("Plotting 2F(F0)...")
93 search.plot_1D(xkey="F0", xlabel="freq [Hz]", ylabel="$2\\mathcal{F}$")
94 print("Plotting 2F(F1)...")
95 search.plot_1D(xkey="F1")
96 print("Plotting 2F(F0,F1)...")
97 search.plot_2D(xkey="F0", ykey="F1", colorbar=True)
98
99 print("Making gridcorner plot...")
100 F0_vals = np.unique(search.data["F0"]) - inj["F0"]
101 F1_vals = np.unique(search.data["F1"]) - inj["F1"]
102 twoF = search.data["twoF"].reshape((len(F0_vals), len(F1_vals)))
103 xyz = [F0_vals, F1_vals]
104 labels = [
105 "$f - f_0$",
106 "$\\dot{f} - \\dot{f}_0$",
107 "$\\widetilde{2\\mathcal{F}}$",
108 ]
109 fig, axes = pyfstat.gridcorner(
110 twoF, xyz, projection="log_mean", labels=labels, whspace=0.1, factor=1.8
111 )
112 fig.savefig(os.path.join(outdir, label + "_projection_matrix.png"))
Total running time of the script: ( 0 minutes 0.000 seconds)