MCMC search: Semicoherent F-statistic with initialisation

Directed MCMC search for an isolated CW signal using the fully-coherent F-statistic. Prior to the burn-in stage, walkers are initialized with a certain scattering factor.

 9 import pyfstat
10 import numpy as np
11 import os
12
13 label = "PyFstat_example_MCMC_search_using_initialisation"
14 outdir = os.path.join("PyFstat_example_data", label)
15
16 # Properties of the GW data
17 data_parameters = {
18     "sqrtSX": 1e-23,
19     "tstart": 1000000000,
20     "duration": 100 * 86400,
21     "detectors": "H1",
22 }
23 tend = data_parameters["tstart"] + data_parameters["duration"]
24 mid_time = 0.5 * (data_parameters["tstart"] + tend)
25
26 # Properties of the signal
27 depth = 10
28 signal_parameters = {
29     "F0": 30.0,
30     "F1": -1e-10,
31     "F2": 0,
32     "Alpha": np.radians(83.6292),
33     "Delta": np.radians(22.0144),
34     "tref": mid_time,
35     "h0": data_parameters["sqrtSX"] / depth,
36     "cosi": 1.0,
37 }
38
39 data = pyfstat.Writer(
40     label=label, outdir=outdir, **data_parameters, **signal_parameters
41 )
42 data.make_data()
43
44 # The predicted twoF, given by lalapps_predictFstat can be accessed by
45 twoF = data.predict_fstat()
46 print("Predicted twoF value: {}\n".format(twoF))
47
48 DeltaF0 = 1e-7
49 DeltaF1 = 1e-13
50 VF0 = (np.pi * data_parameters["duration"] * DeltaF0) ** 2 / 3.0
51 VF1 = (np.pi * data_parameters["duration"] ** 2 * DeltaF1) ** 2 * 4 / 45.0
52 print("\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n".format(VF0 * VF1, VF0, VF1))
53
54 theta_prior = {
55     "F0": {
56         "type": "unif",
57         "lower": signal_parameters["F0"] - DeltaF0 / 2.0,
58         "upper": signal_parameters["F0"] + DeltaF0 / 2.0,
59     },
60     "F1": {
61         "type": "unif",
62         "lower": signal_parameters["F1"] - DeltaF1 / 2.0,
63         "upper": signal_parameters["F1"] + DeltaF1 / 2.0,
64     },
65 }
66 for key in "F2", "Alpha", "Delta":
67     theta_prior[key] = signal_parameters[key]
68
69 ntemps = 1
70 log10beta_min = -1
71 nwalkers = 100
72 nsteps = [100, 100]
73
74 mcmc = pyfstat.MCMCSearch(
75     label=label,
76     outdir=outdir,
77     sftfilepattern=os.path.join(outdir, "*{}*sft".format(label)),
78     theta_prior=theta_prior,
79     tref=mid_time,
80     minStartTime=data_parameters["tstart"],
81     maxStartTime=tend,
82     nsteps=nsteps,
83     nwalkers=nwalkers,
84     ntemps=ntemps,
85     log10beta_min=log10beta_min,
86 )
87 mcmc.setup_initialisation(100, scatter_val=1e-10)
88 mcmc.run(
89     walker_plot_args={"plot_det_stat": True, "injection_parameters": signal_parameters}
90 )
91 mcmc.print_summary()
92 mcmc.plot_corner(add_prior=True, truths=signal_parameters)
93 mcmc.plot_prior_posterior(injection_parameters=signal_parameters)

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

Gallery generated by Sphinx-Gallery