generate_data.py 2.61 KB
Newer Older
1
2
3
import pyfstat
import numpy as np
import os
Gregory Ashton's avatar
Gregory Ashton committed
4
5
6
7
8
9
10
11
import sys

ID = sys.argv[1]
outdir = sys.argv[2]

label = 'run_{}'.format(ID)
data_label = '{}_data'.format(label)
results_file_name = '{}/MCResults_{}.txt'.format(outdir, ID)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

# Properties of the GW data
sqrtSX = 2e-23
tstart = 1000000000
Tspan = 100*86400
tend = tstart + Tspan

# Fixed properties of the signal
F0_center = 30
F1_center = 1e-10
F2 = 0
Alpha = 5e-3
Delta = 6e-2
tref = .5*(tstart+tend)


VF0 = VF1 = 100
DeltaF0 = VF0 * np.sqrt(3)/(np.pi*Tspan)
DeltaF1 = VF1 * np.sqrt(45/4.)/(np.pi*Tspan**2)

Gregory Ashton's avatar
Gregory Ashton committed
32
33
depths = np.linspace(100, 400, 7)
depths = [125, 175]
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

run_setup = [((10, 0), 16, False),
             ((10, 0), 5, False),
             ((10, 10), 1, False)]
for depth in depths:
    h0 = sqrtSX / float(depth)
    r = np.random.uniform(0, 1)
    theta = np.random.uniform(0, 2*np.pi)
    F0 = F0_center + 3*np.sqrt(r)*np.cos(theta)/(np.pi**2 * Tspan**2)
    F1 = F1_center + 45*np.sqrt(r)*np.sin(theta)/(4*np.pi**2 * Tspan**4)

    psi = np.random.uniform(-np.pi/4, np.pi/4)
    phi = np.random.uniform(0, 2*np.pi)
    cosi = np.random.uniform(-1, 1)

    data = pyfstat.Writer(
Gregory Ashton's avatar
Gregory Ashton committed
50
        label=data_label, outdir=outdir, tref=tref,
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
        tstart=tstart, F0=F0, F1=F1, F2=F2, duration=Tspan, Alpha=Alpha,
        Delta=Delta, h0=h0, sqrtSX=sqrtSX, psi=psi, phi=phi, cosi=cosi,
        detector='H1,L1')
    data.make_data()
    predicted_twoF = data.predict_fstat()

    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
                   }

    ntemps = 1
    log10temperature_min = -1
Gregory Ashton's avatar
Gregory Ashton committed
70
    nwalkers = 100
71
72
73
    nsteps = [50, 50]

    mcmc = pyfstat.MCMCFollowUpSearch(
Gregory Ashton's avatar
Gregory Ashton committed
74
75
76
        label=label, outdir=outdir,
        sftfilepath='{}/*{}*sft'.format(outdir, data_label),
        theta_prior=theta_prior,
77
78
79
80
81
82
83
84
85
86
87
        tref=tref, minStartTime=tstart, maxStartTime=tend, nsteps=nsteps,
        nwalkers=nwalkers, ntemps=ntemps,
        log10temperature_min=log10temperature_min)
    mcmc.run(run_setup=run_setup, create_plots=False, log_table=False,
             gen_tex_table=False)
    d, maxtwoF = mcmc.get_max_twoF()
    dF0 = F0 - d['F0']
    dF1 = F1 - d['F1']
    with open(results_file_name, 'a') as f:
        f.write('{} {:1.8e} {:1.8e} {:1.8e} {:1.8e} {:1.8e}\n'
                .format(depth, h0, dF0, dF1, predicted_twoF, maxtwoF))
Gregory Ashton's avatar
Gregory Ashton committed
88
    os.system('rm {}/*{}*'.format(outdir, label))