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