[Ifeffit] Larch: AttributeError
newville at cars.uchicago.edu
Wed Jan 13 14:51:12 CST 2021
On Wed, Jan 13, 2021 at 2:00 PM Rachita Rana <racrana at ucdavis.edu> wrote:
> Hi Everyone,
> I am using Larch for reading and fitting EXAFS data and I get the autobk
> and Fourier transforms working. But when I try to generate the fefffpaths
> and fit the data I get an error from the feffit function. I am using the
> developer version of Larch on MC OS Catalina. Below is the error and the
> sample script-
> *Traceback (most recent call last):*
> * File "/Users/rachita/Box/Larch/Feff_Try2/001.py", line 27, in <module>*
> * fit = feffit(params, dset)*
> * File
> line 534, in feffit*
> * ds.prepare_fit(params=params)*
> * File
> line 265, in prepare_fit*
> * ikmax = int(1.01 + max(self.data.k)/trans.kstep)*
> *AttributeError: 'AthenaGroup' object has no attribute ‘k’ #tried this
> with xdi format data and got the same error*
I think this is because your script actually did not do the background
subtraction. The "read_xdi()" command reads in the raw data, which
probably contains "energy" and "mu" arrays, but not "k" and "chi" arrays.
You said you got autobk and ffts working, you probably want to just add a
command (maybe with other options). That will add "k" and "chi" arrays to
the "data" group, which feffit() is expecting.
I guess the error message could be clearer there....
> *Below is the script -*
> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> from larch.fitting import param_group, Parameter
> from larch.io import read_xdi
> from larch.xafs import feffpath, feffit_dataset, feffit_transform, feffit,
> data = read_xdi('cu_metal_rt.xdi’) *#I tried importing Athena project
> file too *
> path1 = feffpath('feff0001.dat', s02='amplitude', e0='del_e0',
> sigma2='sigma2', deltar='del_r')
> trans = feffit_transform(kmin=3, kmax=16, kw=(2,1,3),
> dk=1, window='hanning', rmin=1.7, rmax=3.1)
> params = param_group(amplitude= Parameter(1, vary=True),
> del_e0 = Parameter(1e-7, vary=True),
> del_r = Parameter(1e-7, vary=True),
> sigma2 = Parameter(0.003, vary=True))
> dset = feffit_dataset(data=data, pathlist=[path1], transform=trans)
> fit = feffit(params, dset)
> By printing path groups and transform fit, I confirmed that the data is
> read correctly.
> Please let me know if there are ways to fix this or if there is an error
> in my script.
> Thank You!
> Ifeffit mailing list
> Ifeffit at millenia.cars.aps.anl.gov
> Unsubscribe: http://millenia.cars.aps.anl.gov/mailman/options/ifeffit
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ifeffit