Software injection into pre-existing data files

Add a software injection into a set of SFTs.

In this case, the set of SFTs is generated using Makefakedata_v5, but the same procedure can be applied to any other set of SFTs (including real detector data).

 12 import os
 13 import numpy as np
 14 import pyfstat
 15
 16 label = "PyFstat_example_injection_into_noise_sfts"
 17 outdir = os.path.join("PyFstat_example_data", label)
 18
 19 tstart = 1269734418
 20 duration_Tsft = 100
 21 Tsft = 1800
 22 randSeed = 69420
 23 IFO = "H1"
 24 h0 = 1000
 25 cosi = 0
 26 F0 = 30
 27 Alpha = 0
 28 Delta = 0
 29
 30 Band = 2.0
 31
 32 # create sfts with a strong signal in them
 33 # window options are optional here
 34 noise_and_signal_writer = pyfstat.Writer(
 35     label="test_noiseSFTs_noise_and_signal",
 36     outdir=outdir,
 37     h0=h0,
 38     cosi=cosi,
 39     F0=F0,
 40     Alpha=Alpha,
 41     Delta=Delta,
 42     tstart=tstart,
 43     duration=duration_Tsft * Tsft,
 44     Tsft=Tsft,
 45     Band=Band,
 46     detectors=IFO,
 47     randSeed=randSeed,
 48     SFTWindowType="tukey",
 49     SFTWindowBeta=0.001,
 50 )
 51 sftfilepattern = os.path.join(
 52     noise_and_signal_writer.outdir,
 53     "*{}*{}*sft".format(duration_Tsft, noise_and_signal_writer.label),
 54 )
 55
 56 noise_and_signal_writer.make_data()
 57
 58 # compute Fstat
 59 coherent_search = pyfstat.ComputeFstat(
 60     tref=noise_and_signal_writer.tref,
 61     sftfilepattern=sftfilepattern,
 62     minCoverFreq=-0.5,
 63     maxCoverFreq=-0.5,
 64 )
 65 FS_1 = coherent_search.get_fullycoherent_twoF(
 66     noise_and_signal_writer.F0,
 67     noise_and_signal_writer.F1,
 68     noise_and_signal_writer.F2,
 69     noise_and_signal_writer.Alpha,
 70     noise_and_signal_writer.Delta,
 71 )
 72
 73 # create noise sfts
 74 # window options are again optional for this step
 75 noise_writer = pyfstat.Writer(
 76     label="test_noiseSFTs_only_noise",
 77     outdir=outdir,
 78     h0=0,
 79     F0=F0,
 80     tstart=tstart,
 81     duration=duration_Tsft * Tsft,
 82     Tsft=Tsft,
 83     Band=Band,
 84     detectors=IFO,
 85     randSeed=randSeed,
 86     SFTWindowType="tukey",
 87     SFTWindowBeta=0.001,
 88 )
 89 noise_writer.make_data()
 90
 91 # then inject a strong signal
 92 # window options *must* match those previously used for the noiseSFTs
 93 add_signal_writer = pyfstat.Writer(
 94     label="test_noiseSFTs_add_signal",
 95     outdir=outdir,
 96     F0=F0,
 97     Alpha=Alpha,
 98     Delta=Delta,
 99     h0=h0,
100     cosi=cosi,
101     tstart=tstart,
102     duration=duration_Tsft * Tsft,
103     Tsft=Tsft,
104     Band=Band,
105     detectors=IFO,
106     sqrtSX=0,
107     noiseSFTs=os.path.join(
108         noise_writer.outdir, "*{}*{}*sft".format(duration_Tsft, noise_writer.label)
109     ),
110     SFTWindowType="tukey",
111     SFTWindowBeta=0.001,
112 )
113 sftfilepattern = os.path.join(
114     add_signal_writer.outdir,
115     "*{}*{}*sft".format(duration_Tsft, add_signal_writer.label),
116 )
117 add_signal_writer.make_data()
118
119 # compute Fstat
120 coherent_search = pyfstat.ComputeFstat(
121     tref=add_signal_writer.tref,
122     sftfilepattern=sftfilepattern,
123     minCoverFreq=-0.5,
124     maxCoverFreq=-0.5,
125 )
126 FS_2 = coherent_search.get_fullycoherent_twoF(
127     add_signal_writer.F0,
128     add_signal_writer.F1,
129     add_signal_writer.F2,
130     add_signal_writer.Alpha,
131     add_signal_writer.Delta,
132 )
133
134 print("Base case Fstat: {}".format(FS_1))
135 print("Noise + Signal Fstat: {}".format(FS_2))
136 print("Relative Difference: {}".format(np.abs(FS_2 - FS_1) / FS_1))

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

Gallery generated by Sphinx-Gallery