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

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

Gallery generated by Sphinx-Gallery