Transit-Like Injections CARMA-Filtered


In [1]:
push!(LOAD_PATH, ".")


Out[1]:
3-element Array{ByteString,1}:
 "/Users/farr/Documents/code/julia/usr/local/share/julia/site/v0.4"
 "/Users/farr/Documents/code/julia/usr/share/julia/site/v0.4"      
 "."                                                               

In [2]:
using Colors
using Gadfly
using Kalman
using Transit

Some Quick Tests of AR(1)

Create a filter with mean 1, variance 25, and timescale 3.


In [3]:
filt = Kalman.AR1KalmanFilter(1.0, 25.0, 3.0)


Out[3]:
Kalman.AR1KalmanFilter(1.0,25.0,1.0,25.0,3.0)

In [4]:
ts = cumsum(rand(1000))
dys = 0.1 + 0*ts
ys = Kalman.generate(filt, ts, dys)
wys = Kalman.whiten(filt, ts, ys, dys)
plot(layer(x=ts, y=ys, Geom.line, Theme(default_color=colorant"red")),
layer(x=ts, y=Kalman.whiten(filt, ts, ys, dys), Geom.line, Theme(default_color=colorant"blue")))


Out[4]:
x -700 -600 -500 -400 -300 -200 -100 0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 -600 -580 -560 -540 -520 -500 -480 -460 -440 -420 -400 -380 -360 -340 -320 -300 -280 -260 -240 -220 -200 -180 -160 -140 -120 -100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000 1020 1040 1060 1080 1100 1120 1140 1160 1180 1200 -1000 0 1000 2000 -600 -550 -500 -450 -400 -350 -300 -250 -200 -150 -100 -50 0 50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 -60 -30 0 30 60 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 y

Let's check that the means and standard deviations work out:


In [5]:
print("Raw timeseries mean = $(mean(ys)), s.d. = $(std(ys))\n")
print("Whitened timeseries mean = $(mean(wys)), s.d. = $(std(wys))")


Raw timeseries mean = 1.3669935706543457, s.d. = 4.982579599872973
Whitened timeseries mean = 0.01603975275415794, s.d. = 0.9970829793516035

Let's check the log-likelihood:


In [6]:
function rawcov(ts, dys, var, tau)
    n = size(ts, 1)
    sigma = zeros(n,n)
    
    for i in 1:n
        for j in i:n
            sigma[i,j] = var*exp(-abs(ts[i]-ts[j])/tau)
            if j == i 
                sigma[i,j] += dys[i]*dys[i]
            else
                sigma[j,i] = sigma[i,j]
            end
        end
    end
    
    sigma
end

function rawloglik(ts, ys, dys, mu, var, tau)
    sigma = rawcov(ts, dys, var, tau)
    
    eigs = eigvals(sigma)
    
    n = size(ts, 1)
    
    -0.5*n*log(2.0*pi) - 0.5*sum(log(abs(eigs))) - 0.5*dot(ys-mu, sigma\(ys-mu))
end


Out[6]:
rawloglik (generic function with 1 method)

In [7]:
println("Raw log likelihood = $(rawloglik(ts, ys, dys, 1.0, 25.0, 3.0))")
println("Kalman log likelihood = $(Kalman.log_likelihood(filt, ts, ys, dys))")


Raw log likelihood = -2284.9991846946436
Kalman log likelihood = -2284.999184694643

Woohoo!

Testing the SNR against various noise parameters

First, the parameters of our transits:


In [16]:
dt = 30.0/60.0/24.0 # dt in days
ts = collect(0:dt:60)
Tdur = 0.5 # 12 hour transits
P = 15 + rand() # 15 +/- 1 day period
T0 = 14*rand() # Random start phase
sigma_wn = 0.01
sigma_ar = 0.10
depth = sigma_wn*2
dflux = sigma_wn + 0.0*ts
tau_ar = P
mu_ar = 0.0
trans = Transit.transit_lightcurve(ts, P, T0, Tdur, depth)
println("Transit SNR = $(Transit.snr(trans, trans, sigma_wn))")
plot(x=ts, y=trans, Geom.line)


Transit SNR = 19.26666662667415
Out[16]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 0.945 0.950 0.955 0.960 0.965 0.970 0.975 0.980 0.985 0.990 0.995 1.000 1.005 1.010 1.015 1.020 1.025 1.030 0.949 0.950 0.951 0.952 0.953 0.954 0.955 0.956 0.957 0.958 0.959 0.960 0.961 0.962 0.963 0.964 0.965 0.966 0.967 0.968 0.969 0.970 0.971 0.972 0.973 0.974 0.975 0.976 0.977 0.978 0.979 0.980 0.981 0.982 0.983 0.984 0.985 0.986 0.987 0.988 0.989 0.990 0.991 0.992 0.993 0.994 0.995 0.996 0.997 0.998 0.999 1.000 1.001 1.002 1.003 1.004 1.005 1.006 1.007 1.008 1.009 1.010 1.011 1.012 1.013 1.014 1.015 1.016 1.017 1.018 1.019 1.020 1.021 1.022 1.023 1.024 1.025 0.925 0.950 0.975 1.000 1.025 0.948 0.950 0.952 0.954 0.956 0.958 0.960 0.962 0.964 0.966 0.968 0.970 0.972 0.974 0.976 0.978 0.980 0.982 0.984 0.986 0.988 0.990 0.992 0.994 0.996 0.998 1.000 1.002 1.004 1.006 1.008 1.010 1.012 1.014 1.016 1.018 1.020 1.022 1.024 1.026 y

