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 = "PyFstatExampleMCMCSearchUsingInitialisation"
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 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 (expectation over noise realizations) can be accessed by
48 twoF = data.predict_fstat()
49 logger.info("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 logger.info("\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 = 1
73 log10beta_min = -1
74 nwalkers = 100
75 nsteps = [100, 100]
76
77 mcmc = pyfstat.MCMCSearch(
78     label=label,
79     outdir=outdir,
80     sftfilepattern=data.sftfilepath,
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.setup_initialisation(100, scatter_val=1e-10)
91 mcmc.run(
92     walker_plot_args={"plot_det_stat": True, "injection_parameters": signal_parameters}
93 )
94 mcmc.print_summary()
95 mcmc.plot_corner(add_prior=True, truths=signal_parameters)
96 mcmc.plot_prior_posterior(injection_parameters=signal_parameters)

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

Gallery generated by Sphinx-Gallery