Directed grid search: Quadratic spindown

Search for CW signal including two spindown parameters using a parameter space grid (i.e. no MCMC).

  9 import os
 10
 11 import numpy as np
 12
 13 import pyfstat
 14
 15 label = "PyFstatExampleGridSearchF0F1F2"
 16 outdir = os.path.join("PyFstat_example_data", label)
 17 logger = pyfstat.set_up_logger(label=label, outdir=outdir)
 18
 19 # Properties of the GW data
 20 sqrtSX = 1e-23
 21 tstart = 1000000000
 22 duration = 10 * 86400
 23 tend = tstart + duration
 24 tref = 0.5 * (tstart + tend)
 25 IFOs = "H1"
 26
 27 # parameters for injected signals
 28 depth = 20
 29 inj = {
 30     "tref": tref,
 31     "F0": 30.0,
 32     "F1": -1e-10,
 33     "F2": 0,
 34     "Alpha": 1.0,
 35     "Delta": 1.5,
 36     "h0": sqrtSX / depth,
 37     "cosi": 0.0,
 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 DeltaF2 = N * dF2
 58 F0s = [inj["F0"] - DeltaF0 / 2.0, inj["F0"] + DeltaF0 / 2.0, dF0]
 59 F1s = [inj["F1"] - DeltaF1 / 2.0, inj["F1"] + DeltaF1 / 2.0, dF1]
 60 F2s = [inj["F2"] - DeltaF2 / 2.0, inj["F2"] + DeltaF2 / 2.0, dF2]
 61 Alphas = [inj["Alpha"]]
 62 Deltas = [inj["Delta"]]
 63 search = pyfstat.GridSearch(
 64     label=label,
 65     outdir=outdir,
 66     sftfilepattern=data.sftfilepath,
 67     F0s=F0s,
 68     F1s=F1s,
 69     F2s=F2s,
 70     Alphas=Alphas,
 71     Deltas=Deltas,
 72     tref=tref,
 73     minStartTime=tstart,
 74     maxStartTime=tend,
 75 )
 76 search.run()
 77
 78 # report details of the maximum point
 79 max_dict = search.get_max_twoF()
 80 logger.info(
 81     "max2F={:.4f} from GridSearch, offsets from injection: {:s}.".format(
 82         max_dict["twoF"],
 83         ", ".join(
 84             [
 85                 "{:.4e} in {:s}".format(max_dict[key] - inj[key], key)
 86                 for key in max_dict.keys()
 87                 if not key == "twoF"
 88             ]
 89         ),
 90     )
 91 )
 92 search.generate_loudest()
 93
 94 # FIXME: workaround for matplotlib "Exceeded cell block limit" errors
 95 agg_chunksize = 10000
 96
 97 logger.info("Plotting 2F(F0)...")
 98 search.plot_1D(
 99     xkey="F0", xlabel="freq [Hz]", ylabel="$2\\mathcal{F}$", agg_chunksize=agg_chunksize
100 )
101 logger.info("Plotting 2F(F1)...")
102 search.plot_1D(xkey="F1", agg_chunksize=agg_chunksize)
103 logger.info("Plotting 2F(F2)...")
104 search.plot_1D(xkey="F2", agg_chunksize=agg_chunksize)
105 logger.info("Plotting 2F(Alpha)...")
106 search.plot_1D(xkey="Alpha", agg_chunksize=agg_chunksize)
107 logger.info("Plotting 2F(Delta)...")
108 search.plot_1D(xkey="Delta", agg_chunksize=agg_chunksize)
109 # 2D plots will currently not work for >2 non-trivial (gridded) search dimensions
110 # search.plot_2D(xkey="F0",ykey="F1",colorbar=True)
111 # search.plot_2D(xkey="F0",ykey="F2",colorbar=True)
112 # search.plot_2D(xkey="F1",ykey="F2",colorbar=True)
113
114 logger.info("Making gridcorner plot...")
115 F0_vals = np.unique(search.data["F0"]) - inj["F0"]
116 F1_vals = np.unique(search.data["F1"]) - inj["F1"]
117 F2_vals = np.unique(search.data["F2"]) - inj["F2"]
118 twoF = search.data["twoF"].reshape((len(F0_vals), len(F1_vals), len(F2_vals)))
119 xyz = [F0_vals, F1_vals, F2_vals]
120 labels = [
121     "$f - f_0$",
122     "$\\dot{f} - \\dot{f}_0$",
123     "$\\ddot{f} - \\ddot{f}_0$",
124     "$\\widetilde{2\\mathcal{F}}$",
125 ]
126 fig, axes = pyfstat.gridcorner(
127     twoF, xyz, projection="log_mean", labels=labels, whspace=0.1, factor=1.8
128 )
129 fig.savefig(os.path.join(outdir, label + "_projection_matrix.png"))

Gallery generated by Sphinx-Gallery