Pure White Noise


In [17]:
noise = sigma_wn * randn(size(ts,1))
flux = trans + noise
cs = distinguishable_colors(2)
println("Transit SNR = $(Transit.snr(flux,trans,std(flux)))")
println("BLS SNR = $(Transit.bls_snr(flux,trans))")
println("New SNR = $(Transit.new_snr(flux, trans))")
plot(layer(x=ts, y=flux, Geom.line, Theme(default_color=RGBA(cs[1],0.2))),
layer(x=ts,y=trans,Geom.line,Theme(default_color=cs[2])))


Transit SNR = 19.772108283614124
Out[17]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 0.850 0.855 0.860 0.865 0.870 0.875 0.880 0.885 0.890 0.895 0.900 0.905 0.910 0.915 0.920 0.925 0.930 0.935 0.940 0.945 0.950 0.955 0.960 0.965 0.970 0.975 0.980 0.985 0.990 0.995 1.000 1.005 1.010 1.015 1.020 1.025 1.030 1.035 1.040 1.045 1.050 1.055 1.060 1.065 1.070 1.075 1.080 1.085 1.090 1.095 1.100 1.105 1.110 1.115 1.120 1.125 1.130 1.135 1.140 1.145 1.150 0.8 0.9 1.0 1.1 1.2 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 1.12 1.13 1.14 1.15 y
BLS SNR = 18.94380314522045
New SNR = 20.228618254815633

Short-period noise (around 1-sample correlations)


In [18]:
filt = Kalman.AR1KalmanFilter(0.0, sigma_ar^2, dt)
noise = Kalman.generate(filt, ts, dflux)
flux = trans + noise
cs = distinguishable_colors(2)
println("Transit SNR = $(Transit.snr(flux,trans,std(flux)))")
println("BLS SNR = $(Transit.bls_snr(flux,trans))")
println("New SNR = $(Transit.new_snr(flux, trans))")
plot(layer(x=ts, y=flux, Geom.line, Theme(default_color=RGBA(cs[1],0.2))),
layer(x=ts,y=trans,Geom.line,Theme(default_color=cs[2])))


Transit SNR = 0.0
Out[18]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 -0.4 -0.2 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 -0.25 -0.20 -0.15 -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.00 2.05 2.10 2.15 2.20 -1 0 1 2 3 -0.25 -0.20 -0.15 -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.00 2.05 2.10 2.15 2.20 y
BLS SNR = -0.15222332367378183
New SNR = -0.1471491765381478

And if we whiten...?


In [19]:
filt = Kalman.AR1KalmanFilter(1.0, sigma_ar^2, dt)
wflux = Kalman.whiten(filt, ts, flux, dflux)
wtrans = Kalman.whiten(filt, ts, trans, dflux)
println("Whitened SNR = $(Transit.snr(wflux, wtrans, 1.0))")
plot(layer(x=ts, y=wflux, Geom.line, Theme(default_color=RGBA(cs[1], 0.2))),
layer(x=ts, y=wtrans, Geom.line, Theme(default_color=cs[2])))


Whitened SNR = 0.18513479231969515
Out[19]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 -20 -10 0 10 20 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 y

Longer Period Correlations (around Tdur)


In [20]:
filt = Kalman.AR1KalmanFilter(0.0, sigma_ar^2, Tdur)
noise = Kalman.generate(filt, ts, dflux)
flux = trans + noise
println("Raw SNR = $(Transit.snr(flux, trans, std(flux)))")
println("BLS SNR = $(Transit.bls_snr(flux, trans))")
println("New SNR = $(Transit.new_snr(flux, trans))")
plot(layer(x=ts, y=flux, Geom.line, Theme(default_color=RGBA(cs[1], 0.2))),
layer(x=ts, y=trans, Geom.line, Theme(default_color=cs[2])))


Raw SNR = 0.0
Out[20]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40 0.42 0.44 0.46 0.48 0.50 0.52 0.54 0.56 0.58 0.60 0.62 0.64 0.66 0.68 0.70 0.72 0.74 0.76 0.78 0.80 0.82 0.84 0.86 0.88 0.90 0.92 0.94 0.96 0.98 1.00 1.02 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 1.20 1.22 1.24 1.26 1.28 1.30 1.32 1.34 1.36 1.38 1.40 1.42 1.44 1.46 1.48 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 0.0 0.5 1.0 1.5 2.0 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 y
BLS SNR = -5.068109069717232
New SNR = -5.193759519333531

...and if we whiten?


