Directed grid search: Quadratic spindown

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

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