semi_coherent_search_using_MCMC.py 1.83 KB
Newer Older
1
import pyfstat
Gregory Ashton's avatar
Gregory Ashton committed
2
import numpy as np
3

Gregory Ashton's avatar
Gregory Ashton committed
4
5
6
7
8
9
10
# Properties of the GW data
sqrtSX = 1e-23
tstart = 1000000000
duration = 100*86400
tend = tstart + duration

# Properties of the signal
11
12
13
F0 = 30.0
F1 = -1e-10
F2 = 0
Gregory Ashton's avatar
Gregory Ashton committed
14
15
16
Alpha = np.radians(83.6292)
Delta = np.radians(22.0144)
tref = .5*(tstart+tend)
17

Gregory Ashton's avatar
Gregory Ashton committed
18
19
depth = 10
h0 = sqrtSX / depth
20
label = 'semicoherent_search_using_MCMC'
Gregory Ashton's avatar
Gregory Ashton committed
21
22
23
24
25
26
27
28
29
30
outdir = 'data'

data = pyfstat.Writer(
    label=label, outdir=outdir, tref=tref,
    tstart=tstart, F0=F0, F1=F1, F2=F2, duration=duration, Alpha=Alpha,
    Delta=Delta, h0=h0, sqrtSX=sqrtSX)
data.make_data()

# The predicted twoF, given by lalapps_predictFstat can be accessed by
twoF = data.predict_fstat()
31
print('Predicted twoF value: {}\n'.format(twoF))
Gregory Ashton's avatar
Gregory Ashton committed
32
33
34
35
36

DeltaF0 = 1e-7
DeltaF1 = 1e-13
VF0 = (np.pi * duration * DeltaF0)**2 / 3.0
VF1 = (np.pi * duration**2 * DeltaF1)**2 * 4/45.
37
print('\nV={:1.2e}, VF0={:1.2e}, VF1={:1.2e}\n'.format(VF0*VF1, VF0, VF1))
38

Gregory Ashton's avatar
Gregory Ashton committed
39
40
41
42
43
44
theta_prior = {'F0': {'type': 'unif',
                      'lower': F0-DeltaF0/2.,
                      'upper': F0+DeltaF0/2.},
               'F1': {'type': 'unif',
                      'lower': F1-DeltaF1/2.,
                      'upper': F1+DeltaF1/2.},
45
46
47
48
49
50
               'F2': F2,
               'Alpha': Alpha,
               'Delta': Delta
               }

ntemps = 1
51
log10beta_min = -1
52
nwalkers = 100
Gregory Ashton's avatar
Gregory Ashton committed
53
nsteps = [300, 300]
54
55

mcmc = pyfstat.MCMCSemiCoherentSearch(
56
    label=label, outdir=outdir, nsegs=10,
Gregory Ashton's avatar
Gregory Ashton committed
57
58
59
60
    sftfilepattern='{}/*{}*sft'.format(outdir, label),
    theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend,
    nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps,
    log10beta_min=log10beta_min)
61
62
63
mcmc.transform_dictionary = dict(
    F0=dict(subtractor=F0, symbol='$f-f^\mathrm{s}$'),
    F1=dict(subtractor=F1, symbol='$\dot{f}-\dot{f}^\mathrm{s}$'))
64
65
66
mcmc.run()
mcmc.plot_corner(add_prior=True)
mcmc.print_summary()