transient_search_using_MCMC.py 2.68 KB
Newer Older
1
2
import pyfstat
import numpy as np
Gregory Ashton's avatar
Gregory Ashton committed
3
4
5
import matplotlib.pyplot as plt

plt.style.use('thesis')
Gregory Ashton's avatar
Gregory Ashton committed
6
7
8
9
10
11
12
13
14

F0 = 30.0
F1 = -1e-10
F2 = 0
Alpha = 5e-3
Delta = 6e-2

tstart = 1000000000
duration = 100*86400
15
16
17
data_tstart = tstart - duration
data_tend = data_tstart + 3*duration
tref = .5*(data_tstart+data_tend)
Gregory Ashton's avatar
Gregory Ashton committed
18

19
20
21
22
23
24
25
26
h0 = 1e-23
sqrtSX = 1e-22

transient = pyfstat.Writer(
    label='transient', outdir='data', tref=tref, tstart=tstart, F0=F0, F1=F1,
    F2=F2, duration=duration, Alpha=Alpha, Delta=Delta, h0=h0, sqrtSX=sqrtSX,
    minStartTime=data_tstart, maxStartTime=data_tend)
transient.make_data()
Gregory Ashton's avatar
Gregory Ashton committed
27
28
29
print transient.predict_fstat()


30
31
32
33
34
35
36
37
38
39
40
41
42

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

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

48
ntemps = 3
Gregory Ashton's avatar
Gregory Ashton committed
49
50
log10temperature_min = -1
nwalkers = 100
51
52
53
54
55
56
57
58
59
60
nsteps = [750, 250]

mcmc = pyfstat.MCMCSearch(
    label='transient_search_initial_stage', outdir='data',
    sftfilepath='data/*transient*sft', theta_prior=theta_prior, tref=tref,
    minStartTime=data_tstart, maxStartTime=data_tend, nsteps=nsteps,
    nwalkers=nwalkers, ntemps=ntemps,
    log10temperature_min=log10temperature_min)
mcmc.run()
mcmc.plot_cumulative_max()
Gregory Ashton's avatar
Gregory Ashton committed
61
mcmc.print_summary()
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

theta_prior = {'F0': {'type': 'unif',
                      'lower': F0-DeltaF0/2.,
                      'upper': F0+DeltaF0/2.},
               'F1': {'type': 'unif',
                      'lower': F1-DeltaF1/2.,
                      'upper': F1+DeltaF1/2.},
               'F2': F2,
               'Alpha': Alpha,
               'Delta': Delta,
               'transient_tstart': {'type': 'unif',
                                    'lower': data_tstart,
                                    'upper': data_tend},
               'transient_duration': {'type': 'halfnorm',
                                      'loc': 0,
                                      'scale': 0.5*duration}
               }

nwalkers = 500
nsteps = [200, 200]
Gregory Ashton's avatar
Gregory Ashton committed
82

83
84
mcmc = pyfstat.MCMCTransientSearch(
    label='transient_search', outdir='data',
Gregory Ashton's avatar
Gregory Ashton committed
85
    sftfilepath='data/*transient*sft', theta_prior=theta_prior, tref=tref,
86
87
    minStartTime=data_tstart, maxStartTime=data_tend, nsteps=nsteps,
    nwalkers=nwalkers, ntemps=ntemps,
Gregory Ashton's avatar
Gregory Ashton committed
88
89
90
91
    log10temperature_min=log10temperature_min)
mcmc.run()
mcmc.plot_corner(add_prior=True)
mcmc.print_summary()