Note
Click here to download the full example code
Cumulative coherent 2FΒΆ
Compute the cumulative coherent F-statistic of a signal candidate.
9 import os
10
11 import numpy as np
12
13 import pyfstat
14 from pyfstat.utils import get_predict_fstat_parameters_from_dict
15
16 label = "PyFstat_example_twoF_cumulative"
17 outdir = os.path.join("PyFstat_example_data", label)
18 logger = pyfstat.set_up_logger(label=label, outdir=outdir)
19
20 # Properties of the GW data
21 gw_data = {
22 "sqrtSX": 1e-23,
23 "tstart": 1000000000,
24 "duration": 100 * 86400,
25 "detectors": "H1,L1",
26 "Band": 4,
27 "Tsft": 1800,
28 }
29
30 # Properties of the signal
31 depth = 100
32 phase_parameters = {
33 "F0": 30.0,
34 "F1": -1e-10,
35 "F2": 0,
36 "Alpha": np.radians(83.6292),
37 "Delta": np.radians(22.0144),
38 "tref": gw_data["tstart"],
39 "asini": 10,
40 "period": 10 * 3600 * 24,
41 "tp": gw_data["tstart"] + gw_data["duration"] / 2.0,
42 "ecc": 0,
43 "argp": 0,
44 }
45 amplitude_parameters = {
46 "h0": gw_data["sqrtSX"] / depth,
47 "cosi": 1,
48 "phi": np.pi,
49 "psi": np.pi / 8,
50 }
51
52 PFS_input = get_predict_fstat_parameters_from_dict(
53 {**phase_parameters, **amplitude_parameters}
54 )
55
56 # Let me grab tref here, since it won't really be needed in phase_parameters
57 tref = phase_parameters.pop("tref")
58 data = pyfstat.BinaryModulatedWriter(
59 label=label,
60 outdir=outdir,
61 tref=tref,
62 **gw_data,
63 **phase_parameters,
64 **amplitude_parameters,
65 )
66 data.make_data()
67
68 # The predicted twoF, given by lalapps_predictFstat can be accessed by
69 twoF = data.predict_fstat()
70 logger.info("Predicted twoF value: {}\n".format(twoF))
71
72 # Create a search object for each of the possible SFT combinations
73 # (H1 only, L1 only, H1 + L1).
74 ifo_constraints = ["L1", "H1", None]
75 compute_fstat_per_ifo = [
76 pyfstat.ComputeFstat(
77 sftfilepattern=os.path.join(
78 data.outdir,
79 (f"{ifo_constraint[0]}*.sft" if ifo_constraint is not None else "*.sft"),
80 ),
81 tref=data.tref,
82 binary=phase_parameters.get("asini", 0),
83 minCoverFreq=-0.5,
84 maxCoverFreq=-0.5,
85 )
86 for ifo_constraint in ifo_constraints
87 ]
88
89 for ind, compute_f_stat in enumerate(compute_fstat_per_ifo):
90 compute_f_stat.plot_twoF_cumulative(
91 label=label + (f"_{ifo_constraints[ind]}" if ind < 2 else "_H1L1"),
92 outdir=outdir,
93 savefig=True,
94 CFS_input=phase_parameters,
95 PFS_input=PFS_input,
96 custom_ax_kwargs={
97 "title": "How does 2F accumulate over time?",
98 "label": "Cumulative 2F"
99 + (f" {ifo_constraints[ind]}" if ind < 2 else " H1 + L1"),
100 },
101 )
Total running time of the script: ( 0 minutes 0.000 seconds)