-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeterodynedData.py
executable file
·120 lines (102 loc) · 3.16 KB
/
HeterodynedData.py
1
2
3
4
5
6
7
8
9
10
11
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
import numpy as np
from bilby.core.prior import PriorDict, Uniform
from cwinpy import HeterodynedData, TargetedPulsarLikelihood
from matplotlib import pyplot as plt
import sys
import pickle as pkl
from lalpulsar.PulsarParametersWrapper import PulsarParametersPy
run=False
def generate_het(H0=5.12e-25,COSIOTA=0.3,PSI=1.1,PHI0=2.4):
use_parfile=False
parname="J0123+3456"
if use_parfile==True:
parcontent = """\
PSRJ {}
RAJ 01:23:45.6789
DECJ 34:56:54.321
F0 567.89
F1 -1.2e-12
PEPOCH 56789
H0 {}
COSIOTA {}
PSI {}
PHI0 {}
""".format(parname,H0,COSIOTA,PSI,PHI0)
par = parname+".par"
with open(par, "w") as fp:
fp.write(parcontent)
else:
# print(0)
par = PulsarParametersPy() # create an empty object
par["PSRJ"] = parname # give it a name
par["RAJ"] = 1.8 # give it a right ascension (in rads)
par["DECJ"] = 0.54 # give it a declination (in rads)
par["F"] = [567.89] # give it a frequency (in Hz)
par["H0"] = H0 # give it a gravitational-wave amplitude (between 0 and 1e-22)
par["COSIOTA"] = COSIOTA # give it a value of cos(iota) (between -1 and 1)
par["PSI"] = PSI # give it a value of the polarisation angle (in rads) (between 0 and pi)
par["PHI0"] = PHI0 # give it a value of the initial phase (in rads) (between 0 and pi/2)
# parcontent["PEPOCH"] = 1000000000
# print(1)
# print(parcontent)
detector = "H1"
# print(2)
times = np.linspace(1000000000.0, 1000086340.0, 1440)
het = HeterodynedData(
times=times,
inject=True,
par=par,
injpar=par,
fakeasd=1e-24,
detector=detector,
bbminlength=1e10000
)
# print(3)
return het
if __name__=="__main__":
x=generate_het()
print(x.data)
times = np.linspace(1000000000.0, 1000086340.0, 1440)
plt.figure()
plt.plot(times,x.data)
plt.show()
if __name__=="__main__" and run==True:
parcontent = """\
PSRJ J0123+3456
RAJ 01:23:45.6789
DECJ 34:56:54.321
F0 567.89
F1 -1.2e-12
PEPOCH 56789
H0 5.12e-25
COSIOTA 0.3
PSI 1.1
PHI0 2.4
"""
# add content to the par file
parfile = "J0123+3456.par"
with open(parfile, "w") as fp:
fp.write(parcontent)
# create some fake heterodyned data
detector = "H1" # the detector to use
#times = np.linspace(1000000000.0, 1000086340.0, 1440) # times
times = np.linspace(1000000000.0, 1000086340.0, 1440)
het = HeterodynedData(
times=times,
inject=True,
par=parfile,
injpar=parfile,
fakeasd=1e-24,
detector=detector,
)
#print(type(het.par))
#np.save("het.npy",(het.data))
# het.write("data.txt")
"""
prior = {}
prior["h0"] = Uniform(0.0, 1e-22, "h0")
prior["phi0"] = Uniform(0.0, np.pi, "phi0")
priordic = PriorDict(prior)
print(type(priordic))
# pkl.dump("")
"""