Hi Fan,

Sorry for the trouble.  That seems like a strange error to me - I don't see why changing those expressions for E0s (even if they are  "slightly complicated"!) should generate NaNs or Infinities.  I don't think I've seen that happen with "feffit" fittings.   Can you send me a Larch Session File with this fit in it?

 One suggestion is to place bounds (say +/- 20 eV) on those Parameters, say
   pars.del_e0_11=param(expr='0.5*del_e0_O+0.5*del_e0_Sr', min=-20, max=20)

But I'm not certain whether that would solve this problem.


On Wed, Sep 14, 2022 at 7:53 AM <dxfan@post.kek.jp> wrote:

Dear All

 

I am doing Temperature-dependent EXAFS experiment with a lot of data.

 

Usually, we do these kinds of data fitting by several steps, like below:

First, put every parameter free, and obtain the averaged value of amp.

Second, set the amp to the averaged value, put other parameters free, and then obtain the averaged value of del_e0.

Third, set the amp and del_e0 to the averaged value, and fit again.

 

In my case, my sample is perovskite structure (Ti K-edge of SrTiO3).

To increase the fitting accuracy, I use three del_e0 for O, Ti, Sr as suggested in paper: Haskel, D., et al. Physica B: Condensed Matter 208 (1995): 151-153.

The fitting parameters of Cubic model is this:

    setattr(pars, f'alpha', param(0, vary=True))

    setattr(pars, f'amp',      param(0, vary=True))

    setattr(pars, f'del_e0_O',   param(0, vary=True))

    setattr(pars, f'del_e0_Sr',   param(0, vary=True))

    setattr(pars, f'del_e0_Ti',   param(0, vary=True))

    setattr(pars, f'sig2_O',  param(.002, vary=True))

    setattr(pars, f'sig2_Sr',  param(.002, vary=True))

    setattr(pars, f'sig2_Ti',  param(.002, vary=True))

    setattr(pars, f'sig2_Tr1', param(.002, vary=True))

    setattr(pars, f'sig2_p',   param(.002, vary=True))

    setattr(pars, f'sig2_Tr2', param(.002, vary=True))

   

    #del_e0 for each path

    pars.del_e0_1=param(expr='del_e0_O')

    pars.del_e0_2=param(expr='del_e0_O')

    pars.del_e0_3=param(expr='del_e0_Sr')

    pars.del_e0_4=param(expr='del_e0_Ti')

    pars.del_e0_5=param(expr='del_e0_O')

    pars.del_e0_6=param(expr='0.5*del_e0_O+0.5*del_e0_Ti')

    pars.del_e0_7=param(expr='(2*del_e0_O+del_e0_Ti)/3')

    pars.del_e0_8=param(expr='(2*del_e0_O+del_e0_Ti)/3')

    pars.del_e0_9=param(expr='(2*del_e0_O+del_e0_Ti)/3')

    pars.del_e0_10=param(expr='(2*del_e0_O+del_e0_Ti)/3')

    pars.del_e0_11=param(expr='0.5*del_e0_O+0.5*del_e0_Sr')

 

In the first step, the fitting is fine, I obtained the averaged amp.

However, in the second step, when I set amp to the averaged value, Error happens for “some” of the data.

When I use different averaged amp value, the data that happens error is different.

The error is:

Traceback (most recent call last):

  File "STO16_C_2.py", line 250, in <module>

    out = feffit(pars, dset)

  File "D:\anaconda3\envs\xraylarch\lib\site-packages\larch\xafs\feffit.py", line 557, in feffit

    result = fit.leastsq()

  File "D:\anaconda3\envs\xraylarch\lib\site-packages\lmfit\minimizer.py", line 1689, in leastsq

    lsout = scipy_leastsq(self.__residual, variables, **lskws)

  File "D:\anaconda3\envs\xraylarch\lib\site-packages\scipy\optimize\minpack.py", line 423, in leastsq

    retval = _minpack._lmdif(func, x0, args, full_output, ftol, xtol,

  File "D:\anaconda3\envs\xraylarch\lib\site-packages\lmfit\minimizer.py", line 601, in __residual

    return _nan_policy(np.asarray(out).ravel(),

  File "D:\anaconda3\envs\xraylarch\lib\site-packages\lmfit\minimizer.py", line 2436, in _nan_policy

    raise ValueError(msg)

ValueError: NaN values detected in your input data or the output of your objective/model function - fitting algorithms cannot handle this! Please read https://lmfit.github.io/lmfit-py/faq.html#i-get-errors-from-nan-in-my-fit-what-can-i-do for more information.

 

I don’t know what happened, can somebody help me figure this out?

 

PS: when I use only one del_e0 for every path, no such error happens.

 

Best regards

Fan

_______________________________________________
Ifeffit mailing list
Ifeffit@millenia.cars.aps.anl.gov
http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
Unsubscribe: http://millenia.cars.aps.anl.gov/mailman/options/ifeffit


--
--Matt Newville <newville at cars.uchicago.edu> 630-327-7411