# -*- coding: utf-8 -*-
"""
Created on Mon Mar 27 22:05:41 2017

@author: camacho
"""
import Gedi as gedi
import numpy as np
import matplotlib.pyplot as pl
pl.close()
### images for the thesis

print 'test 6 - everything combined'

x = 10 * np.sort(np.random.rand(101))
yerr = 0.1 * np.ones_like(x)
y = np.sin(x) + yerr * np.random.randn(len(x))  
#y = yerr * np.random.randn(len(x))
xcalc=np.linspace(0,10,500)  

kernel0=gedi.kernel.ExpSquared(10.0,0.5)
kernel1=gedi.kernel.ExpSquared(10.0,2.0)
kernel2=gedi.kernel.ExpSquared(10.0,10.0)

kernel0=gedi.kernel.RatQuadratic(10.0,0.001,1.0)
kernel1=gedi.kernel.RatQuadratic(10.0,1.0,1.0)
kernel2=gedi.kernel.RatQuadratic(10.0,1000.0,1.0)

kernel0=gedi.kernel.ExpSquared(10.0,2.0)
kernel1=gedi.kernel.Matern_32(10.0,2.0)
kernel2=gedi.kernel.Matern_52(10.0,2.0)

#kernel0=gedi.kernel.ExpSineSquared(10.0,1.0,5.0)
#kernel1=gedi.kernel.ExpSineSquared(10.0,1.0,5.0) +gedi.kernel.WhiteNoise(0.5)
##kernel1=gedi.kernel.ExpSineSquared(1.0,10.0,10.0)


like0=gedi.kernel_likelihood.likelihood(kernel0, x,y,yerr)
like1=gedi.kernel_likelihood.likelihood(kernel1, x,y,yerr)
like2=gedi.kernel_likelihood.likelihood(kernel2, x,y,yerr)
print like0,like1#,like2

#computation of the initial mean and standard deviation
[mu0,std0]=gedi.kernel_likelihood.compute_kernel(kernel0,x,xcalc,y,yerr)
[mu1,std1]=gedi.kernel_likelihood.compute_kernel(kernel1,x,xcalc,y,yerr)
[mu2,std2]=gedi.kernel_likelihood.compute_kernel(kernel2,x,xcalc,y,yerr)
pl.figure()
pl.plot(xcalc, mu0, "g", alpha=1, lw=1.5)
pl.plot(xcalc, mu1, "b--", alpha=1, lw=1.5)
pl.plot(xcalc, mu2, "r:", alpha=1, lw=2.5)
pl.plot(x, y,"ko")
pl.xticks(fontsize = 18);pl.yticks(fontsize=18)

## Four axes, returned as a 2-d array
#f, axarr = pl.subplots(2, 2)
#axarr[0, 0].plot(xt, trial[3][0])
#axarr[0, 0].set_title('amplitude')
#axarr[0, 1].plot(xt, trial[3][1])
#axarr[0, 1].set_title('lenght scale')
#axarr[1, 0].plot(xt, trial[3][2])
#axarr[1, 0].set_title('period')
#axarr[1, 1].plot(xt, trial[3][3])
#axarr[1, 1].set_title('white noise')
#pl.setp([a.get_xticklabels() for a in axarr[0, :]], visible=False)
