mrad = 4.85*10**-9     
incr = 0.005
nulow, nuhigh = float(0.06),float(0.125)
#nulow, nuhigh = float(0.09),float(0.155)
#nulow, nuhigh = float(0.15),float(0.215)
#nulow, nuhigh = float(0.20),float(0.265)
nurange = np.arange(nulow,nuhigh,incr)
pulseperiod = 1.0
bins = 512
bs = pulseperiod/bins
Dval = 3.0
Dsval = 1.5
k1 = 3.0
kappa1 = k1*mrad

taupow4 = psr.tau(Dval,Dsval,kappa1,nurange,light)
taupow4bins = taupow4*bins/pulseperiod

"""Create a dictionaries of all the variable names which are imported back"""
"""Dictionary for profiles and model fits"""
timestring = '20151105'
#folder = 'SlowPulsar'
folder = 'Aniso'
#string2 = 'HF'
string2 = '20151108-00'
d = {} 

"""Choose arsec.txt for 1.0 sec pulsar and arsec_B.txt for milisecond pulsar."""

d["arsec"]  =  np.loadtxt('Pythondata/arsec/arsec.txt')
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 tauval

#if tauval[0] > 10*pulseperiod:
#    sys.exit("tau warning: scattering is too high")
#else:
#    taubins = (tauval/pulseperiod)*P
taubins = (tauval/pulseperiod)*P
#
#print taubins
#print np.median(taubins)

#sys.exit()
#sys.exit()

###############################################################################
## SCATTERING SETUP
###############################################################################

Dval, Dsval = float(3.0),float(1.5)

#for k1 in range(3,15,3):
k1 = 3
k2 = 1
kappa1 = k1*mrad
kappa2 = k2*mrad

tauval = psr.tau(Dval,Dsval,kappa1,nurange,light)
tauval2 = psr.tau(Dval,Dsval,kappa2,nurange,light)
tauvalgeo = np.sqrt(tauval*tauval2)

#print tauval
#print tauval2
#print tauvalgeo

taubins = (tauval/pulseperiod)*P
taubins2 = (tauval2/pulseperiod)*P
taubinsgeo = np.sqrt(taubins*taubins2)

#print taubins
#sys.exit()

print '=============================='