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