import Numeric
import arrayfns
import MLab
import Minimiser
import string
import Dabax
import math

import PPMlayerclass
from PPMlayerclass import *

densita_relativa=Minimiser.Variable(1.0,0.0,2.0)

index1 = MagScatterer(NameFilePlus="pippoPlus.dat", NameFileMinus="pippoMinus.dat", versor=[  1.0, .0, 0], RelativeDensity=1.0,saturation=1.0)
index2 = MagScatterer(NameFilePlus="pippoPlus.dat", NameFileMinus="pippoMinus.dat", versor=[  1, 0., 0.], RelativeDensity=1.0,saturation=1)

Table_f0   = Dabax.Dabax_f0_Table("f0_WaasKirf.dat")

Table_f1f2 = Dabax.Dabax_f1f2_Table("f1f2_Sasaki.dat")

Fe_i=PPMlayerclass.IndexFromTable(Table_f0 , Table_f1f2,   "Fe", 10.0 )


# Fe_i.append([index2], [densita_relativa] , ["non importa; se no un  numero"])

print Fe_i
composto=ComposedIndex( Fe_i )
layer1=PPMlayerclass.PPM_ElementalLayer(thickness=20.0, roughness= .0,DabaxList=[index1], DensityList=[1.0], MassList=[None])

layer2=PPMlayerclass.PPM_SimpleLayer(thickness=20.0, roughness= .0, material = composto  )

stack=layer2

multilayer=stack
multilayer=PPMlayerclass.MultiplyAThing(1, stack)



# for i in range(100):
#  multilayer.calculatescanTensor(Numeric.array([1.,2.,3.,4.,5]*20), Numeric.array([2.,2.,2.,2.,2.]*20))
#print "OK1"

## wavelenghts, angle
res=multilayer.calculatescanTensor(Numeric.array([ 6.2831853071795862  ]), Numeric.array([2.0*math.pi/180.0]),
                  Numeric.array( [ 1.0,complex(0.0,1.0)  ]        )/math.sqrt(2.0) )

print res















































