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