
macro plot_path 1 "color=black"
 ff2chi($1,  group=p$1)
 fftf(real = p$1.chi)
 plot( p$1.r,  -p$1.chir_mag, $2)
end macro

macro plot_fit
echo 'in plot_fit '   
 newplot( data.r, data.chir_mag,xmin=0.,xmax=7)
 ff2chi(1-3, group=fit) 
 fftf(real =  fit.chi)
 plot(fit.r, fit.chir_mag)
# plot(fit.r, abs(data.chir_mag-fit.chir_mag),xmax=6)
end macro


read_data(../data/cu_chi.dat, group = data, type=chi)

unguess
guess  s02   = 1.
guess  e0    = 1.
guess  ss2   = 0.002
guess  dr    = 0.001

path(index  = 1, 
     feff   = ../feff/feffcu01.dat, 
     label  = "Cu metal first neighbor", 
     s02    = s02, 
     sigma2 = ss2,
     delr   = dr, 
     e0     = e0 )

kmin = 2, kmax=17 
dk1 = 1, dk2=1
rmin = 1.5, 
rmax =2.9
rmax_out = 10

feffit(1-3, chi = data.chi, k=data.k,  group = fit, 
       kweight=1, kweight=2, kweight=3)



print 'fit took ', &fit_iteration, ' iterations'


show @variables, chi_square, r_factor


correl(e0,dr,print)
correl(s02,ss2,print)

plot_fit



