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

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

Gallery generated by Sphinx-Gallery