LikelihoodFunction - function to calculate the likelihood of livePoint,
        given Data.

        Template - (N_fd) complex array containing Fourier domain trial signal.
        Data - (N_fd) complex array containing Fourier domain GW data.
        PSD - Noise power spectral density for a gravitational wave detector.
        detRespP - Antenna response to the plus GW polarisation for the
                   detector.
	detGCDelay - Time delay of detector from geocenter (default = 0, use
		     detGCDelay only if computing logL for more than one 
		     detector.

        Returns logL of Template.

        Sarah Gossan 2012. Last updated 02/18/14.

def LikelihoodFunction(Template, Data, PSD, detRespP, detGCDelay=0):
    """ LikelihoodFunction - function to calculate the likelihood of livePoint,
        given Data.

        Template - (N_fd) complex array containing Fourier domain trial signal.
        Data - (N_fd) complex array containing Fourier domain GW data.
        PSD - Noise power spectral density for a gravitational wave detector.
        detRespP - Antenna response to the plus GW polarisation for the
                   detector.
	detGCDelay - Time delay of detector from geocenter (default = 0, use
		     detGCDelay only if computing logL for more than one 
		     detector.

        Returns logL of Template.

        Sarah Gossan 2012. Last updated 02/18/14. """

    # Correct template for geocenter delay and antenna response function
    if detGCDelay:
        phaseGCDelay = -2.*np.pi*np.linspace(0,N_fd-1,num=N_fd)*dF*detGCDelay*1j 
	Template *= phaseGCDelay
    Template *= detRespP
    # Calculate logL - simple Gaussian
    logL = -2.*dF*np.sum(pow(abs(Data[lowBin:] - Template[lowBin:]),2.)/\
	   PSD[lowBin:])

    return logL