MCMC search: Fully coherent F-statistic

Directed MCMC search for an isolated CW signal using the fully coherent F-statistic.

  9 import os
 10
 11 import numpy as np
 12
 13 import pyfstat
 14 from pyfstat.helper_functions import get_predict_fstat_parameters_from_dict
 15
 16 label = "PyFstat_example_fully_coherent_MCMC_search"
 17 outdir = os.path.join("PyFstat_example_data", label)
 18
 19 # Properties of the GW data
 20 data_parameters = {
 21     "sqrtSX": 1e-23,
 22     "tstart": 1000000000,
 23     "duration": 100 * 86400,
 24     "detectors": "H1",
 25 }
 26 tend = data_parameters["tstart"] + data_parameters["duration"]
 27 mid_time = 0.5 * (data_parameters["tstart"] + tend)
 28
 29 # Properties of the signal
 30 depth = 10
 31 signal_parameters = {
 32     "F0": 30.0,
 33     "F1": -1e-10,
 34     "F2": 0,
 35     "Alpha": np.radians(83.6292),
 36     "Delta": np.radians(22.0144),
 37     "tref": mid_time,
 38     "h0": data_parameters["sqrtSX"] / depth,
 39     "cosi": 1.0,
 40 }
 41
 42 data = pyfstat.Writer(
 43     label=label, outdir=outdir, **data_parameters, **signal_parameters
 44 )
 45 data.make_data()
 46
 47 # The predicted twoF, given by lalapps_predictFstat can be accessed by
 48 twoF = data.predict_fstat()
 49 print("Predicted twoF value: {}\n".format(twoF))
 50
 51 DeltaF0 = 1e-7
 52 DeltaF1 = 1e-13
 53 VF0 = (np.pi * data_parameters["duration"] * DeltaF0) ** 2 / 3.0
 54 VF1 = (np.pi * data_parameters["duration"] ** 2 * DeltaF1) ** 2 * 4 / 45.0
 55 print("\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n".format(VF0 * VF1, VF0, VF1))
 56
 57 theta_prior = {
 58     "F0": {
 59         "type": "unif",
 60         "lower": signal_parameters["F0"] - DeltaF0 / 2.0,
 61         "upper": signal_parameters["F0"] + DeltaF0 / 2.0,
 62     },
 63     "F1": {
 64         "type": "unif",
 65         "lower": signal_parameters["F1"] - DeltaF1 / 2.0,
 66         "upper": signal_parameters["F1"] + DeltaF1 / 2.0,
 67     },
 68 }
 69 for key in "F2", "Alpha", "Delta":
 70     theta_prior[key] = signal_parameters[key]
 71
 72 ntemps = 2
 73 log10beta_min = -0.5
 74 nwalkers = 100
 75 nsteps = [300, 300]
 76
 77 mcmc = pyfstat.MCMCSearch(
 78     label=label,
 79     outdir=outdir,
 80     sftfilepattern=os.path.join(outdir, "*{}*sft".format(label)),
 81     theta_prior=theta_prior,
 82     tref=mid_time,
 83     minStartTime=data_parameters["tstart"],
 84     maxStartTime=tend,
 85     nsteps=nsteps,
 86     nwalkers=nwalkers,
 87     ntemps=ntemps,
 88     log10beta_min=log10beta_min,
 89 )
 90 mcmc.transform_dictionary = dict(
 91     F0=dict(subtractor=signal_parameters["F0"], symbol="$f-f^\\mathrm{s}$"),
 92     F1=dict(
 93         subtractor=signal_parameters["F1"], symbol="$\\dot{f}-\\dot{f}^\\mathrm{s}$"
 94     ),
 95 )
 96 mcmc.run(
 97     walker_plot_args={"plot_det_stat": True, "injection_parameters": signal_parameters}
 98 )
 99 mcmc.print_summary()
100 mcmc.plot_corner(add_prior=True, truths=signal_parameters)
101 mcmc.plot_prior_posterior(injection_parameters=signal_parameters)
102
103 mcmc.generate_loudest()
104
105 # plot cumulative 2F, first building a dict as required for PredictFStat
106 d, maxtwoF = mcmc.get_max_twoF()
107 for key, val in mcmc.theta_prior.items():
108     if key not in d:
109         d[key] = val
110 d["h0"] = data.h0
111 d["cosi"] = data.cosi
112 d["psi"] = data.psi
113 PFS_input = get_predict_fstat_parameters_from_dict(d)
114 mcmc.plot_cumulative_max(PFS_input=PFS_input)

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

Gallery generated by Sphinx-Gallery