Note
Click here to download the full example code
Glitch robust grid searchΒΆ
Grid search employing a signal hypothesis allowing for a glitch to be present in the data. The setup corresponds to a targeted search, and the simulated signal contains a single glitch.
10 import pyfstat
11 import numpy as np
12 from PyFstat_example_make_data_for_search_on_1_glitch import (
13 tstart,
14 duration,
15 tref,
16 F0,
17 F1,
18 F2,
19 Alpha,
20 Delta,
21 delta_F0,
22 outdir,
23 dtglitch,
24 )
25 import time
26 import os
27
28 label = "PyFstat_example_glitch_robust_directed_grid_search_on_1_glitch"
29
30 Nstar = 1000
31 F0_width = np.sqrt(Nstar) * np.sqrt(12) / (np.pi * duration)
32 F1_width = np.sqrt(Nstar) * np.sqrt(180) / (np.pi * duration ** 2)
33 N = 20
34 F0s = [F0 - F0_width / 2.0, F0 + F0_width / 2.0, F0_width / N]
35 F1s = [F1 - F1_width / 2.0, F1 + F1_width / 2.0, F1_width / N]
36 F2s = [F2]
37 Alphas = [Alpha]
38 Deltas = [Delta]
39
40 max_delta_F0 = 1e-5
41 tglitchs = [tstart + 0.1 * duration, tstart + 0.9 * duration, 0.8 * float(duration) / N]
42 delta_F0s = [0, max_delta_F0, max_delta_F0 / N]
43 delta_F1s = [0]
44
45
46 t1 = time.time()
47 search = pyfstat.GridGlitchSearch(
48 label,
49 outdir,
50 os.path.join(outdir, "*1_glitch*sft"),
51 F0s=F0s,
52 F1s=F1s,
53 F2s=F2s,
54 Alphas=Alphas,
55 Deltas=Deltas,
56 tref=tref,
57 minStartTime=tstart,
58 maxStartTime=tstart + duration,
59 tglitchs=tglitchs,
60 delta_F0s=delta_F0s,
61 delta_F1s=delta_F1s,
62 )
63 search.run()
64 dT = time.time() - t1
65
66 F0_vals = np.unique(search.data["F0"]) - F0
67 F1_vals = np.unique(search.data["F1"]) - F1
68 delta_F0s_vals = np.unique(search.data["delta_F0"]) - delta_F0
69 tglitch_vals = np.unique(search.data["tglitch"])
70 tglitch_vals_days = (tglitch_vals - tstart) / 86400.0 - dtglitch / 86400.0
71
72 print("Making gridcorner plot...")
73 twoF = search.data["twoF"].reshape(
74 (len(F0_vals), len(F1_vals), len(delta_F0s_vals), len(tglitch_vals))
75 )
76 xyz = [F0_vals * 1e6, F1_vals * 1e12, delta_F0s_vals * 1e6, tglitch_vals_days]
77 labels = [
78 "$f - f_\\mathrm{s}$\n[$\\mu$Hz]",
79 "$\\dot{f} - \\dot{f}_\\mathrm{s}$\n[$p$Hz/s]",
80 "$\\delta f-\\delta f_\\mathrm{s}$\n[$\\mu$Hz]",
81 "$t^\\mathrm{g} - t^\\mathrm{g}_\\mathrm{s}$\n[d]",
82 "$t^\\mathrm{g} - t^\\mathrm{g}_\\mathrm{s}$\n[d]",
83 "$\\widehat{2\\mathcal{F}}$",
84 ]
85 fig, axes = pyfstat.gridcorner(
86 twoF,
87 xyz,
88 projection="log_mean",
89 labels=labels,
90 showDvals=False,
91 lines=[0, 0, 0, 0],
92 label_offset=0.25,
93 max_n_ticks=4,
94 )
95 fig.savefig("{}/{}_projection_matrix.png".format(outdir, label), bbox_inches="tight")
96
97
98 print(("Prior widths =", F0_width, F1_width))
99 print(("Actual run time = {}".format(dT)))
100 print(("Actual number of grid points = {}".format(search.data.shape[0])))
Total running time of the script: ( 0 minutes 0.000 seconds)