
cu = read_ascii('../xafsdata/cu_metal_rt.xdi')
autobk(cu.energy, cu.mutrans, group=cu, rbkg=1.0, kw=1)

fitparams = group(amp  = guess(1),
                  de0  = guess(0.1),
                  ss2  = guess(0.002),
                  delr = guess(0.)
                  )

path1 = feffpath('feffcu01.dat',
                 s02 = 'amp',
                 e0  = 'de0',
                 sigma2 = 'ss2',
                 deltar = 'delr')

trans = feffit_transform(kmin=3, kmax=17, kw=2, dk=3,
                         window='hanning', rmin=1.4, rmax=3.0)

# to set data uncertainty use either
#    cu.epsilon_k = 0.003
#    cu.epsilon_k = 0.002 + arange(len(cu.k)) * 0.0003
# so that epsilon_k is a single value or the same length as cu.k.
# or pass epsilon_k as an argument to feffit_dataset()

d1    = feffit_dataset(data=cu, pathlist=[path1], transform=trans,
                       epsilon_k=0.003)

out = feffit(fitparams, d1)

print( fit_report(fitparams))

newplot(d1.data.r, d1.data.chir_mag, color='blue', label='data',
        show_legend=True,xlabel=r'$R \rm(\AA)$', xmax=6)
   plot(d1.model.r, d1.model.chir_mag, color='red', label='fit')
   plot(d1.data.r, d1.data.chir_re, color='blue', label='')
   plot(d1.model.r, d1.model.chir_re, color='red', label='')
