Directed grid search: Monochromatic source

Search for a monochromatic (no spindown) signal using a parameter space grid (i.e. no MCMC).

  8 import pyfstat
  9 import numpy as np
 10 import matplotlib.pyplot as plt
 11 import os
 12
 13 label = "PyFstat_example_grid_search_F0"
 14 outdir = os.path.join("PyFstat_example_data", label)
 15
 16 # Properties of the GW data
 17 sqrtS = "1e-23"
 18 IFOs = "H1"
 19 # IFOs = "H1,L1"
 20 sqrtSX = ",".join(np.repeat(sqrtS, len(IFOs.split(","))))
 21 tstart = 1000000000
 22 duration = 100 * 86400
 23 tend = tstart + duration
 24 tref = 0.5 * (tstart + tend)
 25
 26 # parameters for injected signals
 27 depth = 70
 28 inj = {
 29     "tref": tref,
 30     "F0": 30.0,
 31     "F1": 0,
 32     "F2": 0,
 33     "Alpha": 1.0,
 34     "Delta": 1.5,
 35     "h0": float(sqrtS) / depth,
 36     "cosi": 0.0,
 37 }
 38
 39 data = pyfstat.Writer(
 40     label=label,
 41     outdir=outdir,
 42     tstart=tstart,
 43     duration=duration,
 44     sqrtSX=sqrtSX,
 45     detectors=IFOs,
 46     **inj,
 47 )
 48 data.make_data()
 49
 50 m = 0.001
 51 dF0 = np.sqrt(12 * m) / (np.pi * duration)
 52 DeltaF0 = 800 * dF0
 53 F0s = [inj["F0"] - DeltaF0 / 2.0, inj["F0"] + DeltaF0 / 2.0, dF0]
 54 F1s = [inj["F1"]]
 55 F2s = [inj["F2"]]
 56 Alphas = [inj["Alpha"]]
 57 Deltas = [inj["Delta"]]
 58 search = pyfstat.GridSearch(
 59     label=label,
 60     outdir=outdir,
 61     sftfilepattern=os.path.join(outdir, "*" + label + "*sft"),
 62     F0s=F0s,
 63     F1s=F1s,
 64     F2s=F2s,
 65     Alphas=Alphas,
 66     Deltas=Deltas,
 67     tref=tref,
 68     minStartTime=tstart,
 69     maxStartTime=tend,
 70 )
 71 search.run()
 72
 73 # report details of the maximum point
 74 max_dict = search.get_max_twoF()
 75 print(
 76     "max2F={:.4f} from GridSearch, offsets from injection: {:s}.".format(
 77         max_dict["twoF"],
 78         ", ".join(
 79             [
 80                 "{:.4e} in {:s}".format(max_dict[key] - inj[key], key)
 81                 for key in max_dict.keys()
 82                 if not key == "twoF"
 83             ]
 84         ),
 85     )
 86 )
 87 search.generate_loudest()
 88
 89 print("Plotting 2F(F0)...")
 90 fig, ax = plt.subplots()
 91 frequencies = search.data["F0"]
 92 twoF = search.data["twoF"]
 93 # mismatch = np.sign(x-inj["F0"])*(duration * np.pi * (x - inj["F0"]))**2 / 12.0
 94 ax.plot(frequencies, twoF, "k", lw=1)
 95 DeltaF = frequencies - inj["F0"]
 96 sinc = np.sin(np.pi * DeltaF * duration) / (np.pi * DeltaF * duration)
 97 A = np.abs((np.max(twoF) - 4) * sinc**2 + 4)
 98 ax.plot(frequencies, A, "-r", lw=1)
 99 ax.set_ylabel("$\\widetilde{2\\mathcal{F}}$")
100 ax.set_xlabel("Frequency")
101 ax.set_xlim(F0s[0], F0s[1])
102 dF0 = np.sqrt(12 * 1) / (np.pi * duration)
103 xticks = [inj["F0"] - 10 * dF0, inj["F0"], inj["F0"] + 10 * dF0]
104 ax.set_xticks(xticks)
105 xticklabels = ["$f_0 {-} 10\\Delta f$", "$f_0$", "$f_0 {+} 10\\Delta f$"]
106 ax.set_xticklabels(xticklabels)
107 plt.tight_layout()
108 fig.savefig(os.path.join(outdir, label + "_1D.png"), dpi=300)

Total running time of the script: ( 0 minutes 0.000 seconds)

Gallery generated by Sphinx-Gallery