xraypy / xraylarch

Larch: Applications and Python Library for Data Analysis of X-ray Absorption Spectroscopy (XAS, XANES, XAFS, EXAFS), X-ray Fluorescence (XRF) Spectroscopy and Imaging, and more.
https://xraypy.github.io/xraylarch
Other
127 stars 62 forks source link

Fit convolution parameters to experimental data #436

Open maurov opened 1 year ago

maurov commented 1 year ago

@newville @mretegan

This is a follow-up of #435. I was wondering if we could make a fitting routine (based on lmfit) that minimizes the convolutions parameters for a FDMNES simulation in order to best fit the experimental data. Usually this is a manual/visual procedure the user does or, in the worst case, is not done at all and default convolution parameters are simply kept.

If you have ideas or you are willing to share some code, please, feel free to post here.

newville commented 1 year ago

@maurov Yes, thanks for #435 This sort of fitting of the broadening is exactly what I want, too. I find myself (and sometimes see others) spending a lot of time twiddling these parameters.

It is OK to make this be a part of XAS Viewer / Larix ? Like, read in and somehow present unconvolved FDMNES calculations (I would think that "as an XAS Viewer group" would be OK to start), and the convolve to best match experimental data?

maurov commented 1 year ago

@newville

It is OK to make this be a part of XAS Viewer / Larix ? Like, read in and somehow present unconvolved FDMNES calculations (I would think that "as an XAS Viewer group" would be OK to start), and the convolve to best match experimental data?

Yes, this would be great! If you have in mind how should be a function that given unconvoluted XANES calculations - FDMNES or other read as a mu(E) - plus experimental one get the best convolution parameters automagically, it would be wonderful.

maurov commented 1 year ago

@newville @mretegan, FYI:

I have found that in section E of the FDMNES manual, page 71, the possibility to fit the convolution parameters to the experimental spectrum. I have highlighted what I think are the main parameters that affects the convolution in first order.

image

By experience, it is also important how one goes from gamma_hole to gamma_max, that is, going from an arctangent-like to an erf-like function, but this means 3 more parameters in the fit.

At the moment I do not have time to implement this in lmfit, but if any of you is planning to do it, please, keep posted here.