# ------------------------------------
# --------- LUCIFER SOURCES ----------
# ------------------------------------

import numpy
import math

def get_src_par():
	pars = {
		'field':0, 				# Ex
		'type':1,				# plane wave
		'direction':2,				# 0=X; 1=Y; 2=Z;
		'location':(0,0,500)			# at z, x, y are irrelevant see add_source.c
	}

	return pars

def get_time_profile(t_buf, simp):
	dt = numpy.dtype(numpy.float32)
	dt = dt.newbyteorder('<')
	t = numpy.frombuffer(t_buf,dtype=dt)

	C0 = simp['C0']
	delta_t = simp['dt']
	max_time = simp['max_time']

	X1 = numpy.empty([max_time-1, 1], dtype=numpy.float32)
	Y1 = numpy.empty([max_time-1, 1], dtype=numpy.float32)
	X2 = numpy.empty([max_time-1, 1], dtype=numpy.float32)
	Y2 = numpy.empty([max_time-1, 1], dtype=numpy.float32)
	X3 = numpy.empty([max_time-1, 1], dtype=numpy.float32)
	Y3 = numpy.empty([max_time-1, 1], dtype=numpy.float32)

	X1[0] = 0 
	Y1[0] = 0
	X2[0] = 0
	Y2[0] = 0
	X3[0] = 0
	Y3[0] = 0

	for i in xrange(1, max_time-1):
		X1[i] = X1[i-1]*numpy.exp(-delta_t/4.4e-14) + numpy.sqrt((4.4e-14/2)*(1-numpy.exp(-2*delta_t/4.4e-14)))*numpy.random.random_sample()
		Y1[i] = Y1[i-1]*numpy.exp(-delta_t/4.4e-14) + numpy.sqrt((4.4e-14/2)*(1-numpy.exp(-2*delta_t/4.4e-14)))*numpy.random.random_sample()
		X2[i] = X2[i-1]*numpy.exp(-delta_t/7.2e-14) + numpy.sqrt((7.2e-14/2)*(1-numpy.exp(-2*delta_t/7.2e-14)))*numpy.random.random_sample()
		Y2[i] = Y2[i-1]*numpy.exp(-delta_t/7.2e-14) + numpy.sqrt((7.2e-14/2)*(1-numpy.exp(-2*delta_t/7.2e-14)))*numpy.random.random_sample()
		X3[i] = X3[i-1]*numpy.exp(-delta_t/8.5e-14) + numpy.sqrt((8.5e-14/2)*(1-numpy.exp(-2*delta_t/8.5e-14)))*numpy.random.random_sample()
		Y3[i] = Y3[i-1]*numpy.exp(-delta_t/8.5e-14) + numpy.sqrt((8.5e-14/2)*(1-numpy.exp(-2*delta_t/8.5e-14)))*numpy.random.random_sample()
		t[i] = 0.63*X1[i]*math.cos(2*numpy.pi*8.19e14*i*delta_t) + 0.63*Y1[i]*math.sin(2*numpy.pi*8.19e14*i*delta_t) + 0.579*X2[i]*math.cos(2*numpy.pi*7.38e14*i*delta_t) + 0.579*Y2[i]*math.sin(2*numpy.pi*7.38e14*i*delta_t) +	X3[i]*math.cos(2*numpy.pi*6.86e14*i*delta_t) + Y3[i]*math.sin(2*numpy.pi*6.86e14*i*delta_t)  
		#t[i] = math.sin(2*numpy.pi*6e14*i*delta_t)
		#t[i] = -(i-500)*numpy.exp(-((i-500)*delta_t/0.25e-9)**2)
		#t[i] = math.sin(2*numpy.pi*6e14*i*delta_t)*numpy.exp(-((i-500)*delta_t/2e-14)**2)

