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