In [21]:
filt = Kalman.AR1KalmanFilter(1.0, sigma_ar^2, Tdur)
wflux = Kalman.whiten(filt, ts, flux, dflux)
wtrans = Kalman.whiten(filt, ts, trans, dflux)
println("Whitened SNR = $(Transit.snr(wflux, wtrans, 1.0))")
plot(layer(x=ts, y=wflux, Geom.line, Theme(default_color=RGBA(cs[1],0.2))),
layer(x=ts, y=wtrans, Geom.line, Theme(default_color=cs[2])))


Whitened SNR = 0.8866120557067384
Out[21]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 -16.0 -15.5 -15.0 -14.5 -14.0 -13.5 -13.0 -12.5 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 -20 -10 0 10 20 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 y

And for very long-period correlations?


In [22]:
filt = Kalman.AR1KalmanFilter(0.0, sigma_ar^2, P)
noise = Kalman.generate(filt, ts, dflux)
flux = trans + noise
println("Raw SNR = $(Transit.snr(flux, trans, std(flux)))")
println("BLS SNR = $(Transit.bls_snr(flux, trans))")
println("New SNR = $(Transit.new_snr(flux, trans))")
plot(layer(x=ts, y=flux, Geom.line, Theme(default_color=RGBA(cs[1], 0.2))),
layer(x=ts, y=trans, Geom.line, Theme(default_color=cs[2])))


Raw SNR = 0.0
Out[22]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40 0.42 0.44 0.46 0.48 0.50 0.52 0.54 0.56 0.58 0.60 0.62 0.64 0.66 0.68 0.70 0.72 0.74 0.76 0.78 0.80 0.82 0.84 0.86 0.88 0.90 0.92 0.94 0.96 0.98 1.00 1.02 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 1.20 1.22 1.24 1.26 1.28 1.30 1.32 1.34 1.36 1.38 1.40 1.42 1.44 1.46 1.48 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 0.0 0.5 1.0 1.5 2.0 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 1.50 1.55 1.60 1.65 1.70 1.75 1.80 y
BLS SNR = 1.2983880872159574
New SNR = 1.0177252322105386

In [23]:
filt = Kalman.AR1KalmanFilter(1.0, sigma_ar^2, P)
wflux = Kalman.whiten(filt, ts, flux, dflux)
wtrans = Kalman.whiten(filt, ts, trans, dflux)
println("Whitened SNR = $(Transit.snr(wflux, wtrans, 1.0))")
plot(layer(x=ts, y=wflux, Geom.line, Theme(default_color=RGBA(cs[1], 0.2))),
layer(x=ts, y=wtrans, Geom.line, Theme(default_color=cs[2])))


Whitened SNR = 5.56031242106391
Out[23]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 -20 -15 -10 -5 0 5 10 15 20 -15.0 -14.5 -14.0 -13.5 -13.0 -12.5 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.5 13.0 13.5 14.0 14.5 15.0 -20 -10 0 10 20 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 y

Really Long Correlations


In [26]:
filt = Kalman.AR1KalmanFilter(0.0, sigma_ar^2, ts[end]-ts[1])
noise = Kalman.generate(filt, ts, dflux)
flux = trans + noise
println("Raw SNR = $(Transit.snr(flux, trans, std(flux)))")
println("BLS SNR = $(Transit.bls_snr(flux, trans))")
println("New SNR = $(Transit.new_snr(flux, trans))")
plot(layer(x=ts, y=flux, Geom.line, Theme(default_color=RGBA(cs[1], 0.2))),
layer(x=ts, y=trans, Geom.line, Theme(default_color=cs[2])))


Raw SNR = 6.118217958904014
Out[26]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 1.22 1.23 1.24 1.25 1.26 1.27 1.28 1.29 1.30 1.31 1.32 1.33 1.34 1.35 1.36 1.37 1.38 1.39 1.40 1.41 0.0 0.5 1.0 1.5 0.64 0.66 0.68 0.70 0.72 0.74 0.76 0.78 0.80 0.82 0.84 0.86 0.88 0.90 0.92 0.94 0.96 0.98 1.00 1.02 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 1.20 1.22 1.24 1.26 1.28 1.30 1.32 1.34 1.36 1.38 1.40 1.42 y
BLS SNR = 14.07140409371554
New SNR = 6.378129982574294

In [27]:
filt = Kalman.AR1KalmanFilter(1.0, sigma_ar^2, P)
wflux = Kalman.whiten(filt, ts, flux, dflux)
wtrans = Kalman.whiten(filt, ts, trans, dflux)
println("Whitened SNR = $(Transit.snr(wflux, wtrans, 1.0))")
plot(layer(x=ts, y=wflux, Geom.line, Theme(default_color=RGBA(cs[1], 0.2))),
layer(x=ts, y=wtrans, Geom.line, Theme(default_color=cs[2])))


Whitened SNR = 3.909938982528112
Out[27]:
x -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 -100 0 100 200 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 -14 -12 -10 -8 -6 -4 -2 0 2 4 6 8 10 12 14 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 -20 -10 0 10 20 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5 -6.0 -5.5 -5.0 -4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0 10.5 11.0 11.5 12.0 y

In [ ]: