# -*- coding: utf-8 -*-
"""
Created on Mon May  1 12:58:43 2017

@author: ishort
"""

    #JB#
import numpy as np
    
    
def ldc(numLams, lambdaScale, numThetas, cosTheta, contIntens):

    ldc = [0.0 for i in range(numLams)]

    epsilon = 0.0
    meanEepsilon = 0.0
    y = 0.0

    #double epsilon, meanEpsilon, y;

    for iL in range(numLams):

        #//System.out.println("lambdaScale[iL] " + lambdaScale[iL]);
        meanEpsilon = 0.0 #//initialize accumulator
        
        for iT in range(1, numThetas-1):
            
           y = contIntens[iL][iT]/contIntens[iL][0] 
           epsilon = (y - 1.0) / (cosTheta[1][iT] - 1.0)
        
           meanEpsilon += epsilon
            
        #pick the best LDC with the best R^2 and use that LDC
        ldc[iL] = meanEpsilon / numThetas


    return ldc

