s = w50/(2*np.sqrt(2*np.log(2)))    #sigma calculated through the dutycycle
a = 1                               #amplitude. at some point this will be replaced by the intrinsic spectrum. 

trainlength = 20

## Intrinsic profile




bins, profile = psr.makeprofile(nbins = P, ncomps = 1, amps = a, means = m, sigmas = s)
xaxlong =  np.linspace(1,20*P,20*P)
#xaxlong =  np.linspace(1,100*P,100*P)

spectralindex = 1.6  #Input spectral index as a postivie number, for nu^-alpha
profile_intr = psr.profilespec(nurange,spectralindex,profile)
profile_intr_norm = profile_intr/np.sum(profile_intr[0])   #Normalised such that the max intrinsic flux = 1.0. That is the intrinsice pulse at the lowest frequency has flux = 1

###############################################################################
## ISOTROPIC
###############################################################################

## In the case of importing data/broadening functions these parameters will only play a roll in plotting the alpha = 4.0 spectrum to compare
## In the case where I simulate the data to fit here, these paramteres will dicatate the shape of the broadening function

Dval, Dsval = float(DD),float(Dss)

k1 = sigma1
kappa1 = k1*mrad

tauval = psr.tau(Dval,Dsval,kappa1,nurange,light)
print 'bandwidth: '+str(bandw)+' GHz'
print str(nulow)+'-'+str(nuhigh)+' GHz'



### Create the properties of the ingoing pulse

pulseperiod =1.382                  #in seconds
dutycycle = float(2.5)             #as a % of the overall pulseperiod

## Create the profile to have the same time resolution than the broadening function created by photonscat.py

P = int(pulseperiod/binstimeres)

specepn = 1.8
epn_intr = psr.profilespec(nurange,specepn,epnprofy)
epn_norm = epn_intr/np.sum(epn_intr[0])

## Resample epn_norm to have the same time resolution than the broadening function produced by Ray_minimal.py
newbinnumber = pulseperiod/binstimeres
epnbintimeres = np.linspace(0.,1.0,len(epn_norm[0]))
newtimeres= np.linspace(0,1.0,newbinnumber)
epn_norm_interpp = []
for k in range(len(epn_norm)):
    epn_norm_interp = np.interp(newtimeres,epnbintimeres,epn_norm[k])
    epn_norm_interpp.append(epn_norm_interp)



###############################################################################
## ISOTROPIC