[Ifeffit] Problem with using lincomb_fit function in the Larch

Matt Newville newville at cars.uchicago.edu
Tue Feb 26 11:56:49 CST 2019

Hi Ahkil,

On Tue, Feb 26, 2019 at 3:51 AM Tayal, Akhil <akhil.tayal at desy.de> wrote:

> Hello Matt,
> I could not be able to perform LCA using the lincomb_fit function in the
> Larch software. I am getting the error message from line number 80 in
> the lincombo_fitting.py script. I expect the function has some bug with
> reading the group values. It could not be even able to read the default
> array 'norm' nither any user-provided 'arrayname' such as 'flat or fpp.'
> Can you suggest any solution for it? Please find the data files and
> larch script I am using for this purpose.

There are a couple of things wrong -- some with your script but also a bug
in lincombo_fit() that I had not seen until this morning.

First, you should just use the group symbols, not the names of the groups,
so replace
    lincombo_fit(group='g3',components='g1 g2', ....

    lincombo_fit(group=g3, components=[g1, g2], ....

Second, you should also keep the result (somewhat unusually for Larch, it
does not currently get written into the main group -- perhaps this should
be fixed), so

    result = lincomb_fit(group=g3, ....)

Third, the 'xmin' and 'xmax' parameters you have appear to be intended to
be "relative to e0", but lincombo_fit() wants absolute x values (and e0 is
not defined anyway).  So you probably want something like

  result = lincombo_fit(group=g3, components=[g1, g2], arrayname='flat',
xmin=22070, xmax=22170, sum_to_one=True)

But:  this still won't work with Larch 0.9.41 because of a typo in
lincombo_fit().  I have a fix pushed to github, and I'm working on a
release for 0.9.42 today anyway (mostly fixing other bugs in XAS Viewer),
and this will be included in that.

Anyway, until you can upgrade to Larch 0.9.42, you will need to supply
starting weights (they do not have to be accurate, just not `None`).
So, in summary, you should use:

  result = lincombo_fit(group=g3, components=[g1, g2], arrayname='flat',
xmin=22070, xmax=22170, weights=[0.8. 0.2], sum_to_one=True)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20190226/5c5a9fca/attachment.html>

More information about the Ifeffit mailing list