Skip to content

Commit

Permalink
Merge pull request #10 from alvincjk/revert-9-gpu-dev
Browse files Browse the repository at this point in the history
Revert "sqrt(df) -> sqrt(dt), noise curves added"
  • Loading branch information
mikekatz04 authored Sep 10, 2019
2 parents 2f20db1 + c04dcfc commit 1c4d352
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 64 deletions.
70 changes: 8 additions & 62 deletions examples/pygpuAAKdemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,20 @@
from AAKwrapper import AAKwrapper as cpu_AAK
from gpuAAK import GPUAAK
from pygpuAAK import pygpuAAK
import tdi

import time

fit_pars = {
0.5:{
'alpha': 0.133,
'beta': 243,
'kappa': 482,
'gamma': 917,
'f_k': 2.58e-3
},
1:{
'alpha': 0.171,
'beta': 292,
'kappa': 1020,
'gamma': 1680,
'f_k': 2.15e-3
},
2:{
'alpha': 0.165,
'beta': 299,
'kappa': 611,
'gamma': 1340,
'f_k': 1.73e-3
},
4:{
'alpha': 0.138,
'beta': -221,
'kappa': 521,
'gamma': 1680,
'f_k': 1.13e-3
}
}

def P_OMS(f):
return (1.5e-11)**2*(1 + (2e-3/f)**4)

def P_acc(f):
return (3e-15)**2*(1 + (0.4e-3/f)**2)*(1+(f/8e-3)**4)

def S_c(f, dur=4):
if dur not in [0.5, 1, 2, 4]:
raise ValueError("dur needs to be 0.5, 1, 2, or 4 years.")

alpha = fit_pars[dur]['alpha']
beta = fit_pars[dur]['beta']
kappa = fit_pars[dur]['kappa']
gamma = fit_pars[dur]['gamma']
f_k = fit_pars[dur]['f_k']
A = 9e-45
return A* f**(-7/3)*np.exp(-f**alpha + beta*f*np.sin(kappa*f))*(1+np.tanh(gamma*(f_k - f)))


def LISA_Noise(f, L=2.5e9, f_star=19.09e-3, dur=4):
S_n=20./(3.*L**2)*(P_OMS(f) + 4*P_acc(f)/(2*np.pi*f)**4)*(1+6/10*(f/f_star)**2)+S_c(f, dur=4)
return S_n;


def test():
iota = 0.2
s = 0.8
p = 10.0
e = 0.7
T_fit = 1.0
init_length = 100000
length = 1000000
init_dt = 100.0
init_length = 14000
length = 1400000
init_dt = 1000.0
dt = 10.0
M = 1e6
mu = 1e1
Expand All @@ -81,7 +28,7 @@ def test():
phi_S = 0.785
theta_K = 1.05
phi_K = 1.05
D = 5.0
D = 1.0
LISA = True
backint = True

Expand Down Expand Up @@ -119,8 +66,8 @@ def test():
freqs = np.fft.rfftfreq(len(hIc), d=dt)
freqs[0] = 1e-8
deltaF = 1/dt
ASD = np.sqrt(LISA_Noise(freqs, dur=4))
noise_channels = {'channel1': ASD**2, 'channel2': ASD**2}
AE_ASD = tdi.noisepsd_AE(freqs, model='SciRDv1', includewd=3)
noise_channels = {'channel1': AE_ASD, 'channel2': AE_ASD}

kwargs = {
'T_fit': 1.0,
Expand All @@ -131,7 +78,7 @@ def test():
like_class = pygpuAAK.pyGPUAAK(data_stream, noise_channels, length, dt, init_dt, **kwargs)
likelihood = like_class.NLL(iota, s, p, e, M, mu, gamma, psi, alph, theta_S,
phi_S, theta_K, phi_K, D)
num = 10
num = 1000
st = time.perf_counter()
for i in range(num):
likelihood = like_class.NLL(iota, s, p, e, M, mu, gamma, psi, alph, theta_S,
Expand All @@ -144,7 +91,6 @@ def test():
phi_S, theta_K, phi_K, D, return_snr=True)

print('SNR: ', snr, 'Likelihood:', likelihood)
import pdb; pdb.set_trace()

if __name__ == "__main__":
test()
4 changes: 2 additions & 2 deletions pygpuAAK/pygpuAAK.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def __init__(self, data_stream, noise_channels, length, dt, init_dt, **kwargs):
# whiten data stream
self.data_stream = data_stream

self.noise_channel1_inv = 1./np.sqrt(noise_channels['channel1'])*np.sqrt(dt) # dt dt df = dt
self.noise_channel2_inv = 1./np.sqrt(noise_channels['channel2'])*np.sqrt(dt)
self.noise_channel1_inv = 1./np.sqrt(noise_channels['channel1'])*np.sqrt(df)
self.noise_channel2_inv = 1./np.sqrt(noise_channels['channel2'])*np.sqrt(df)

self.data_channel1 *= self.noise_channel1_inv
self.data_channel2 *= self.noise_channel2_inv
Expand Down

0 comments on commit 1c4d352

Please sign in to comment.